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: Nightly
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).

CountTuple

struct CountTuple[V: Equatable & Hashable & Copyable & Deinitable]

A tuple representing a value and its count in a Counter.

Parameters​

Implemented traits​

AnyType, Comparable, Copyable, Deinitable, Equatable, Movable

Methods​

__init__​

def __init__(out self, value: V, count: Int)

Create a new CountTuple.

Args:

  • ​value (V): The value in the Counter.
  • ​count (Int): The count of the value in the Counter.

__getitem__​

def __getitem__(self, idx: Int) -> Variant[V, Int]

Get an element in the CountTuple.

Args:

  • ​idx (Int): The element to return.

Returns:

Variant[V, Int]: The value if idx is 0 and the count if idx is 1.

__lt__​

def __lt__(self, other: Self) -> Bool

Compare two CountTuples by count, then by value.

Args:

  • ​other (Self): The other CountTuple to compare to.

Returns:

Bool: True if this CountTuple is less than the other, False otherwise.

__eq__​

def __eq__(self, other: Self) -> Bool

Compare two CountTuples for equality.

Args:

  • ​other (Self): The other CountTuple to compare to.

Returns:

Bool: True if the two CountTuples are equal, False otherwise.