pub struct InternedInput<T> {
pub before: Vec<Token>,
pub after: Vec<Token>,
pub interner: Interner<T>,
}
Expand description
Two lists of interned tokens that a Diff
can be computed from.
A token represents the smallest possible unit of change during a diff. For text this is usually a line, a word or a single character. All algorithms operate on interned tokens instead of using the token data directly. This allows for much better performance by amortizing the cost of hashing/equality.
While you can intern tokens yourself it is strongly recommended to use InternedInput
module.
Fields§
§before: Vec<Token>
§after: Vec<Token>
§interner: Interner<T>
Implementations§
Source§impl<T> InternedInput<T>
impl<T> InternedInput<T>
Source§impl<T: Eq + Hash> InternedInput<T>
impl<T: Eq + Hash> InternedInput<T>
pub fn new<I: TokenSource<Token = T>>(before: I, after: I) -> Self
Sourcepub fn reserve_for_token_source<S: TokenSource<Token = T> + ?Sized>(
&mut self,
before: &S,
after: &S,
)
pub fn reserve_for_token_source<S: TokenSource<Token = T> + ?Sized>( &mut self, before: &S, after: &S, )
Create an Interner with an intial capacity calculated by calling
estimate_tokens
methods of before
and after
pub fn reserve(&mut self, capacity_before: u32, capacity_after: u32)
Sourcepub fn update_before(&mut self, input: impl Iterator<Item = T>)
pub fn update_before(&mut self, input: impl Iterator<Item = T>)
replaces self.before
with the interned Tokens yielded by input
Note that this does not erase any tokens from the interner and might therefore be considered
a memory leak. If this function is called often over a long_running process
consider clearing the interner with clear
.
Sourcepub fn update_after(&mut self, input: impl Iterator<Item = T>)
pub fn update_after(&mut self, input: impl Iterator<Item = T>)
replaces self.before
with the interned Tokens yielded by input
Note that this does not erase any tokens from the interner and might therefore be considered
a memory leak. If this function is called often over a long_running process
consider clearing the interner with clear
or
erase_tokens_after
.