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 duplicate 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 RollingHash
impl<T> FromIterator<T> for RollingHash
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
Auto Trait Implementations§
impl Freeze for RollingHash
impl RefUnwindSafe for RollingHash
impl Send for RollingHash
impl Sync for RollingHash
impl Unpin for RollingHash
impl UnwindSafe for RollingHash
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more