mixed_radix_counter 0.1.0

A no_std crate for counting in a mixed radix system.
Documentation
  • Coverage
  • 0%
    0 out of 7 items documented0 out of 6 items with examples
  • Size
  • Source code size: 8.85 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 2.02 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 14s Average build duration of successful builds.
  • all releases: 14s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • tpdenk/mixed_radix_counter
    0 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • tsatke

Mixed Radix Counter

A counter for a mixed radix system.

The counter consists of values and limits. values overflow at their limit (exclusive).

Given values of [0, 1, 4] and limits of [3, 4, 5], adding 1 to the counter results in the values [0, 2, 0].

Usage

let mut mrc = MixedRadixCounter::try_from_limits([u64::MAX, 365, 24, 60, 60]).expect("default values don't fit the limits");
assert_eq!(*mrc, [0, 0, 0, 0, 0]);

mrc.add(69_413_798); // or call `mrc.increment()` in a loop 69_413_798 times, but beware, that's a lot slower
assert_eq!(*mrc, [2, 73, 9, 36, 38]);

Although numbers are the most obvious element types, this is not restricted to numbers. Look at the generic bounds af you want to see more.

How to contribute

Feel free to send PRs for anything that comes to your mind.