IMPORTANT: To view this page as Markdown, append `.md` to the URL (e.g. /docs/manual/basics.md). For the complete Mojo documentation index, see llms.txt.
Skip to main content
Version: 1.0
For the complete Mojo documentation index, see llms.txt. Markdown versions of all pages are available by appending .md to any URL (e.g. /docs/manual/basics.md).

counter

Defines the Counter type.

Import these APIs from the collections package:

from std.collections import Counter

Counters provide convenient tallying objects that use a dictionary to store keys and their counts. They offer the full functionality of counted sets, also called bags or multisets, and extend that model by supporting negative counts.

Structs

  • Counter: A container for counting hashable items.
  • CountTuple: A tuple representing a value and its count in a Counter.