/// Constructs a LcsTable for matching between two sequences `a` and `b`.
Constructs a LcsTable for matching between two sequences `a` and `b`.
Constructs a LcsTable for matching between two sequences ` a ` and ` b ` .
pub fn new(a: &'a [T], b: &'a [T]) -> LcsTable<'a, T> {
        let mut lengths = vec![vec![0; b.len() + 1]; a.len() + 1];
        for i in 0..a.len() {
            for j in 0..b.len() {
                lengths[i + 1][j + 1] = if a[i] == b[j] {
                    1 + lengths[i][j]
                } else {
                    cmp::max(lengths[i + 1][j], lengths[i][j + 1])
                }
            }
        }
        LcsTable { lengths: lengths, a: a, b: b }
    }
pub fn new ( a : & ' a [ T ] , b : & ' a [ T ] ) -> LcsTable < ' a , T > { let mut lengths = vec ! [ vec [ 0 b len ( ) 1 ] a len ( ) 1 ] ; for i in 0 .. a . len ( ) { for j in 0 .. b . len ( ) { lengths [ i + 1 ] [ j + 1 ] = if a [ i ] == b [ j ] { 1 + lengths [ i ] [ j ] } else { cmp :: max ( lengths [ i + 1 ] [ j ] , lengths [ i ] [ j + 1 ] ) } } } LcsTable { lengths : lengths , a : a , b : b } }
Constructs a LcsTable for matching between two sequences `a` and `b`.
Constructs a LcsTable for matching between two sequences ` a ` and ` b ` .
a
&'a [T]
b
&'a [T]