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>
impl<T: Eq> Set<T>
pub fn new() -> Self
pub fn with_capacity(capacity: usize) -> Self
pub fn capacity(&self) -> usize
pub fn clear(&mut self)
pub fn contains<Q>(&self, value: &Q) -> bool
pub fn difference<'a>(&'a self, other: &'a Self) -> Difference<'a, T> ⓘ
pub fn drain(&mut self) -> Drain<'_, T>
pub fn get<Q>(&self, value: &Q) -> Option<&T>
pub fn get_or_insert(&mut self, value: T) -> &T
pub fn get_or_insert_with<Q>( &mut self, value: &Q, f: impl FnOnce(&Q) -> T ) -> &T
pub fn insert(&mut self, value: T) -> bool
pub fn intersection<'a>(&'a self, other: &'a Self) -> Intersection<'a, T> ⓘ
pub fn is_disjoint<'a>(&'a self, other: &'a Self) -> bool
pub fn is_empty(&self) -> bool
pub fn is_subset(&self, other: &Self) -> bool
pub fn is_superset(&self, other: &Self) -> bool
pub fn iter(&self) -> Iter<'_, T>
pub fn len(&self) -> usize
pub fn remove<Q>(&mut self, value: &Q) -> bool
pub fn replace(&mut self, value: T) -> Option<T>
pub fn reserve(&mut self, additional: usize)
pub fn retain(&mut self, f: impl FnMut(&T) -> bool)
pub fn shrink_to_fit(&mut self)
pub fn symmetric_difference<'a>( &'a self, other: &'a Self ) -> SymmetricDifference<'a, T> ⓘ
pub fn take<Q>(&mut self, value: &Q) -> Option<T>
pub fn union<'a>(&'a self, other: &'a Self) -> Union<'a, T> ⓘ
pub fn try_reserve(&mut self, additional: usize) -> Result<(), TryReserveError>
pub fn shrink_to(&mut self, min_capacity: usize)
Trait Implementations§
source§impl<'de, T> Deserialize<'de> for Set<T>where
T: Deserialize<'de>,
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>,
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>
impl<'a, T: 'a + Copy + Eq> Extend<&'a T> for Set<T>
source§fn extend<I: IntoIterator<Item = &'a T>>(&mut self, iter: I)
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)
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)
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>
impl<T: Eq> Extend<T> for Set<T>
source§fn extend<I: IntoIterator<Item = T>>(&mut self, iter: I)
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)
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)
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> FromIterator<T> for Set<T>
impl<T: Eq> FromIterator<T> for Set<T>
source§fn from_iter<I: IntoIterator<Item = T>>(iter: I) -> Self
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>
impl<'a, T> IntoIterator for &'a Set<T>
source§impl<'a, T> IntoIterator for &'a mut Set<T>
impl<'a, T> IntoIterator for &'a mut Set<T>
source§impl<T> IntoIterator for Set<T>
impl<T> IntoIterator for Set<T>
source§impl<T: PartialEq> PartialEq for Set<T>
impl<T: PartialEq> PartialEq for Set<T>
impl<T: Eq> Eq for Set<T>
impl<T> StructuralEq for Set<T>
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> 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