pub struct IdentifiedVec<Id, T> { /* private fields */ }Expand description
Ordered collection with O(1) id lookup (UDF IdentifiedArray parity).
Implementations§
Source§impl<Id, T> IdentifiedVec<Id, T>
impl<Id, T> IdentifiedVec<Id, T>
pub fn new() -> IdentifiedVec<Id, T>
pub fn with_capacity(capacity: usize) -> IdentifiedVec<Id, T>
pub fn len(&self) -> usize
pub fn is_empty(&self) -> bool
pub fn ids(&self) -> impl Iterator<Item = Id>
pub fn iter(&self) -> impl Iterator<Item = &T>
pub fn iter_mut(&mut self) -> impl Iterator<Item = &mut T>
pub fn get(&self, id: Id) -> Option<&T>
pub fn get_mut(&mut self, id: Id) -> Option<&mut T>
pub fn index_of(&self, id: Id) -> Option<usize>
pub fn contains(&self, id: Id) -> bool
Sourcepub fn update(&mut self, id: Id, f: impl FnOnce(&mut T)) -> bool
pub fn update(&mut self, id: Id, f: impl FnOnce(&mut T)) -> bool
Apply a closure to the element with id. Returns false when the id is missing.
The closure must not change the element’s id; use Self::insert to move an
element under a new id.
Sourcepub fn is_consistent(&self) -> bool
pub fn is_consistent(&self) -> bool
Returns true when the internal index matches element order and ids.
Sourcepub fn insert(&mut self, item: T) -> Option<T>
pub fn insert(&mut self, item: T) -> Option<T>
Inserts at the end, or replaces an existing element with the same id (order preserved).
pub fn remove(&mut self, id: Id) -> Option<T>
pub fn reorder(&mut self, from: usize, to: usize) -> bool
Trait Implementations§
Source§impl<Id, T> Clone for IdentifiedVec<Id, T>
impl<Id, T> Clone for IdentifiedVec<Id, T>
Source§fn clone(&self) -> IdentifiedVec<Id, T>
fn clone(&self) -> IdentifiedVec<Id, T>
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl<Id, T> Debug for IdentifiedVec<Id, T>
impl<Id, T> Debug for IdentifiedVec<Id, T>
Source§impl<Id, T> Default for IdentifiedVec<Id, T>
impl<Id, T> Default for IdentifiedVec<Id, T>
Source§fn default() -> IdentifiedVec<Id, T>
fn default() -> IdentifiedVec<Id, T>
Returns the “default value” for a type. Read more
impl<Id, T> Eq for IdentifiedVec<Id, T>where
T: Eq,
Source§impl<'a, Id, T> IntoIterator for &'a IdentifiedVec<Id, T>
impl<'a, Id, T> IntoIterator for &'a IdentifiedVec<Id, T>
Source§impl<'a, Id, T> IntoIterator for &'a mut IdentifiedVec<Id, T>
impl<'a, Id, T> IntoIterator for &'a mut IdentifiedVec<Id, T>
Source§impl<Id, T> PartialEq for IdentifiedVec<Id, T>where
T: PartialEq,
impl<Id, T> PartialEq for IdentifiedVec<Id, T>where
T: PartialEq,
Source§fn eq(&self, other: &IdentifiedVec<Id, T>) -> bool
fn eq(&self, other: &IdentifiedVec<Id, T>) -> bool
Tests for
self and other values to be equal, and is used by ==.Auto Trait Implementations§
impl<Id, T> Freeze for IdentifiedVec<Id, T>
impl<Id, T> RefUnwindSafe for IdentifiedVec<Id, T>where
T: RefUnwindSafe,
Id: RefUnwindSafe,
impl<Id, T> Send for IdentifiedVec<Id, T>
impl<Id, T> Sync for IdentifiedVec<Id, T>
impl<Id, T> Unpin for IdentifiedVec<Id, T>
impl<Id, T> UnsafeUnpin for IdentifiedVec<Id, T>
impl<Id, T> UnwindSafe for IdentifiedVec<Id, T>where
Id: UnwindSafe,
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