toy-lib-0.1.0.0
Safe HaskellSafe-Inferred
LanguageHaskell2010

Data.ByteString.SuffixArray

Description

Suffix Array calculation.

Definition

\(\mathcal{sa}[i] = \mathcal{originalOrderOf}(\mathcal{sa}[(n-1-i):])\) where \(\mathcal{originalOrderOf(i)}\) returns the order of i-th suffix.

Synopsis

Documentation

saOfNaive :: ByteString -> Vector Int #

\(O(N^2 \log N)\) Suffix array calculation.

saOf :: ByteString -> Vector Int #

\(O(N \log N)\) Suffix array calculation.

The \(O(N \log N)\) algorithm

Binary lifting with smart sort.

     a    b    a    $
    ab   ba   a$   $a
  aba$ ba$a a$ab $aba

sortCyclicShifts :: ByteString -> Vector Int #

\(O(N \log N)\) Sorts cyclic substrings of bs of length n.

sortByCharacter :: ByteString -> (Int, Vector Int, Vector Int) #

\(O(N)\) Preprocessing function to sortCyclicShifts.

sortCyclicShifts' :: Int -> Int -> Int -> Vector Int -> Vector Int -> Vector Int #

\(O(N \log N)\) Binary lifting part of sortCyclicShifts.

lcpOfSa :: ByteString -> Vector Int -> Vector Int #

Creates an LCP array of length n-1: \(\mathcal{lcp}[i'] = \mathcal{lcp}(\mathcal{sa}[i'], \mathcal{sa}[i'+1])\).

countUniqueSubstrings :: ByteString -> Int #

\(O(N \log N)\) Counts unique substrings.