Function esaxx_rs::suffix

source ·
pub fn suffix(string: &str) -> Result<Suffix<i32>, SuffixError>
Expand description

Creates the suffix array and provides an iterator over its items (c++ unsafe version)

Gives you an iterator over the suffixes of the input array and their count within the input srtring.

let string = "abracadabra";
let suffix = esaxx_rs::suffix(string).unwrap();
let chars: Vec<_> = string.chars().collect();
let mut iter = suffix.iter();
assert_eq!(iter.next().unwrap(), (&chars[..4], 2)); // abra
assert_eq!(iter.next(), Some((&chars[..1], 5))); // a
assert_eq!(iter.next(), Some((&chars[1..4], 2))); // bra
assert_eq!(iter.next(), Some((&chars[2..4], 2))); // ra
assert_eq!(iter.next(), Some((&chars[..0], 11))); // ''
assert_eq!(iter.next(), None);