Comparing v0.1.0
CompareUint
pub func CompareUint(left: uint, right: uint) -> Ordering
The ordering of two uint values.
Both are read by value. Cannot fail; runs in constant time and allocates nothing.
Parameters
| Name | Type | Description |
|---|---|---|
left | uint | one of the two values |
right | uint | the other |
Returns: how left orders against right
CompareUint64
pub func CompareUint64(
left: uint64,
right: uint64
) -> Ordering
The ordering of two uint64 values.
Parameters
| Name | Type | Description |
|---|---|---|
left | uint64 | one of the two values |
right | uint64 | the other |
Returns: how left orders against right
CompareUint32
pub func CompareUint32(
left: uint32,
right: uint32
) -> Ordering
The ordering of two uint32 values.
Parameters
| Name | Type | Description |
|---|---|---|
left | uint32 | one of the two values |
right | uint32 | the other |
Returns: how left orders against right
CompareInt64
pub func CompareInt64(left: int64, right: int64) -> Ordering
The ordering of two int64 values.
Signed, so this is not the unsigned comparison of the same bits: a negative key sorts below every positive one.
Parameters
| Name | Type | Description |
|---|---|---|
left | int64 | one of the two values |
right | int64 | the other |
Returns: how left orders against right
CompareInt32
pub func CompareInt32(left: int32, right: int32) -> Ordering
The ordering of two int32 values.
Parameters
| Name | Type | Description |
|---|---|---|
left | int32 | one of the two values |
right | int32 | the other |
Returns: how left orders against right
CompareChar8
pub func CompareChar8(left: char8, right: char8) -> Ordering
The ordering of two char8 code units.
By code unit, which for ASCII is alphabetical and for anything above it is UTF-8 byte order — which is the order
of the code points, since UTF-8 is ordered that way by construction.
Parameters
| Name | Type | Description |
|---|---|---|
left | char8 | one of the two values |
right | char8 | the other |
Returns: how left orders against right
CompareSlice
pub func CompareSlice(
left: char8[..],
right: char8[..]
) -> Ordering
The ordering of two runs of characters, shortest-first where one is a prefix of the other.
Both are borrowed and read. Compares code unit by code unit and, where every shared position agrees, orders the
shorter one first — which is the ordering a dictionary uses, and the one Rux/Algorithms sorts by.
Cannot fail. Runs in time proportional to the shorter length and allocates nothing.
Parameters
| Name | Type | Description |
|---|---|---|
left | char8[..] | one of the two values |
right | char8[..] | the other |
Returns: how the two order byte by byte, then by length