Struct OrdHashSet

Source
pub struct OrdHashSet<T> { /* private fields */ }
Expand description

A std::collections::HashSet ordered using a Vec.

Implementations§

Source§

impl<T> OrdHashSet<T>

Source

pub fn new() -> Self

Construct a new OrdHashSet.

Source

pub fn with_capacity(capacity: usize) -> Self

Construct a new OrdHashSet with the given capacity.

Source

pub fn iter(&self) -> Iter<'_, T>

Construct an iterator over the items in this OrdHashSet.

Source

pub fn is_empty(&self) -> bool

Return true if this OrdHashSet is empty.

Source

pub fn len(&self) -> usize

Return the number of items in this OrdHashSet.

Source§

impl<T: Eq + Hash + Ord> OrdHashSet<T>

Source

pub fn bisect<Cmp>(&self, cmp: Cmp) -> Option<&T>
where Cmp: Fn(&T) -> Option<Ordering> + Copy,

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.

Source

pub fn bisect_and_remove<Cmp>(&mut self, cmp: Cmp) -> Option<T>
where Cmp: Fn(&T) -> Option<Ordering> + Copy, T: Debug,

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.

Source

pub fn clear(&mut self)

Remove all items from this OrdHashSet.

Source

pub fn contains<Q>(&self, item: &Q) -> bool
where Arc<T>: Borrow<Q>, Q: Hash + Eq + ?Sized,

Return true if the given item is present in this OrdHashSet.

Source

pub fn drain(&mut self) -> Drain<'_, T>

Drain all items from this OrdHashSet.

Source

pub fn drain_while<Cond>(&mut self, cond: Cond) -> DrainWhile<'_, T, Cond>
where Cond: Fn(&T) -> bool,

Drain items from this OrdHashSet while they match the given condition.

Source

pub fn extend<I: IntoIterator<Item = T>>(&mut self, iter: I)

Consume the given iter and insert all its items into this OrdHashSet

Source

pub fn first(&self) -> Option<&T>

Borrow the first item in this OrdHashSet.

Source

pub fn insert(&mut self, item: T) -> bool

Insert an item into this OrdHashSet and return false if it was already present.

Source

pub fn last(&self) -> Option<&T>

Borrow the last item in this OrdHashSet.

Source

pub fn pop_first(&mut self) -> Option<T>
where T: Debug,

Remove and return the first item in this OrdHashSet.

Source

pub fn pop_last(&mut self) -> Option<T>
where T: Debug,

Remove and return the last item in this OrdHashSet.

Source

pub fn remove<Q>(&mut self, item: &Q) -> bool
where Arc<T>: Borrow<Q>, Q: Eq + Hash + Ord,

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.

Source

pub fn starts_with<'a, I: IntoIterator<Item = &'a T>>( &'a self, other: I, ) -> bool
where T: PartialEq,

Return true if the first elements in this set are equal to those in the given iter.

Trait Implementations§

Source§

impl<T: Clone + Eq + Hash + Ord + Debug> Clone for OrdHashSet<T>

Source§

fn clone(&self) -> Self

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<T: Eq + Hash + Ord + Debug> Debug for OrdHashSet<T>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<T: Eq + Hash + Ord + Debug> FromIterator<T> for OrdHashSet<T>

Source§

fn from_iter<I: IntoIterator<Item = T>>(iter: I) -> Self

Creates a value from an iterator. Read more
Source§

impl<T: GetSize> GetSize for OrdHashSet<T>

Source§

fn get_heap_size(&self) -> usize

Determines how many bytes this object occupies inside the heap. Read more
Source§

fn get_stack_size() -> usize

Determines how may bytes this object occupies inside the stack. Read more
Source§

fn get_size(&self) -> usize

Determines the total size of the object. Read more
Source§

impl<'a, T> IntoIterator for &'a OrdHashSet<T>

Source§

type Item = &'a T

The type of the elements being iterated over.
Source§

type IntoIter = Iter<'a, T>

Which kind of iterator are we turning this into?
Source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
Source§

impl<T: Debug> IntoIterator for OrdHashSet<T>

Source§

type Item = T

The type of the elements being iterated over.
Source§

type IntoIter = IntoIter<T>

Which kind of iterator are we turning this into?
Source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
Source§

impl<T: PartialEq + Debug> PartialEq for OrdHashSet<T>

Source§

fn eq(&self, other: &Self) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<T: Eq + Debug> Eq for OrdHashSet<T>

Auto Trait Implementations§

§

impl<T> Freeze for OrdHashSet<T>

§

impl<T> RefUnwindSafe for OrdHashSet<T>
where T: RefUnwindSafe,

§

impl<T> Send for OrdHashSet<T>
where T: Sync + Send,

§

impl<T> Sync for OrdHashSet<T>
where T: Sync + Send,

§

impl<T> Unpin for OrdHashSet<T>

§

impl<T> UnwindSafe for OrdHashSet<T>
where T: RefUnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.