Struct erg_common::set::Set

source ·
pub struct Set<T> { /* private fields */ }

Implementations§

source§

impl<T> Set<T>

source

pub fn new() -> Self

source§

impl<T: Hash> Set<T>

source

pub fn with_capacity(capacity: usize) -> Self

source

pub fn len(&self) -> usize

source

pub fn is_empty(&self) -> bool

source

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

source

pub fn to_vec(&self) -> Vec<T>
where T: Clone,

source

pub fn into_vec(self) -> Vec<T>

source§

impl<T: Hash + Eq> Set<T>

source

pub fn get<Q>(&self, value: &Q) -> Option<&T>
where T: Borrow<Q>, Q: ?Sized + Hash + Eq,

source

pub fn get_by<Q>(&self, value: &Q, cmp: impl Fn(&Q, &Q) -> bool) -> Option<&T>
where T: Borrow<Q>, Q: ?Sized + Hash + Eq,

source

pub fn fast_eq(&self, other: &Set<T>) -> bool

source

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

source

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

newly inserted: true, already present: false

source

pub fn remove<Q>(&mut self, value: &Q) -> bool
where T: Borrow<Q>, Q: ?Sized + Hash + Eq,

source

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

source

pub fn extended<I: IntoIterator<Item = T>>(self, iter: I) -> Self

source

pub fn is_superset(&self, other: &Set<T>) -> bool

source

pub fn merge(&mut self, other: Self)

source

pub fn concat(self, other: Self) -> Self

source

pub fn retain(&mut self, f: impl FnMut(&T) -> bool)

remove all elements for which the predicate returns false

source

pub fn clear(&mut self)

source

pub fn take_all(&mut self) -> Self

source

pub fn inplace_map<F: FnMut(T) -> T>(&mut self, f: F)

source§

impl<T: Hash + Eq + Clone> Set<T>

source

pub fn union(&self, other: &Set<T>) -> Set<T>

assert_eq!(set!{1, 2, 3}.union(&set!{2, 3, 4}), set!{1, 2, 3, 4});
source

pub fn union_iter<'a>( &'a self, other: &'a Set<T> ) -> impl Iterator<Item = &'a T>

source

pub fn union_from_iter<I: Iterator<Item = T>>(&self, iter: I) -> Set<T>

source

pub fn intersection(&self, other: &Set<T>) -> Set<T>

assert_eq!(set!{1, 2, 3}.intersection(&set!{2, 3, 4}), set!{2, 3});
source

pub fn intersec_iter<'a>( &'a self, other: &'a Set<T> ) -> impl Iterator<Item = &'a T>

source

pub fn intersec_from_iter<I: Iterator<Item = T>>(&self, iter: I) -> Set<T>

source

pub fn multi_intersection<I>(i: I) -> Set<T>
where I: Iterator<Item = Set<T>> + Clone,

assert_eq!(Set::multi_intersection([set!{1, 3}, set!{1, 2}].into_iter()), set!{1});
assert_eq!(Set::multi_intersection([set!{1, 3}, set!{1, 2}, set!{2}].into_iter()), set!{1, 2});
assert_eq!(Set::multi_intersection([set!{1, 3}, set!{1, 2}, set!{2, 3}].into_iter()), set!{1, 2, 3});
source

pub fn difference(&self, other: &Set<T>) -> Set<T>

source

pub fn diff_iter<'a>(&'a self, other: &'a Set<T>) -> impl Iterator<Item = &'a T>

source

pub fn include(self, other: T) -> Set<T>

source

pub fn exclude(self, other: &T) -> Set<T>

source§

impl<T: Hash + Ord> Set<T>

source

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

source

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

source§

impl<T: Hash + Display> Set<T>

source

pub fn folded_display(&self) -> String

Trait Implementations§

source§

impl<T: Clone> Clone for Set<T>

source§

fn clone(&self) -> Set<T>

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: Debug> Debug for Set<T>

source§

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

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

impl<T> Default for Set<T>

source§

fn default() -> Self

Returns the “default value” for a type. Read more
source§

impl<T: Display> Display for Set<T>

source§

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

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

impl<T: Hash + Eq, const N: usize> From<[T; N]> for Set<T>

source§

fn from(arr: [T; N]) -> Self

Converts to this type from the input type.
source§

impl<T: Hash + Eq> From<Vec<T>> for Set<T>

source§

fn from(vec: Vec<T>) -> Self

Converts to this type from the input type.
source§

impl<T: Hash + Eq> FromIterator<T> for Set<T>

source§

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

Creates a value from an iterator. Read more
source§

impl<T: Hash> Hash for Set<T>

source§

fn hash<H: Hasher>(&self, state: &mut H)

Feeds this value into the given Hasher. Read more
1.3.0 · source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
source§

impl<T: Hash> IntoIterator for Set<T>

§

type Item = T

The type of the elements being iterated over.
§

type IntoIter = <HashSet<T, BuildHasherDefault<FxHasher>> as IntoIterator>::IntoIter

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: Hash + Eq> PartialEq for Set<T>

source§

fn eq(&self, other: &Set<T>) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<T: Hash + Eq> Eq for Set<T>

Auto Trait Implementations§

§

impl<T> Freeze for Set<T>

§

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

§

impl<T> Send for Set<T>
where T: Send,

§

impl<T> Sync for Set<T>
where T: Sync,

§

impl<T> Unpin for Set<T>
where T: Unpin,

§

impl<T> UnwindSafe for Set<T>
where T: UnwindSafe,

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> 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,

§

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> ToString for T
where T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
source§

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

§

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>,

§

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.