pub struct IntervalTreeN {
expected: &'static [&'static str],
maps: Vec<IntervalMap<usize, Vec<&'static [&'static str]>>>,
}
Expand description
A structure encapsulating an interval-based mapping designed to index and query segments of expected string data.
It maintains a reference to an array of constant strings along with a vector of interval maps that associate ranges of indices with collections of string slice arrays. This design facilitates efficient operations for matching, extracting, and navigating through substrings or superstrings based on predefined expectations.
Fields§
§expected: &'static [&'static str]
§maps: Vec<IntervalMap<usize, Vec<&'static [&'static str]>>>
Implementations§
Source§impl IntervalTreeN
impl IntervalTreeN
Sourcepub fn new(expected: &'static [&'static str]) -> Self
pub fn new(expected: &'static [&'static str]) -> Self
Creates a new instance using the provided expected strings and initializes an internal collection of interval maps.
Constructs the instance by assigning the given expected strings and generating one interval map per expected element, ensuring a corresponding structure is available for each.
Sourcepub fn insert(&mut self, key: &'static [&'static str])
pub fn insert(&mut self, key: &'static [&'static str])
Inserts a key into the interval-based mapping structure by iterating over corresponding expected string slices and mutable interval maps.
The method scans each component of the key against its paired expected string to identify all matching substrings through pattern matching. For each match, it computes a range based on the match index and the length of the key component. If an existing entry for the range is found, it appends the key; otherwise, it creates a new entry with the key.
Sourcepub fn insert_first_occur(&mut self, key: &'static [&'static str])
pub fn insert_first_occur(&mut self, key: &'static [&'static str])
Inserts the first occurrence of each element of the provided key into the interval tree by mapping the range of its first match in the corresponding expected string.
Iterates over each element of the key array alongside the expected strings and mutable maps. For each pair, it identifies the first matching index in the expected string and constructs a range covering that occurrence. It then updates the map at that range by appending the key if the range already exists or inserting a new entry if it does not.
Sourcepub fn superstrings(
&self,
key: &'static [&'static str],
) -> impl Iterator<Item = &'static [&'static str]> + '_
pub fn superstrings( &self, key: &'static [&'static str], ) -> impl Iterator<Item = &'static [&'static str]> + '_
Returns an iterator over stored string sequences that are valid superstrings of the provided key.
Selects a dimension based on the longest string in the key and then retrieves intervals from the corresponding expected string. These intervals are used to access candidate sequences, which are filtered to retain only those sequences that have the supplied key as a substring, yielding an iterator over matching sequences.
Sourcepub fn substrings(
&self,
key: &'static [&'static str],
) -> impl Iterator<Item = &'static [&'static str]> + '_
pub fn substrings( &self, key: &'static [&'static str], ) -> impl Iterator<Item = &'static [&'static str]> + '_
Returns an iterator over elements from the interval tree whose stored string slices satisfy a substring inclusion condition with respect to the provided key.
Selects the key element with the minimum length to guide the search for matching intervals. Then, for each occurrence of that element within the expected string, it gathers a range corresponding to that match and scans the associated interval map entries. Finally, it filters and returns only those entries whose string slices fulfill the substring checking predicate relative to the entire key.
Auto Trait Implementations§
impl Freeze for IntervalTreeN
impl RefUnwindSafe for IntervalTreeN
impl Send for IntervalTreeN
impl Sync for IntervalTreeN
impl Unpin for IntervalTreeN
impl UnwindSafe for IntervalTreeN
Blanket Implementations§
Source§impl<T> AllocForAny<T> for T
impl<T> AllocForAny<T> for T
Source§fn galloc(self) -> &'static T
fn galloc(self) -> &'static T
Provides a method to allocate an instance of T
on the heap with a static lifetime.
This implementation of galloc
takes ownership of the T
instance and uses the alloc
function to place it in a location with a static lifetime, presumably managing it in a way that ensures its persistence for the duration of the program.
This can be particularly useful for scenarios where a static lifetime is required, such as when interfacing with systems or patterns that necessitate global state or long-lived data.
Source§fn galloc_mut(self) -> &'static T
fn galloc_mut(self) -> &'static T
Provides a method that moves the instance and returns a reference to it allocated with a static lifetime.
This method utilizes alloc_mut
to perform the allocation, likely involving allocating the resource in a manner that ensures it lives for the entire duration of the application.
These semantics allow the user to safely assume that the reference will not expire during the program’s execution, making it suitable for long-lived data structures or operations that require such guarantees.
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> 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