Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//! Generic Segment Tree implemented for custom comparator and min functions. | |
//! | |
//! See Chapters 15, 16 in Blandy and Orendorff | |
/// Segment Tree allows for querying information over ranges in a continuous data stream. | |
pub struct SegmentTree<T, Comparator, Minimum> { | |
tree: Vec<T>, | |
n: usize, | |
f: Comparator, | |
d: Minimum, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//! Knuth-Morris-Pratt implementation | |
//! | |
//! See Chapter 17 in Blandy + Orendorff | |
/// computes the KMP longest prefix-suffix function | |
pub fn kmp<T: AsRef<[u8]>>(pattern: T) -> Vec<usize> { | |
let pattern = pattern.as_ref(); | |
let n = pattern.len(); | |
let mut ans = vec![0; n + 1]; |
OlderNewer