Struct map_vec::set::Set

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

map_vec::Set is a data structure with a Set-like API but based on a Vec. It’s primarily useful when you care about constant factors or prefer determinism to speed. Please refer to the docs for Set for details and examples of the Set API.

Example

let mut set1 = map_vec::Set::new();
let mut set2 = map_vec::Set::new();
set1.insert(1);
set1.insert(2);
set2.insert(2);
set2.insert(3);
let mut set3 = map_vec::Set::with_capacity(1);
assert!(set3.insert(3));
assert_eq!(&set2 - &set1, set3);

Implementations§

source§

impl<T: Eq> Set<T>

source

pub fn new() -> Self

source

pub fn with_capacity(capacity: usize) -> Self

source

pub fn capacity(&self) -> usize

source

pub fn clear(&mut self)

source

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

source

pub fn difference<'a>(&'a self, other: &'a Self) -> Difference<'a, T>

source

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

source

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

source

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

source

pub fn get_or_insert_with<Q>( &mut self, value: &Q, f: impl FnOnce(&Q) -> T ) -> &T
where T: Borrow<Q>, Q: Eq + ?Sized,

source

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

source

pub fn intersection<'a>(&'a self, other: &'a Self) -> Intersection<'a, T>

source

pub fn is_disjoint<'a>(&'a self, other: &'a Self) -> bool

source

pub fn is_empty(&self) -> bool

source

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

source

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

source

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

source

pub fn len(&self) -> usize

source

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

source

pub fn replace(&mut self, value: T) -> Option<T>

source

pub fn reserve(&mut self, additional: usize)

source

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

source

pub fn shrink_to_fit(&mut self)

source

pub fn symmetric_difference<'a>( &'a self, other: &'a Self ) -> SymmetricDifference<'a, T>

source

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

source

pub fn union<'a>(&'a self, other: &'a Self) -> Union<'a, T>

source

pub fn try_reserve(&mut self, additional: usize) -> Result<(), TryReserveError>

source

pub fn shrink_to(&mut self, min_capacity: usize)

Trait Implementations§

source§

impl<T: Clone + Eq> BitAnd<&Set<T>> for &Set<T>

§

type Output = Set<T>

The resulting type after applying the & operator.
source§

fn bitand(self, rhs: &Set<T>) -> Set<T>

Performs the & operation. Read more
source§

impl<T: Clone + Eq> BitOr<&Set<T>> for &Set<T>

§

type Output = Set<T>

The resulting type after applying the | operator.
source§

fn bitor(self, rhs: &Set<T>) -> Set<T>

Performs the | operation. Read more
source§

impl<T: Clone + Eq> BitXor<&Set<T>> for &Set<T>

§

type Output = Set<T>

The resulting type after applying the ^ operator.
source§

fn bitxor(self, rhs: &Set<T>) -> Set<T>

Performs the ^ operation. Read more
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<'de, T> Deserialize<'de> for Set<T>
where T: Deserialize<'de>,

source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
source§

impl<'a, T: 'a + Copy + Eq> Extend<&'a T> for Set<T>

source§

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

Extends a collection with the contents of an iterator. Read more
source§

fn extend_one(&mut self, item: A)

🔬This is a nightly-only experimental API. (extend_one)
Extends a collection with exactly one element.
source§

fn extend_reserve(&mut self, additional: usize)

🔬This is a nightly-only experimental API. (extend_one)
Reserves capacity in a collection for the given number of additional elements. Read more
source§

impl<T: Eq> Extend<T> for Set<T>

source§

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

Extends a collection with the contents of an iterator. Read more
source§

fn extend_one(&mut self, item: A)

🔬This is a nightly-only experimental API. (extend_one)
Extends a collection with exactly one element.
source§

fn extend_reserve(&mut self, additional: usize)

🔬This is a nightly-only experimental API. (extend_one)
Reserves capacity in a collection for the given number of additional elements. Read more
source§

impl<V: Eq, T: Into<Vec<V>>> From<T> for Set<V>

source§

fn from(values: T) -> Self

Converts to this type from the input type.
source§

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

source§

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

Creates a value from an iterator. Read more
source§

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

§

type Item = &'a T

The type of the elements being iterated over.
§

type IntoIter = Iter<'a, T>

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

fn into_iter(self) -> <Self as IntoIterator>::IntoIter

Creates an iterator from a value. Read more
source§

impl<'a, T> IntoIterator for &'a mut Set<T>

§

type Item = &'a mut T

The type of the elements being iterated over.
§

type IntoIter = IterMut<'a, T>

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

fn into_iter(self) -> <Self as IntoIterator>::IntoIter

Creates an iterator from a value. Read more
source§

impl<T> IntoIterator for Set<T>

§

type Item = T

The type of the elements being iterated over.
§

type IntoIter = IntoIter<T>

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

fn into_iter(self) -> <Self as IntoIterator>::IntoIter

Creates an iterator from a value. Read more
source§

impl<T: PartialEq> 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> Serialize for Set<T>
where T: Serialize,

source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
source§

impl<T: Clone + Eq> Sub<&Set<T>> for &Set<T>

§

type Output = Set<T>

The resulting type after applying the - operator.
source§

fn sub(self, rhs: &Set<T>) -> Set<T>

Performs the - operation. Read more
source§

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

source§

impl<T> StructuralEq for Set<T>

source§

impl<T> StructuralPartialEq for Set<T>

Auto Trait Implementations§

§

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, 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.
source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,