pub struct SparseSlot<T> { /* private fields */ }Implementations§
Source§impl<T> SparseSlot<T>
impl<T> SparseSlot<T>
Sourcepub fn new(capacity: usize) -> Self
pub fn new(capacity: usize) -> Self
Creates a new SparseSlot with the specified capacity.
§Arguments
capacity- The fixed size of the collection
§Returns
A new SparseSlot instance with all slots initialized to None
§Examples
use sparse_slot::SparseSlot;
let slot: SparseSlot<i32> = SparseSlot::new(5);
assert_eq!(slot.len(), 0);
assert_eq!(slot.capacity(), 5);pub fn try_set(&mut self, id: Id, item: T) -> Result<(), SparseSlotError>
pub fn remove(&mut self, id: Id) -> Option<T>
pub fn clear(&mut self)
pub fn values_mut(&mut self) -> ValuesMut<'_, T> ⓘ
pub fn get_mut(&mut self, id: Id) -> Option<&mut T>
pub fn iter(&self) -> Iter<'_, T> ⓘ
pub fn iter_mut(&mut self) -> IterMut<'_, T> ⓘ
pub fn keys(&self) -> Keys<'_, T> ⓘ
pub fn values(&self) -> Values<'_, T> ⓘ
pub fn drain(&mut self) -> impl Iterator<Item = (Id, T)> + '_
pub fn capacity(&self) -> usize
pub fn len(&self) -> usize
pub fn is_empty(&self) -> bool
pub fn first_id(&self) -> Option<Id>
pub fn last_id(&self) -> Option<Id>
pub fn get(&self, id: Id) -> Option<&T>
Trait Implementations§
Source§impl<T: Debug> Debug for SparseSlot<T>
impl<T: Debug> Debug for SparseSlot<T>
Source§impl<T> FromIterator<(Id, T)> for SparseSlot<T>
impl<T> FromIterator<(Id, T)> for SparseSlot<T>
Auto Trait Implementations§
impl<T> Freeze for SparseSlot<T>
impl<T> RefUnwindSafe for SparseSlot<T>where
T: RefUnwindSafe,
impl<T> Send for SparseSlot<T>where
T: Send,
impl<T> Sync for SparseSlot<T>where
T: Sync,
impl<T> Unpin for SparseSlot<T>where
T: Unpin,
impl<T> UnwindSafe for SparseSlot<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