Skip to main content

IntersectionView

Struct IntersectionView 

Source
pub struct IntersectionView<'a, L, R> { /* private fields */ }
Expand description

An immutable view over the intersection of two TrieViews.

Returned as Option<IntersectionView<'_, L, R>> by TrieView::intersection. None means the two sub-tries are disjoint (no common prefixes possible).

A live IntersectionView can be iterated directly (implements IntoIterator) or composed with further set operations before iterating.

Trait Implementations§

Source§

impl<'a, L, R> AsView<'a> for IntersectionView<'a, L, R>
where L: TrieView<'a>, R: TrieView<'a, P = L::P>,

Source§

type P = <L as TrieView<'a>>::P

The prefix type.
Source§

type View = IntersectionView<'a, L, R>

The concrete view type returned by view.
Source§

fn view(self) -> Self

Get a view rooted at the origin (the entire trie).
Source§

fn view_at(self, prefix: &Self::P) -> Option<Self::View>
where Self: Sized,

Get a view rooted at prefix, or None if the sub-trie is empty.
Source§

impl<'a, L: Clone, R: Clone> Clone for IntersectionView<'a, L, R>

Source§

fn clone(&self) -> IntersectionView<'a, L, R>

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl<'a, L, R> IntoIterator for IntersectionView<'a, L, R>
where L: TrieView<'a>, R: TrieView<'a, P = L::P>,

Source§

