Struct IntervalTreeN

Source
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

Source

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.

Source

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.

Source

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.

Source

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.

Source

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§

Blanket Implementations§

Source§

impl<T> AllocForAny<T> for T

Source§

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

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> 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> 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, 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<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V