Skip to main content

MultipleSuffixTree

Struct MultipleSuffixTree 

Source
pub struct MultipleSuffixTree<T>
where T: Ord + Clone,
{ texts: Vec<Vec<T>>, offsets: Vec<usize>, tree: SuffixTree<Delimited<T>>, position_map: Vec<(usize, usize)>, }

Fields§

§texts: Vec<Vec<T>>§offsets: Vec<usize>§tree: SuffixTree<Delimited<T>>§position_map: Vec<(usize, usize)>

Implementations§

Source§

impl<T> MultipleSuffixTree<T>
where T: Ord + Clone,

Source

pub fn new(texts: Vec<Vec<T>>) -> Self

Source

pub fn texts(&self) -> &[Vec<T>]

Source

pub fn suffix_array(&self) -> &[usize]

Source

pub fn lcp_array(&self) -> &[usize]

Source

pub fn rank(&self) -> &[usize]

Source

pub fn node_size(&self) -> usize

Source

pub fn node(&self, node_id: usize) -> &STNode

Source

pub fn children(&self, node_id: usize) -> &[usize]

Source

pub fn position_map(&self) -> &[(usize, usize)]

Source

pub fn depth_range(&self, node_id: usize) -> Range<usize>

Source

pub fn kth_substrings(&self) -> MultipleKthSubstrings<'_, T>

Source

fn to_global_start(&self, text_idx: usize, pos: usize) -> usize

Examples found in repository?
crates/competitive/src/string/suffix_tree.rs (line 577)
573    pub fn index_of_distinct_substring(&self, (text_idx, range): (usize, Range<usize>)) -> u64 {
574        debug_assert!(text_idx < self.tree.texts.len());
575        debug_assert!(range.start < range.end && range.end <= self.tree.texts[text_idx].len());
576        let m = range.len();
577        let start = self.tree.to_global_start(text_idx, range.start);
578        let sa_idx = self.tree.tree.rank[start];
579        let leaf = self.tree.tree.leafs[sa_idx];
580        let node = self.tree.tree.node_covering_depth(leaf, m);
581        let parent_depth = self.tree.tree.nodes[self.tree.tree.nodes[node].parent].depth;
582        let offset = m - (parent_depth + 1);
583        self.prefix_distinct[node - 1] + offset as u64
584    }
585
586    pub fn index_of_substring(&self, (text_idx, range): (usize, Range<usize>)) -> u64 {
587        debug_assert!(text_idx < self.tree.texts.len());
588        debug_assert!(range.start < range.end && range.end <= self.tree.texts[text_idx].len());
589        let m = range.len();
590        let start = self.tree.to_global_start(text_idx, range.start);
591        let sa_idx = self.tree.tree.rank[start];
592        let leaf = self.tree.tree.leafs[sa_idx];
593        let node = self.tree.tree.node_covering_depth(leaf, m);
594        let parent_depth = self.tree.tree.nodes[self.tree.tree.nodes[node].parent].depth;
595        let offset = m - (parent_depth + 1);
596        let occ = self.tree.tree.nodes[node].sa_range.len() as u64;
597        let occ_idx = (sa_idx - self.tree.tree.nodes[node].sa_range.start) as u64;
598        self.prefix_total[node - 1] + offset as u64 * occ + occ_idx
599    }

Auto Trait Implementations§

§

impl<T> Freeze for MultipleSuffixTree<T>

§

impl<T> RefUnwindSafe for MultipleSuffixTree<T>
where T: RefUnwindSafe,

§

impl<T> Send for MultipleSuffixTree<T>
where T: Send,

§

impl<T> Sync for MultipleSuffixTree<T>
where T: Sync,

§

impl<T> Unpin for MultipleSuffixTree<T>
where T: Unpin,

§

impl<T> UnsafeUnpin for MultipleSuffixTree<T>

§

impl<T> UnwindSafe for MultipleSuffixTree<T>
where 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> 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> ToArrayVecScalar for T

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.