Mojo struct
CountTuple
struct CountTuple[V: KeyElement]
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
,
UnknownDestructibility
Methods
__init__
__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.
__copyinit__
__copyinit__(out self, other: Self)
Create a new CountTuple by copying another CountTuple.
Args:
- other (
Self
): The CountTuple to copy.
__moveinit__
__moveinit__(out self, owned other: Self)
Create a new CountTuple by moving another CountTuple.
Args:
- other (
Self
): The CountTuple to move.
__getitem__
__getitem__(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, 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, 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?
Thank you! We'll create more content like this.
Thank you for helping us improve!