cipher_utils::frequency

Function counts

source
pub fn counts(text: &str) -> HashMap<char, usize>
Expand description

Returns a frequency map of the given text. The turned map maps characters to the number of times they appear in the given string. To get a frequency map that maps characters to percentages, use Frequency::of().

This function treats uppercase and lowercase as identical, and the returned map contains both for each character. Use Frequency::cased_counts() to retrieve a map that’s case-sensitive.

§Performance

This is O(n).

§Returns

A map of characters and the number of times they appear in the given string.