type Item = (<L as TrieView<'a>>::P, (<L as TrieView<'a>>::T, <R as TrieView<'a>>::T))

The type of the elements being iterated over.
Source§

type IntoIter = ViewIter<'a, IntersectionView<'a, L, R>>

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

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
Source§

impl<'a, L, R> TrieView<'a> for IntersectionView<'a, L, R>
where L: TrieView<'a>, R: TrieView<'a, P = L::P>,

Source§

fn data_bitmap(&self) -> u32

Only bits present in both data bitmaps.

Source§

fn child_bitmap(&self) -> u32

Only children present in both child bitmaps.

Source§

type P = <L as TrieView<'a>>::P

The prefix type.
Source§

type T = (<L as TrieView<'a>>::T, <R as TrieView<'a>>::T)

The value type yielded by this view (e.g. &'a T, &'a mut T, (&'a L, &'a R)).
Source§

fn depth(&self) -> u32

Depth of the underlying MultiBitNode: always a multiple of K.
Source§

fn key(&self) -> <L::P as Prefix>::R

Accumulated key bits; only the top prefix_len bits are significant.
Source§

fn prefix_len(&self) -> u32

Binary-tree depth of this view’s root position (depth <= prefix_len < depth + K).
Source§

unsafe fn get_data(&mut self, data_bit: u32) -> (L::T, R::T)

Return the value at data_bit. Read more
Source§

unsafe fn get_child(&mut self, child_bit: u32) -> Self

Return a child view at child_bit. Read more
Source§

unsafe fn reposition(&mut self, key: <L::P as Prefix>::R, prefix_len: u32)

Move the cursor to a different location within the same multibit-node. Read more
Source§

fn is_non_empty(&self) -> bool

Whether the sub-trie rooted at this view position is non-empty. Read more
Source§

fn prefix(&self) -> Self::P

Reconstruct the prefix at this view’s root position. Read more
Source§

fn value(self) -> Option<Self::T>

Return the value stored exactly at this view’s root position, if any. Read more
Source§

fn prefix_value(self) -> Option<(Self::P, Self::T)>

Return the prefix and value stored exactly at this view’s root position, if any. Read more
Source§

fn left(self) -> Option<Self>

Return a view into the left (0-bit) child sub-trie, or None if empty. Read more
Source§

fn right(self) -> Option<Self>

Return a view into the right (1-bit) child sub-trie, or None if empty. Read more
Source§

fn navigate_to( self, target_key: <Self::P as Prefix>::R, target_len: u32, ) -> Option<Self>

Navigate toward (target_key, target_len) from this view’s node. Read more
Source§

fn find(self, prefix: &Self::P) -> Option<Self>

Navigate to prefix and return the view if the sub-trie is non-empty. Read more
Source§

fn find_exact(self, prefix: &Self::P) -> Option<Self>

Navigate to prefix and return the view only if a value is stored exactly there. Read more
Source§

fn find_exact_value(self, prefix: &Self::P) -> Option<(Self::P, Self::T)>

Navigate to prefix and return its prefix/value pair if a value is stored exactly there. Read more
Source§

fn find_lpm(self, prefix: &Self::P) -> Option<Self>
where Self: Clone,

Find the view pointing at the longest prefix match for prefix. Read more
Source§

fn find_lpm_value(self, prefix: &Self::P) -> Option<(Self::P, Self::T)>

Find the longest prefix match for prefix and return its prefix/value pair. Read more
Source§

fn iter(self) -> ViewIter<'a, Self>

Return an iterator over all (prefix, value) pairs in this sub-trie. Read more
Source§

fn iter_from(self, prefix: &Self::P, inclusive: bool) -> ViewIter<'a, Self>

Return an iterator starting at the given prefix in lexicographic order. Read more
Source§

fn keys(self) -> ViewKeys<'a, Self>

Return an iterator over all prefixes in this sub-trie. Read more
Source§

fn values(self) -> ViewValues<'a, Self>

Return an iterator over all values in this sub-trie. Read more
Source§

fn intersection<R>( self, other: R, ) -> Option<IntersectionView<'a, Self, R::View>>
where R: AsView<'a, P = Self::P>,

Return the intersection of self and other as a view, or None if disjoint. Read more
Source§

fn union<R>(self, other: R) -> UnionView<'a, Self, R::View>
where R: AsView<'a, P = Self::P>,

Return the union of self and other as a view. Read more
Source§

fn covering_union<R>(self, other: R) -> CoveringUnionView<'a, Self, R::View>
where Self: Clone, R: AsView<'a, P = Self::P>, R::View: Clone,

Return the covering union of self and other as a view. Read more
Source§

fn difference<R>(self, other: R) -> DifferenceView<'a, Self, R::View>
where R: AsView<'a, P = Self::P>,

Return the difference of self minus other as a view. Read more
Source§

fn eq_keys<R: AsView<'a, P = Self::P>>(self, other: R) -> bool

Check whether self and other contain exactly the same set of prefixes, ignoring values. Read more
Source§

fn eq_by<R, F>(self, other: R, cmp: F) -> bool
where Self::P: PartialEq, R: AsView<'a, P = Self::P>, F: FnMut(Self::T, <<R as AsView<'a>>::View as TrieView<'a>>::T) -> bool,

Check whether self and other contain the same prefixes with equal values, using cmp to compare each value pair. Read more
Source§

fn covering_difference<R>( self, other: R, ) -> CoveringDifferenceView<'a, Self, R::View>
where R: AsView<'a, P = Self::P>,

Return the covering difference of self minus other as a view. Read more
Source§

fn step(self, go_right: bool) -> Option<Self>

Step one binary level deeper, going left (0-bit) or right (1-bit).

Auto Trait Implementations§

§

impl<'a, L, R> Freeze for IntersectionView<'a, L, R>
where L: Freeze, R: Freeze,

§

impl<'a, L, R> RefUnwindSafe for IntersectionView<'a, L, R>

§

impl<'a, L, R> Send for IntersectionView<'a, L, R>
where L: Send, R: Send,

§

impl<'a, L, R> Sync for IntersectionView<'a, L, R>
where L: Sync, R: Sync,

§

impl<'a, L, R> Unpin for IntersectionView<'a, L, R>
where L: Unpin, R: Unpin,

§

impl<'a, L, R> UnsafeUnpin for IntersectionView<'a, L, R>
where L: UnsafeUnpin, R: UnsafeUnpin,

§

impl<'a, L, R> UnwindSafe for IntersectionView<'a, L, R>
where L: UnwindSafe, R: 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<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.