(alphabet: &Alphabet, s: &str)
| 6 | |
| 7 | impl Count { |
| 8 | pub fn compute(alphabet: &Alphabet, s: &str) -> Vec<usize> { |
| 9 | let mut count = vec![0; alphabet.radix()]; |
| 10 | for c in s.chars() { |
| 11 | if let Some(&i) = alphabet.to_index(c) { |
| 12 | if i >= 0 { |
| 13 | count[i as usize] += 1; |
| 14 | } |
| 15 | } |
| 16 | } |
| 17 | count |
| 18 | } |
| 19 | } |