MCPcopy Create free account
hub / github.com/douchuan/algorithm / compute

Method compute

src/strings/count.rs:8–18  ·  view source on GitHub ↗
(alphabet: &Alphabet, s: &str)

Source from the content-addressed store, hash-verified

6
7impl 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}

Callers

nothing calls this directly

Calls 1

to_indexMethod · 0.80

Tested by

no test coverage detected