Skip to main content
Log in

Mojo struct

CountTuple

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

Parameters​

  • ​V (KeyElement): The value in the Counter.

Implemented traits​

AnyType, CollectionElement, Copyable, Movable

Methods​

__init__​

__init__(inout self: 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.

__copyinit__​

__copyinit__(inout self: Self, other: Self)

Create a new CountTuple by copying another CountTuple.

Args:

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

__moveinit__​

__moveinit__(inout self: Self, owned other: Self)

Create a new CountTuple by moving another CountTuple.

Args:

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

__getitem__​

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

Get an element in the tuple.

Args:

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

Returns:

The value if idx is 0 and the count if idx is 1.

__lt__​

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

Compare two CountTuples by count, then by value.

Args:

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

Returns:

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

__eq__​

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

Compare two CountTuples for equality.

Args:

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

Returns:

True if the two CountTuples are equal, False otherwise.

Was this page helpful?