[−][src]Struct genmap::GenMap
A collection of T
's referred to by Handle
's.
When you add an object to the GenMap
it will
return a Handle
, and you can look that item up
by that Handle
. You can also remove the item,
which makes any old Handle
's to it become invalid
and attempting to get it will return None
.
Methods
impl<T> GenMap<T>
[src]
pub fn with_capacity(capacity: usize) -> Self
[src]
Create a new empty GenMap
with enough memory to accomodate
the given number of items without reallocating.
pub fn insert(&mut self, itm: T) -> Handle
[src]
Insert the element into the map and return a handle referring to it.
pub fn get(&self, h: Handle) -> Option<&T>
[src]
Returns a reference to the item if the handle is valid,
or None
otherwise.
pub fn get_mut(&mut self, h: Handle) -> Option<&mut T>
[src]
Returns a mutable reference to the item if the handle is valid,
or None
otherwise.
pub fn remove(&mut self, h: Handle) -> Option<T>
[src]
Removes the referenced item from the map, returning it. Returns None if the handle is stale.
pub fn count(&self) -> usize
[src]
Number of items in the map.
pub fn capacity(&self) -> usize
[src]
The total number of items the map has free memory to contain.
ⓘImportant traits for Iterator<'_, T>pub fn iter(&self) -> Iterator<T>
[src]
Trait Implementations
impl<T: Default> Default for GenMap<T>
[src]
impl<T: Clone> Clone for GenMap<T>
[src]
fn clone(&self) -> GenMap<T>
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more
impl<T: Debug> Debug for GenMap<T>
[src]
Auto Trait Implementations
impl<T> Send for GenMap<T> where
T: Send,
T: Send,
impl<T> Unpin for GenMap<T> where
T: Unpin,
T: Unpin,
impl<T> Sync for GenMap<T> where
T: Sync,
T: Sync,
impl<T> UnwindSafe for GenMap<T> where
T: UnwindSafe,
T: UnwindSafe,
impl<T> RefUnwindSafe for GenMap<T> where
T: RefUnwindSafe,
T: RefUnwindSafe,
Blanket Implementations
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,