Skip to content

Commit 1f4cb0e

Browse files
committed
feat(doc): more
1 parent 3819505 commit 1f4cb0e

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

src/string/multiple_longest_common_subsequence.rs

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,16 @@ use std::collections::HashMap;
44

55
const IMPOSSIBLE_NB: usize = 999_999_999_999;
66

7-
// saves all the precalculations needed
7+
// saves the precalculations
8+
// will be moved around a lot
9+
// alphabet : the common alphabet
10+
// chains : the strings among which the common subsequence is
11+
// d : the number of strings
12+
// f : for each point, an heuristic function
13+
// g : for each point, the number of ancestors
14+
// ms : the table of suffix tables
15+
// mt : the lookup table
16+
// parents : the ancestor tree
817
struct Context {
918
alphabet: Vec<char>,
1019
chains: Vec<Vec<char>>,
@@ -53,21 +62,21 @@ impl Context {
5362
}
5463
}
5564

56-
// ascend back up the parent tree to form the common string
65+
// ascend back up the parent tree to form the common subsequence
5766
fn common_seq(ctx: &Context, p: &Vec<usize>) -> String {
5867
let ref_str: &Vec<char> = &ctx.chains[0];
59-
let mut common_sequence: Vec<char> = vec![];
68+
let mut common_subsequence: Vec<char> = vec![];
6069
// Gaining mutability
6170
let mut p = p;
6271

6372
while ctx.parents[p].is_some() {
64-
common_sequence.push(ref_str[p[0]]);
73+
common_subsequence.push(ref_str[p[0]]);
6574

6675
// getting the parent of current point
6776
p = ctx.parents[p].as_ref().unwrap();
6877
}
6978

70-
common_sequence.iter().rev().collect::<String>()
79+
common_subsequence.iter().rev().collect::<String>()
7180
}
7281

7382
/// Heuristic to find the smallest common alphabet among the strings

0 commit comments

Comments
 (0)