pub struct FlatMultiset<T, S = RandomState> { /* private fields */ }
Expand description
Multiset implementation where items are stored as a flattened hash set.
§Examples
use flat_multimap::FlatMultiset;
let mut set = FlatMultiset::new();
set.insert(1);
set.insert(1);
set.insert(2);
assert_eq!(set.len(), 3);
Implementations§
Source§impl<T> FlatMultiset<T, RandomState>
impl<T> FlatMultiset<T, RandomState>
Sourcepub fn new() -> Self
pub fn new() -> Self
Creates an empty FlatMultiset
with a capacity of 0,
so it will not allocate until it is first inserted into.
§Examples
use flat_multimap::FlatMultiset;
let mut set: FlatMultiset<i32> = FlatMultiset::new();
assert_eq!(set.capacity(), 0);
Sourcepub fn with_capacity(capacity: usize) -> Self
pub fn with_capacity(capacity: usize) -> Self
Creates an empty FlatMultiset
with at least the specified capacity.
Source§impl<T, S> FlatMultiset<T, S>
impl<T, S> FlatMultiset<T, S>
Sourcepub const fn with_hasher(hash_builder: S) -> Self
pub const fn with_hasher(hash_builder: S) -> Self
Creates an empty FlatMultiset
with default capacity which will use the given hash builder to hash keys.
Sourcepub fn with_capacity_and_hasher(capacity: usize, hash_builder: S) -> Self
pub fn with_capacity_and_hasher(capacity: usize, hash_builder: S) -> Self
Creates an empty FlatMultiset
with at least the specified capacity, using the given hash builder to hash keys.
Sourcepub fn capacity(&self) -> usize
pub fn capacity(&self) -> usize
Returns the number of elements the map can hold without reallocating.
Sourcepub const fn hasher(&self) -> &S
pub const fn hasher(&self) -> &S
Returns a reference to the set’s BuildHasher
.
Sourcepub fn drain(&mut self) -> Drain<'_, T> ⓘ
pub fn drain(&mut self) -> Drain<'_, T> ⓘ
Clears the set, returning all elements as an iterator.
Source§impl<T, S> FlatMultiset<T, S>
impl<T, S> FlatMultiset<T, S>
Sourcepub fn reserve(&mut self, additional: usize)
pub fn reserve(&mut self, additional: usize)
Reserves capacity for at least additional more elements to be inserted in the FlatMultset
.
Sourcepub fn try_reserve(&mut self, additional: usize) -> Result<(), TryReserveError>
pub fn try_reserve(&mut self, additional: usize) -> Result<(), TryReserveError>
Tries to reserve capacity for at least additional more elements to be inserted in the FlatMultset
.
Sourcepub fn shrink_to_fit(&mut self)
pub fn shrink_to_fit(&mut self)
Shrinks the capacity of the set as much as possible.
Sourcepub fn shrink_to(&mut self, min_capacity: usize)
pub fn shrink_to(&mut self, min_capacity: usize)
Shrinks the capacity of the set with a lower limit.
Sourcepub fn remove<Q>(&mut self, value: &Q) -> bool
pub fn remove<Q>(&mut self, value: &Q) -> bool
Removes a value from the set. Returns whether the value was present in the set.
§Examples
use flat_multimap::FlatMultiset;
let mut set = FlatMultiset::new();
set.insert(1);
set.insert(1);
assert!(set.remove(&1));
assert!(set.remove(&1));
assert!(!set.remove(&1));
Trait Implementations§
Source§impl<T: Clone, S: Clone> Clone for FlatMultiset<T, S>
impl<T: Clone, S: Clone> Clone for FlatMultiset<T, S>
Source§fn clone(&self) -> FlatMultiset<T, S>
fn clone(&self) -> FlatMultiset<T, S>
1.0.0 · Source§const fn clone_from(&mut self, source: &Self)
const fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl<T, S> Debug for FlatMultiset<T, S>where
T: Debug,
impl<T, S> Debug for FlatMultiset<T, S>where
T: Debug,
Source§impl<T, S> Default for FlatMultiset<T, S>where
S: Default,
impl<T, S> Default for FlatMultiset<T, S>where
S: Default,
Source§impl<'de, T, S> Deserialize<'de> for FlatMultiset<T, S>
impl<'de, T, S> Deserialize<'de> for FlatMultiset<T, S>
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>,
Source§impl<'a, T, S> Extend<&'a T> for FlatMultiset<T, S>
impl<'a, T, S> Extend<&'a T> for FlatMultiset<T, S>
Source§fn extend<I: IntoIterator<Item = &'a T>>(&mut self, iter: I)
fn extend<I: IntoIterator<Item = &'a T>>(&mut self, iter: I)
Source§fn extend_one(&mut self, item: A)
fn extend_one(&mut self, item: A)
extend_one
)Source§fn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
extend_one
)Source§impl<T, S> Extend<T> for FlatMultiset<T, S>
impl<T, S> Extend<T> for FlatMultiset<T, S>
Source§fn extend<I: IntoIterator<Item = T>>(&mut self, iter: I)
fn extend<I: IntoIterator<Item = T>>(&mut self, iter: I)
Source§fn extend_one(&mut self, item: A)
fn extend_one(&mut self, item: A)
extend_one
)Source§fn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
extend_one
)Source§impl<T, const N: usize> From<[T; N]> for FlatMultiset<T, RandomState>
impl<T, const N: usize> From<[T; N]> for FlatMultiset<T, RandomState>
Source§impl<T, S> FromIterator<T> for FlatMultiset<T, S>
impl<T, S> FromIterator<T> for FlatMultiset<T, S>
Source§fn from_iter<I: IntoIterator<Item = T>>(iter: I) -> Self
fn from_iter<I: IntoIterator<Item = T>>(iter: I) -> Self
Source§impl<T, S> FromParallelIterator<T> for FlatMultiset<T, S>
impl<T, S> FromParallelIterator<T> for FlatMultiset<T, S>
Source§fn from_par_iter<P>(par_iter: P) -> Selfwhere
P: IntoParallelIterator<Item = T>,
fn from_par_iter<P>(par_iter: P) -> Selfwhere
P: IntoParallelIterator<Item = T>,
par_iter
. Read moreSource§impl<'a, T, S> IntoIterator for &'a FlatMultiset<T, S>
impl<'a, T, S> IntoIterator for &'a FlatMultiset<T, S>
Source§impl<T, S> IntoIterator for FlatMultiset<T, S>
impl<T, S> IntoIterator for FlatMultiset<T, S>
Source§impl<'a, T: Sync, S> IntoParallelIterator for &'a FlatMultiset<T, S>
impl<'a, T: Sync, S> IntoParallelIterator for &'a FlatMultiset<T, S>
Source§impl<T: Send, S> IntoParallelIterator for FlatMultiset<T, S>
impl<T: Send, S> IntoParallelIterator for FlatMultiset<T, S>
Source§impl<'a, T, S> ParallelExtend<&'a T> for FlatMultiset<T, S>
impl<'a, T, S> ParallelExtend<&'a T> for FlatMultiset<T, S>
Source§fn par_extend<I>(&mut self, par_iter: I)where
I: IntoParallelIterator<Item = &'a T>,
fn par_extend<I>(&mut self, par_iter: I)where
I: IntoParallelIterator<Item = &'a T>,
par_iter
. Read moreSource§impl<T, S> ParallelExtend<T> for FlatMultiset<T, S>
impl<T, S> ParallelExtend<T> for FlatMultiset<T, S>
Source§fn par_extend<I>(&mut self, par_iter: I)where
I: IntoParallelIterator<Item = T>,
fn par_extend<I>(&mut self, par_iter: I)where
I: IntoParallelIterator<Item = T>,
par_iter
. Read moreAuto Trait Implementations§
impl<T, S> Freeze for FlatMultiset<T, S>where
S: Freeze,
impl<T, S> RefUnwindSafe for FlatMultiset<T, S>where
S: RefUnwindSafe,
T: RefUnwindSafe,
impl<T, S> Send for FlatMultiset<T, S>
impl<T, S> Sync for FlatMultiset<T, S>
impl<T, S> Unpin for FlatMultiset<T, S>
impl<T, S> UnwindSafe for FlatMultiset<T, S>where
S: UnwindSafe,
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more