Expand description
Myers algorithm.
Implementations
sourceimpl<T: BitVec> Myers<T>
impl<T: BitVec> Myers<T>
sourcepub fn distance<C, I>(&self, text: I) -> T::DistType where
C: Borrow<u8>,
I: IntoIterator<Item = C>,
pub fn distance<C, I>(&self, text: I) -> T::DistType where
C: Borrow<u8>,
I: IntoIterator<Item = C>,
Calculate the global distance of the pattern to the given text.
sourcepub fn find_all_end<C, I>(
&self,
text: I,
max_dist: T::DistType
) -> Matches<'_, T, C, I::IntoIter>ⓘNotable traits for Matches<'a, T, C, I>impl<'a, T, C, I> Iterator for Matches<'a, T, C, I> where
T: BitVec,
C: Borrow<u8>,
I: Iterator<Item = C>, type Item = (usize, T::DistType);
where
C: Borrow<u8>,
I: IntoIterator<Item = C>,
pub fn find_all_end<C, I>(
&self,
text: I,
max_dist: T::DistType
) -> Matches<'_, T, C, I::IntoIter>ⓘNotable traits for Matches<'a, T, C, I>impl<'a, T, C, I> Iterator for Matches<'a, T, C, I> where
T: BitVec,
C: Borrow<u8>,
I: Iterator<Item = C>, type Item = (usize, T::DistType);
where
C: Borrow<u8>,
I: IntoIterator<Item = C>,
T: BitVec,
C: Borrow<u8>,
I: Iterator<Item = C>, type Item = (usize, T::DistType);
Finds all matches of pattern in the given text up to a given maximum distance. Matches are returned as an iterator over pairs of end position and distance.
sourcepub fn find_best_end<C, I>(&self, text: I) -> (usize, T::DistType) where
C: Borrow<u8>,
I: IntoIterator<Item = C>,
pub fn find_best_end<C, I>(&self, text: I) -> (usize, T::DistType) where
C: Borrow<u8>,
I: IntoIterator<Item = C>,
Find the best match of the pattern in the given text. if multiple end positions have the same distance, the first is returned.
sourcepub fn find_all<C, I>(
&mut self,
text: I,
max_dist: T::DistType
) -> FullMatches<'_, T, C, I::IntoIter>ⓘNotable traits for FullMatches<'a, T, C, I>impl<'a, T, C, I> Iterator for FullMatches<'a, T, C, I> where
T: 'a + BitVec,
C: Borrow<u8>,
I: Iterator<Item = C> + ExactSizeIterator, type Item = (usize, usize, T::DistType);
where
C: Borrow<u8>,
I: IntoIterator<Item = C>,
I::IntoIter: ExactSizeIterator,
pub fn find_all<C, I>(
&mut self,
text: I,
max_dist: T::DistType
) -> FullMatches<'_, T, C, I::IntoIter>ⓘNotable traits for FullMatches<'a, T, C, I>impl<'a, T, C, I> Iterator for FullMatches<'a, T, C, I> where
T: 'a + BitVec,
C: Borrow<u8>,
I: Iterator<Item = C> + ExactSizeIterator, type Item = (usize, usize, T::DistType);
where
C: Borrow<u8>,
I: IntoIterator<Item = C>,
I::IntoIter: ExactSizeIterator,
T: 'a + BitVec,
C: Borrow<u8>,
I: Iterator<Item = C> + ExactSizeIterator, type Item = (usize, usize, T::DistType);
Finds all matches of pattern in the given text up to a given maximum distance.
In contrast to find_all_end
, matches are returned as an iterator over ranges
of (start, end, distance)
. Note that the end coordinate is not included in the
range and thus and thus greater by one compared to the end index returned by
find_all_end()
.
sourcepub fn find_all_lazy<C, I>(
&mut self,
text: I,
max_dist: T::DistType
) -> LazyMatches<'_, T, C, I::IntoIter>ⓘNotable traits for LazyMatches<'a, T, C, I>impl<'a, T, C, I> Iterator for LazyMatches<'a, T, C, I> where
T: BitVec,
C: Borrow<u8>,
I: Iterator<Item = C> + ExactSizeIterator, type Item = (usize, T::DistType);
where
C: Borrow<u8>,
I: IntoIterator<Item = C>,
I::IntoIter: ExactSizeIterator,
pub fn find_all_lazy<C, I>(
&mut self,
text: I,
max_dist: T::DistType
) -> LazyMatches<'_, T, C, I::IntoIter>ⓘNotable traits for LazyMatches<'a, T, C, I>impl<'a, T, C, I> Iterator for LazyMatches<'a, T, C, I> where
T: BitVec,
C: Borrow<u8>,
I: Iterator<Item = C> + ExactSizeIterator, type Item = (usize, T::DistType);
where
C: Borrow<u8>,
I: IntoIterator<Item = C>,
I::IntoIter: ExactSizeIterator,
T: BitVec,
C: Borrow<u8>,
I: Iterator<Item = C> + ExactSizeIterator, type Item = (usize, T::DistType);
As find_all_end
, this function returns an iterator over tuples of (end, distance)
.
Additionally, it keeps the data necessary for later obtaining the starting positions and/or
the alignment path at any position that was already searched.
sourceimpl<T: BitVec> Myers<T>
impl<T: BitVec> Myers<T>
sourcepub fn new<P, C>(pattern: P) -> Self where
C: Borrow<u8>,
P: IntoIterator<Item = C>,
P::IntoIter: ExactSizeIterator,
pub fn new<P, C>(pattern: P) -> Self where
C: Borrow<u8>,
P: IntoIterator<Item = C>,
P::IntoIter: ExactSizeIterator,
Create a new instance of Myers algorithm for a given pattern.
pub fn m(&self) -> T::DistType
Auto Trait Implementations
impl<T> RefUnwindSafe for Myers<T> where
T: RefUnwindSafe,
<T as BitVec>::DistType: RefUnwindSafe,
impl<T> Send for Myers<T> where
T: Send,
<T as BitVec>::DistType: Send,
impl<T> Sync for Myers<T> where
T: Sync,
<T as BitVec>::DistType: Sync,
impl<T> Unpin for Myers<T> where
T: Unpin,
<T as BitVec>::DistType: Unpin,
impl<T> UnwindSafe for Myers<T> where
T: UnwindSafe,
<T as BitVec>::DistType: UnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcepub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<SS, SP> SupersetOf<SS> for SP where
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SP where
SS: SubsetOf<SP>,
pub fn to_subset(&self) -> Option<SS>
pub fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct self
from the equivalent element of its
superset. Read more
pub fn is_in_subset(&self) -> bool
pub fn is_in_subset(&self) -> bool
Checks if self
is actually part of its subset T
(and can be converted to it).
pub fn to_subset_unchecked(&self) -> SS
pub fn to_subset_unchecked(&self) -> SS
Use with care! Same as self.to_subset
but without any property checks. Always succeeds.
pub fn from_subset(element: &SS) -> SP
pub fn from_subset(element: &SS) -> SP
The inclusion map: converts self
to the equivalent element of its superset.