Crates.io | galil-seiferas |
lib.rs | galil-seiferas |
version | 0.1.5 |
source | src |
created_at | 2017-11-09 23:08:06.471146 |
updated_at | 2017-11-25 14:46:31.816871 |
description | General string search in constant space, linear time, for nonorderable alphabets. |
homepage | |
repository | https://github.com/bluss/galil-seiferas |
max_upload_size | |
id | 38787 |
size | 63,812 |
General string search in constant space, linear time, for nonorderable alphabets. Also known as exact string matching.
In Rust terms this means we can define the function:
fn gs_find<T: Eq>(text: &[T], pattern: &[T]) -> Option<usize> {
// ...
}
and the function computes in O(n) time and O(1) space. In the worst case, this algorithm makes 4 n character comparisons.
Note that the Crochemore-Perrin (“Two Way” algorithm) is much superior if there is a linear order for the alphabet.
This work is Copyright 2017 by Ulrik Sverdrup "bluss"; see license terms in the package.
Both papers are recommended reading. The comments in this crate’s implementation are also meant to explain and point out important details, so that’s recommended reading too.