pub struct OrderedSet<K> { /* private fields */ }Expand description
Efficient Ordered Set implementatoin that keeps track of the order of insertions and deletions.
Every operation is O(1).
Implementations§
Source§impl<K> OrderedSet<K>
impl<K> OrderedSet<K>
pub fn new() -> Self
pub fn first(&self) -> Option<&K>
Sourcepub fn insert(&mut self, key: K) -> bool
pub fn insert(&mut self, key: K) -> bool
Insert a key into the set.
Returns true if the key was already present in the set.
Sourcepub fn pop_next(&mut self) -> Option<K>
pub fn pop_next(&mut self) -> Option<K>
Pops the next element inserted into the set.
Returns None if the set is empty.
Sourcepub fn remove(&mut self, key: &K) -> bool
pub fn remove(&mut self, key: &K) -> bool
Removes a key from the set.
Returns true if the key was present in the set.
Sourcepub fn iter(&self) -> OrderedSetIter<'_, K> ⓘ
pub fn iter(&self) -> OrderedSetIter<'_, K> ⓘ
Returns an iterator over the keys in the set.
pub fn len(&self) -> usize
Trait Implementations§
Source§impl<K: Clone> Clone for OrderedSet<K>
impl<K: Clone> Clone for OrderedSet<K>
Source§fn clone(&self) -> OrderedSet<K>
fn clone(&self) -> OrderedSet<K>
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<K: Debug> Debug for OrderedSet<K>
impl<K: Debug> Debug for OrderedSet<K>
Source§impl<K: Default> Default for OrderedSet<K>
impl<K: Default> Default for OrderedSet<K>
Source§fn default() -> OrderedSet<K>
fn default() -> OrderedSet<K>
Returns the “default value” for a type. Read more
Source§impl<K> IntoIterator for OrderedSet<K>
impl<K> IntoIterator for OrderedSet<K>
Auto Trait Implementations§
impl<K> Freeze for OrderedSet<K>
impl<K> RefUnwindSafe for OrderedSet<K>where
K: RefUnwindSafe,
impl<K> Send for OrderedSet<K>where
K: Send,
impl<K> Sync for OrderedSet<K>where
K: Sync,
impl<K> Unpin for OrderedSet<K>where
K: Unpin,
impl<K> UnsafeUnpin for OrderedSet<K>
impl<K> UnwindSafe for OrderedSet<K>where
K: 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