Struct PrefixSetMut
pub struct PrefixSetMut { /* private fields */ }Expand description
A container for efficiently storing and checking for the presence of key prefixes.
This data structure stores a set of Nibbles and provides methods to insert
new elements and check whether any existing element has a given prefix.
Internally, this implementation stores keys in an unsorted Vec<Nibbles> together with an
all flag. The all flag indicates that every entry should be considered changed and that
individual keys can be ignored.
Sorting and deduplication do not happen during insertion or membership checks on this mutable
structure. Instead, keys are sorted and deduplicated when converting into the immutable
PrefixSet via freeze(). The immutable PrefixSet provides contains and relies on the
sorted and unique keys produced by freeze(); it does not perform additional sorting or
deduplication.
This guarantees that a PrefixSet constructed from a PrefixSetMut is always sorted and
deduplicated.
§Examples
use reth_trie_common::{prefix_set::PrefixSetMut, Nibbles};
let mut prefix_set_mut = PrefixSetMut::default();
prefix_set_mut.insert(Nibbles::from_nibbles_unchecked(&[0xa, 0xb]));
prefix_set_mut.insert(Nibbles::from_nibbles_unchecked(&[0xa, 0xb, 0xc]));
let mut prefix_set = prefix_set_mut.freeze();
assert!(prefix_set.contains(&Nibbles::from_nibbles_unchecked([0xa, 0xb])));
assert!(prefix_set.contains(&Nibbles::from_nibbles_unchecked([0xa, 0xb, 0xc])));Implementations§
§impl PrefixSetMut
impl PrefixSetMut
pub fn with_capacity(capacity: usize) -> PrefixSetMut
pub fn with_capacity(capacity: usize) -> PrefixSetMut
Create PrefixSetMut with pre-allocated capacity.
pub const fn all() -> PrefixSetMut
pub const fn all() -> PrefixSetMut
Create PrefixSetMut that considers all key changed.
pub fn extend(&mut self, other: PrefixSetMut)
pub fn extend(&mut self, other: PrefixSetMut)
Extend prefix set with contents of another prefix set.
pub fn extend_ref(&mut self, other: &PrefixSetMut)
pub fn extend_ref(&mut self, other: &PrefixSetMut)
Extend prefix set with contents of another prefix set by reference.
pub fn append(&mut self, other: &mut PrefixSetMut)
pub fn append(&mut self, other: &mut PrefixSetMut)
Appends prefix set keys from another mutable prefix set, leaving it empty.
pub fn extend_keys<I>(&mut self, keys: I)where
I: IntoIterator<Item = Nibbles>,
pub fn extend_keys<I>(&mut self, keys: I)where
I: IntoIterator<Item = Nibbles>,
Extend prefix set keys with contents of provided iterator.
pub fn clear(&mut self)
pub fn clear(&mut self)
Clears the inner vec for reuse, setting all to false.
Trait Implementations§
§impl Clone for PrefixSetMut
impl Clone for PrefixSetMut
§fn clone(&self) -> PrefixSetMut
fn clone(&self) -> PrefixSetMut
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more§impl Debug for PrefixSetMut
impl Debug for PrefixSetMut
§impl Default for PrefixSetMut
impl Default for PrefixSetMut
§fn default() -> PrefixSetMut
fn default() -> PrefixSetMut
impl Eq for PrefixSetMut
§impl<I> From<I> for PrefixSetMutwhere
I: IntoIterator<Item = Nibbles>,
impl<I> From<I> for PrefixSetMutwhere
I: IntoIterator<Item = Nibbles>,
§fn from(value: I) -> PrefixSetMut
fn from(value: I) -> PrefixSetMut
§impl<'a> IntoIterator for &'a PrefixSetMut
impl<'a> IntoIterator for &'a PrefixSetMut
§impl PartialEq for PrefixSetMut
impl PartialEq for PrefixSetMut
impl StructuralPartialEq for PrefixSetMut
Auto Trait Implementations§
impl Freeze for PrefixSetMut
impl RefUnwindSafe for PrefixSetMut
impl Send for PrefixSetMut
impl Sync for PrefixSetMut
impl Unpin for PrefixSetMut
impl UnsafeUnpin for PrefixSetMut
impl UnwindSafe for PrefixSetMut
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
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 moreimpl<T> MaybeDebug for Twhere
T: Debug,
§impl<T> Pointable for T
impl<T> Pointable for T
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
§impl<T> WithSubscriber for T
impl<T> WithSubscriber for T
§fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘwhere
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘwhere
S: Into<Dispatch>,
§fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ
fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ
Source§impl<T> WithSubscriber for T
impl<T> WithSubscriber for T
Source§fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘwhere
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘwhere
S: Into<Dispatch>,
Source§fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ
fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ
Layout§
Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain repr(...) attributes. Please see the Rust Reference's “Type Layout” chapter for details on type layout guarantees.
Size: 32 bytes