Struct rolling_hash::RollingHash
source · pub struct RollingHash { /* private fields */ }
Expand description
Rolling Hash です。O(文字列長) の前計算をしたうえで、部分文字列のハッシュ値を O(1) で計算します。
Implementations§
source§impl RollingHash
impl RollingHash
pub fn new(xs: &[u64]) -> Self
pub fn len(&self) -> usize
pub fn is_empty(&self) -> bool
pub fn at(&self, i: usize) -> u64
sourcepub fn is_substring(&self, other: &Self) -> bool
pub fn is_substring(&self, other: &Self) -> bool
self が other の部分文字列かどうかを返します。
O(other.len())
Examples
use rolling_hash::RollingHash;
let rh1 = RollingHash::from_iter("abcd".bytes());
let rh2 = RollingHash::from_iter("xxabcdyy".bytes());
assert!(rh1.is_substring(&rh2));
Trait Implementations§
source§impl Clone for RollingHash
impl Clone for RollingHash
source§fn clone(&self) -> RollingHash
fn clone(&self) -> RollingHash
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresource§impl Debug for RollingHash
impl Debug for RollingHash
source§impl<T> FromIterator<T> for RollingHashwhere
T: Into<u64>,
impl<T> FromIterator<T> for RollingHashwhere T: Into<u64>,
source§fn from_iter<I: IntoIterator<Item = T>>(iter: I) -> Self
fn from_iter<I: IntoIterator<Item = T>>(iter: I) -> Self
Creates a value from an iterator. Read more