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?
Thank you! We'll create more content like this.
Thank you for helping us improve!
If you'd like to share more information, please report an issue on GitHub