HashTrieSet

Struct HashTrieSet 

Source
pub struct HashTrieSet<T, P = RcK, H = RandomState>
where H: BuildHasher + Clone, T: Eq + Hash, P: SharedPointerKind,
{ /* private fields */ }
Expand description

A persistent set with structural sharing. This implementation uses a hash array mapped trie.

§Complexity

Let n be the number of elements in the set.

§Temporal complexity

OperationAverageWorst case
new()Θ(1)Θ(1)
insert()Θ(1)Θ(n)
remove()Θ(1)Θ(n)
get()Θ(1)Θ(n)
contains()Θ(1)Θ(n)
size()Θ(1)Θ(1)
clone()Θ(1)Θ(1)
iterator creationΘ(1)Θ(1)
iterator stepΘ(1)Θ(1)
iterator fullΘ(n)Θ(n)

§Implementation details

This is a thin wrapper around a HashTrieMap.

Implementations§

Source§

impl<T> HashTrieSet<T>
where T: Eq + Hash,

Source

pub fn new() -> HashTrieSet<T>

Source

pub fn new_with_degree(degree: u8) -> HashTrieSet<T>

Source§

impl<T> HashTrieSet<T, ArcTK>
where T: Eq + Hash,

Source§

impl<T, P, H> HashTrieSet<T, P, H>
where H: BuildHasher + Clone, T: Eq + Hash, P: SharedPointerKind,

Source

pub fn new_with_hasher_with_ptr_kind(hasher_builder: H) -> HashTrieSet<T, P, H>

Source

pub fn new_with_hasher_and_degree_and_ptr_kind( hasher_builder: H, degree: u8, ) -> HashTrieSet<T, P, H>

Source

pub fn insert(&self, v: T) -> HashTrieSet<T, P, H>

Source

pub fn insert_mut(&mut self, v: T)

Source

pub fn remove<V>(&self, v: &V) -> HashTrieSet<T, P, H>
where T: Borrow<V>, V: Hash + Eq + ?Sized,

Source

pub fn remove_mut<V>(&mut self, v: &V) -> bool
where T: Borrow<V>, V: Hash + Eq + ?Sized,

Source

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

Source

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

Source

pub fn is_disjoint<HO>(&self, other: &HashTrieSet<T, P, HO>) -> bool
where HO: BuildHasher + Clone,

Source

pub fn ptr_eq<PO, HO>(&self, other: &HashTrieSet<T, PO, HO>) -> bool

Test whether the two sets refer to the same content in memory.

This would return true if you’re comparing a set to itself, or if you’re comparing a set to a fresh clone of itself.

Source

pub fn is_subset<HO>(&self, other: &HashTrieSet<T, P, HO>) -> bool
where HO: BuildHasher + Clone,

Source

pub fn is_superset<HO>(&self, other: &HashTrieSet<T, P, HO>) -> bool
where HO: BuildHasher + Clone,

Source

pub fn size(&self) -> usize

Source

pub fn is_empty(&self) -> bool

Source

pub fn iter( &self, ) -> Map<Map<IterPtr<'_, T, (), P>, fn(&SharedPointer<Entry<T, ()>, P>) -> (&T, &())>, fn((&T, &())) -> &T>

Trait Implementations§

Source§

impl<T, P, H> Clone for HashTrieSet<T, P, H>
where H: BuildHasher + Clone, T: Eq + Hash, P: SharedPointerKind,

Source§

fn clone(&self) -> HashTrieSet<T, P, H>

Returns a duplicate 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, P, H> Debug for HashTrieSet<T, P, H>

Source§

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

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

impl<T, P, H> Default for HashTrieSet<T, P, H>

Source§

fn default() -> HashTrieSet<T, P, H>

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

impl<'de, T, P, H> Deserialize<'de> for HashTrieSet<T, P, H>

Source§

fn deserialize<D>( deserializer: D, ) -> Result<HashTrieSet<T, P, H>, <D as Deserializer<'de>>::Error>
where D: Deserializer<'de>,

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

impl<T, P, H> Display for HashTrieSet<T, P, H>

Source§

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

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

impl<T, P, H> FromIterator<T> for HashTrieSet<T, P, H>

Source§

fn from_iter<I>(into_iter: I) -> HashTrieSet<T, P, H>
where I: IntoIterator<Item = T>,

Creates a value from an iterator. Read more
Source§

impl<'a, T, P, H> IntoIterator for &'a HashTrieSet<T, P, H>

Source§

type Item = &'a T

The type of the elements being iterated over.
Source§

type IntoIter = Map<Map<IterPtr<'a, T, (), P>, fn(&'a SharedPointer<Entry<T, ()>, P>) -> (&'a T, &'a ())>, fn((&'a T, &())) -> &'a T>

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

fn into_iter( self, ) -> Map<Map<IterPtr<'a, T, (), P>, fn(&'a SharedPointer<Entry<T, ()>, P>) -> (&'a T, &'a ())>, fn((&'a T, &())) -> &'a T>

Creates an iterator from a value. Read more
Source§

impl<T, P, PO, H> PartialEq<HashTrieSet<T, PO, H>> for HashTrieSet<T, P, H>

Source§

fn eq(&self, other: &HashTrieSet<T, PO, H>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<T, P, H> Serialize for HashTrieSet<T, P, H>

Source§

fn serialize<S>( &self, serializer: S, ) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>
where S: Serializer,

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

impl<T, P, H> Eq for HashTrieSet<T, P, H>
where T: Eq + Hash, H: BuildHasher + Clone, P: SharedPointerKind,

Auto Trait Implementations§

§

impl<T, P, H> Freeze for HashTrieSet<T, P, H>
where H: Freeze, P: Freeze,

§

impl<T, P, H> RefUnwindSafe for HashTrieSet<T, P, H>

§

impl<T, P, H> Send for HashTrieSet<T, P, H>
where H: Send, P: Send + Sync, T: Sync + Send,

§

impl<T, P, H> Sync for HashTrieSet<T, P, H>
where H: Sync, P: Sync + Send, T: Sync + Send,

§

impl<T, P, H> Unpin for HashTrieSet<T, P, H>
where H: Unpin,

§

impl<T, P, H> UnwindSafe for HashTrieSet<T, P, H>
where H: UnwindSafe, P: 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<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. 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<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> ToString for T
where T: Display + ?Sized,

Source§

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

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