pub struct OrdHashSet<T> { /* private fields */ }
Expand description
A std::collections::HashSet
ordered using a Vec
.
Implementations§
Source§impl<T> OrdHashSet<T>
impl<T> OrdHashSet<T>
Sourcepub fn new() -> Self
pub fn new() -> Self
Construct a new OrdHashSet
.
Sourcepub fn with_capacity(capacity: usize) -> Self
pub fn with_capacity(capacity: usize) -> Self
Construct a new OrdHashSet
with the given capacity
.
Sourcepub fn iter(&self) -> Iter<'_, T> ⓘ
pub fn iter(&self) -> Iter<'_, T> ⓘ
Construct an iterator over the items in this OrdHashSet
.
Sourcepub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
Return true
if this OrdHashSet
is empty.
Sourcepub fn len(&self) -> usize
pub fn len(&self) -> usize
Return the number of items in this OrdHashSet
.
Source§impl<T: Eq + Hash + Ord> OrdHashSet<T>
impl<T: Eq + Hash + Ord> OrdHashSet<T>
Sourcepub fn bisect<Cmp>(&self, cmp: Cmp) -> Option<&T>
pub fn bisect<Cmp>(&self, cmp: Cmp) -> Option<&T>
Bisect this set to match an item using the provided comparison, and return it (if present).
The first item for which the comparison returns Some(Ordering::Equal)
will be returned.
This method assumes that any partially-ordered items (where cmp(item).is_none()
)
are ordered at the beginning or end of the set.
Sourcepub fn bisect_and_remove<Cmp>(&mut self, cmp: Cmp) -> Option<T>
pub fn bisect_and_remove<Cmp>(&mut self, cmp: Cmp) -> Option<T>
Bisect this set to match and remove an item using the provided comparison.
The first item for which the comparison returns Some(Ordering::Equal)
will be returned.
This method assumes that any partially-ordered items (where cmp(item).is_none()
)
are ordered at the beginning and/or end of the set.
Sourcepub fn clear(&mut self)
pub fn clear(&mut self)
Remove all items from this OrdHashSet
.
Sourcepub fn contains<Q>(&self, item: &Q) -> bool
pub fn contains<Q>(&self, item: &Q) -> bool
Return true
if the given item is present in this OrdHashSet
.
Sourcepub fn drain(&mut self) -> Drain<'_, T> ⓘ
pub fn drain(&mut self) -> Drain<'_, T> ⓘ
Drain all items from this OrdHashSet
.
Sourcepub fn drain_while<Cond>(&mut self, cond: Cond) -> DrainWhile<'_, T, Cond> ⓘ
pub fn drain_while<Cond>(&mut self, cond: Cond) -> DrainWhile<'_, T, Cond> ⓘ
Drain items from this OrdHashSet
while they match the given cond
ition.
Sourcepub fn extend<I: IntoIterator<Item = T>>(&mut self, iter: I)
pub fn extend<I: IntoIterator<Item = T>>(&mut self, iter: I)
Consume the given iter
and insert all its items into this OrdHashSet
Sourcepub fn first(&self) -> Option<&T>
pub fn first(&self) -> Option<&T>
Borrow the first item in this OrdHashSet
.
Sourcepub fn insert(&mut self, item: T) -> bool
pub fn insert(&mut self, item: T) -> bool
Insert an item
into this OrdHashSet
and return false
if it was already present.
Sourcepub fn last(&self) -> Option<&T>
pub fn last(&self) -> Option<&T>
Borrow the last item in this OrdHashSet
.
Sourcepub fn pop_first(&mut self) -> Option<T>where
T: Debug,
pub fn pop_first(&mut self) -> Option<T>where
T: Debug,
Remove and return the first item in this OrdHashSet
.
Sourcepub fn pop_last(&mut self) -> Option<T>where
T: Debug,
pub fn pop_last(&mut self) -> Option<T>where
T: Debug,
Remove and return the last item in this OrdHashSet
.
Sourcepub fn remove<Q>(&mut self, item: &Q) -> bool
pub fn remove<Q>(&mut self, item: &Q) -> bool
Remove the given item
from this OrdHashSet
and return true
if it was present.
The item may be any borrowed form of T
,
but the ordering on the borrowed form must match the ordering of T
.
Sourcepub fn starts_with<'a, I: IntoIterator<Item = &'a T>>(
&'a self,
other: I,
) -> boolwhere
T: PartialEq,
pub fn starts_with<'a, I: IntoIterator<Item = &'a T>>(
&'a self,
other: I,
) -> boolwhere
T: PartialEq,
Return true
if the first elements in this set are equal to those in the given iter
.