Function bio::data_structures::suffix_array::lcp
source · [−]Expand description
Construct lcp array for given text and suffix array of length n. Complexity: O(n).
Arguments
text
- the text ended by sentinel symbol (being lexicographically smallest)pos
- the suffix array for the text
Example
use bio::data_structures::suffix_array::{lcp, suffix_array};
let text = b"GCCTTAACATTATTACGCCTA$";
let pos = suffix_array(text);
// obtain compressed LCP array
let lcp = lcp(text, &pos);
// get most values in O(1).
assert_eq!(lcp.get(6).unwrap(), 4);
// obtain uncompressed LCP array.
let uncompressed = lcp.decompress();
assert_eq!(
uncompressed,
[-1, 0, 1, 1, 2, 1, 4, 0, 1, 3, 1, 1, 2, 0, 4, 0, 2, 2, 2, 1, 3, 3, -1]
)