Skip to main content

Module rank

Module rank 

Source
Expand description

Lexicographic rank for fractional indexing.

Backlog order is stored as a string that sorts lexicographically. Because a gap can always be generated between two ranks, reordering an item only rewrites that one item — neighbors keep their ranks, so insertion and movement are O(1) writes.

The internal representation is a base-36 (0-9a-z) digit string read as the fraction 0.d1 d2 …. In ASCII the ordering 09 < az matches the numeric order of the digits, so a plain string comparison is already numeric sort order. Digit values stay in 0..36, so all internal arithmetic uses u8.

It is implemented in-house rather than pulling in a crate: in line with the project’s minimal-dependency policy, the logic fits in a few dozen lines of std-only code (see docs/DESIGN.md).

Structs§

Rank
Comparable ranks ordered lexicographically.
RankStats
Rank-length statistics used to decide whether Rank::rebalance is needed.