Struct FlatMultiset

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

Source

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);
Source

pub fn with_capacity(capacity: usize) -> Self

Creates an empty FlatMultiset with at least the specified capacity.

Source§

impl<T, S> FlatMultiset<T, S>

Source

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.

Source

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.

Source

pub fn capacity(&self) -> usize

Returns the number of elements the map can hold without reallocating.

Source

pub const fn hasher(&self) -> &S

Returns a reference to the set’s BuildHasher.

Source

pub fn len(&self) -> usize

Returns the number of elements in the set.

Source

pub fn is_empty(&self) -> bool

Returns true if the set contains no elements.

Source

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

Clears the set, returning all elements as an iterator.

Source

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

Retains only the elements specified by the predicate.

Source

pub fn clear(&mut self)

Clears the set, removing all values.

Source

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

An iterator visiting all elements in arbitrary order. The iterator element type is &'a T.

Source§

impl<T, S> FlatMultiset<T, S>
where T: Eq + Hash, S: BuildHasher,

Source

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

Reserves capacity for at least additional more elements to be inserted in the FlatMultset.

Source

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.

Source

pub fn shrink_to_fit(&mut self)

Shrinks the capacity of the set as much as possible.

Source

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

Shrinks the capacity of the set with a lower limit.

Source

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

Adds a value to the set.

Source

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

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));
Source

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

Returns true if the set contains the value.

Source§

impl<T, S> FlatMultiset<T, S>
where T: Eq + Hash + Send,

Source

pub fn par_drain(&mut self) -> ParDrain<'_, T>

Consumes (potentially in parallel) all values in an arbitrary order.

Trait Implementations§

Source§

impl<T: Clone, S: Clone> Clone for FlatMultiset<T, S>

Source§

fn clone(&self) -> FlatMultiset<T, S>

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

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

Performs copy-assignment from source. Read more
Source§

impl<T, S> Debug for FlatMultiset<T, S>
where T: Debug,

Source§

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

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

impl<T, S> Default for FlatMultiset<T, S>
where S: Default,

Source§

fn default() -> Self

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

impl<'de, T, S> Deserialize<'de> for FlatMultiset<T, S>
where T: Deserialize<'de> + Eq + Hash, S: BuildHasher + Default,

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, S> Extend<&'a T> for FlatMultiset<T, S>
where T: 'a + Eq + Hash + Copy, S: BuildHasher,

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, S> Extend<T> for FlatMultiset<T, S>
where T: Eq + Hash, S: BuildHasher,

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<T, const N: usize> From<[T; N]> for FlatMultiset<T, RandomState>
where T: Eq + Hash,

Source§

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

Converts to this type from the input type.
Source§

impl<T, S> FromIterator<T> for FlatMultiset<T, S>
where T: Eq + Hash, S: BuildHasher + Default,

Source§

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

Creates a value from an iterator. Read more
Source§

impl<T, S> FromParallelIterator<T> for FlatMultiset<T, S>
where T: Eq + Hash + Send, S: BuildHasher + Default,

Source§

fn from_par_iter<P>(par_iter: P) -> Self
where P: IntoParallelIterator<Item = T>,

Creates an instance of the collection from the parallel iterator par_iter. Read more
Source§

impl<'a, T, S> IntoIterator for &'a FlatMultiset<T, S>

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) -> Iter<'a, T>

Creates an iterator from a value. Read more
Source§

impl<T, S> IntoIterator for FlatMultiset<T, S>

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) -> IntoIter<T>

Creates an iterator from a value. Read more
Source§

impl<'a, T: Sync, S> IntoParallelIterator for &'a FlatMultiset<T, S>

Source§

type Item = &'a T

The type of item that the parallel iterator will produce.
Source§

type Iter = ParIter<'a, T>

The parallel iterator type that will be created.
Source§

fn into_par_iter(self) -> Self::Iter

Converts self into a parallel iterator. Read more
Source§

impl<T: Send, S> IntoParallelIterator for FlatMultiset<T, S>

Source§

type Item = T

The type of item that the parallel iterator will produce.
Source§

type Iter = IntoParIter<T>

The parallel iterator type that will be created.
Source§

fn into_par_iter(self) -> Self::Iter

Converts self into a parallel iterator. Read more
Source§

impl<'a, T, S> ParallelExtend<&'a T> for FlatMultiset<T, S>
where T: 'a + Copy + Eq + Hash + Sync, S: BuildHasher,

Source§

fn par_extend<I>(&mut self, par_iter: I)
where I: IntoParallelIterator<Item = &'a T>,

Extends an instance of the collection with the elements drawn from the parallel iterator par_iter. Read more
Source§

impl<T, S> ParallelExtend<T> for FlatMultiset<T, S>
where T: Eq + Hash + Send, S: BuildHasher,

Source§

fn par_extend<I>(&mut self, par_iter: I)
where I: IntoParallelIterator<Item = T>,

Extends an instance of the collection with the elements drawn from the parallel iterator par_iter. Read more
Source§

impl<T, H> Serialize for FlatMultiset<T, H>
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

Auto Trait Implementations§

§

impl<T, S> Freeze for FlatMultiset<T, S>
where S: Freeze,

§

impl<T, S> RefUnwindSafe for FlatMultiset<T, S>

§

impl<T, S> Send for FlatMultiset<T, S>
where S: Send, T: Send,

§

impl<T, S> Sync for FlatMultiset<T, S>
where S: Sync, T: Sync,

§

impl<T, S> Unpin for FlatMultiset<T, S>
where S: Unpin, T: Unpin,

§

impl<T, S> UnwindSafe for FlatMultiset<T, S>
where S: UnwindSafe, 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> 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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<'data, I> IntoParallelRefIterator<'data> for I
where I: 'data + ?Sized, &'data I: IntoParallelIterator,

Source§

type Iter = <&'data I as IntoParallelIterator>::Iter

The type of the parallel iterator that will be returned.
Source§

type Item = <&'data I as IntoParallelIterator>::Item

The type of item that the parallel iterator will produce. This will typically be an &'data T reference type.
Source§

fn par_iter(&'data self) -> <I as IntoParallelRefIterator<'data>>::Iter

Converts self into a parallel iterator. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
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.
Source§

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