Skip to main content

SequenceMatcher

Struct SequenceMatcher 

Source
pub struct SequenceMatcher<'a, T: Eq + Hash> { /* private fields */ }
Expand description

SequenceMatcher(None, a, b, autojunk): finds the longest matching blocks of two sequences, recursively.

Implementations§

Source§

impl<'a, T: Eq + Hash> SequenceMatcher<'a, T>

Source

pub fn new(a: &'a [T], b: &'a [T], autojunk: bool) -> Self

SequenceMatcher(None, a, b, autojunk=autojunk).

Source

pub fn find_longest_match( &self, alo: usize, ahi: usize, blo: usize, bhi: usize, ) -> Match

find_longest_match(alo, ahi, blo, bhi): the longest matching block in a[alo..ahi] and b[blo..bhi], the earliest in a, then in b; then extended by the popular elements around it.

Source

pub fn get_matching_blocks(&self) -> Vec<Match>

get_matching_blocks: the matching blocks, increasing in a and b, adjacent ones collapsed, ending with (len(a), len(b), 0).

Source

pub fn get_opcodes(&self) -> Vec<Opcode>

get_opcodes: how to turn a into b.

Source

pub fn get_grouped_opcodes(&self, n: i128) -> Vec<Vec<Opcode>>

get_grouped_opcodes(n): the groups of changes with n lines of context.

Trait Implementations§

Source§

impl<'a, T: Debug + Eq + Hash> Debug for SequenceMatcher<'a, T>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'a, T> Forget for SequenceMatcher<'a, T>

§

impl<'a, T> Freeze for SequenceMatcher<'a, T>

§

impl<'a, T> Move for SequenceMatcher<'a, T>

§

impl<'a, T> RefUnwindSafe for SequenceMatcher<'a, T>

§

impl<'a, T> Send for SequenceMatcher<'a, T>
where &'a [T]: Send, HashMap<&'a T, Vec<usize>>: Send,

§

impl<'a, T> Sync for SequenceMatcher<'a, T>
where &'a [T]: Sync, HashMap<&'a T, Vec<usize>>: Sync,

§

impl<'a, T> Unpin for SequenceMatcher<'a, T>
where &'a [T]: Unpin, HashMap<&'a T, Vec<usize>>: Unpin,

§

impl<'a, T> UnsafeUnpin for SequenceMatcher<'a, T>

§

impl<'a, T> UnwindSafe for SequenceMatcher<'a, T>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> AsAny for T
where T: Any,

Source§

fn as_any(&self) -> &(dyn Any + 'static)

self as &dyn Any.
Source§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

self as &mut dyn Any.
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.