pub struct GenerationalBuffer<T> { /* private fields */ }Expand description
A generic append-only circular buffer with generational IDs
Inserting returns a Handle that can be used to access the value later,
checking the item hasn’t been replaced in the meantime.
Implementations§
Source§impl<T> GenerationalBuffer<T>
impl<T> GenerationalBuffer<T>
Sourcepub fn new(max_capacity: usize) -> Self
pub fn new(max_capacity: usize) -> Self
Creates a new generational buffer with the specified maximum capacity
Sourcepub fn push(&mut self, value: T) -> Handle<T>
pub fn push(&mut self, value: T) -> Handle<T>
Inserts a value into the buffer and returns a handle to it
Sourcepub fn get(&self, handle: Handle<T>) -> Option<&T>
pub fn get(&self, handle: Handle<T>) -> Option<&T>
Gets a reference to the value associated with the handle
Sourcepub fn get_mut(&mut self, handle: Handle<T>) -> Option<&mut T>
pub fn get_mut(&mut self, handle: Handle<T>) -> Option<&mut T>
Gets a mutable reference to the value associated with the handle
Sourcepub fn is_valid(&self, handle: Handle<T>) -> bool
pub fn is_valid(&self, handle: Handle<T>) -> bool
Checks if a handle is still valid (points to existing data)
Sourcepub fn iter(&self) -> impl Iterator<Item = (Handle<T>, &T)>
pub fn iter(&self) -> impl Iterator<Item = (Handle<T>, &T)>
Returns an iterator over all entries with their handles, in no particular order
Trait Implementations§
Auto Trait Implementations§
impl<T> Freeze for GenerationalBuffer<T>
impl<T> RefUnwindSafe for GenerationalBuffer<T>where
T: RefUnwindSafe,
impl<T> Send for GenerationalBuffer<T>where
T: Send,
impl<T> Sync for GenerationalBuffer<T>where
T: Sync,
impl<T> Unpin for GenerationalBuffer<T>where
T: Unpin,
impl<T> UnwindSafe for GenerationalBuffer<T>where
T: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more