skip to content
==> README.md <==
1# @ajax/mesh-jobs-ranges
2
3A set of u64 items as disjoint, non-touching half-open ranges `[s, e)`, in order: a job's items (a
4Slurm-like array, or endless: `[s, UINT64_MAX)`). Insert, remove, union, subtract, intersect, take
5from the front, the n-th item, and the text form `a-b,c-d` (`a-` is endless, `-` is empty) with its
6parser (which also takes single items `a`).
7
8```c
9#include "mesh/jobs/ranges.h"
10mj_ranges r = mj_ranges_of(0, 100);
11mj_ranges_take(&r, 7);            /* 0-7,8-100 */
12mj_ranges front = mj_ranges_take_front(&r, 10);
13```
14
15A zeroed `mj_ranges` is the empty set; free with `mj_ranges_free`.
16
17## Ported from
18
19[alpha-rust-mesh](https://github.com/rsafier/alpha-rust-mesh) (Richard Safier, MIT):
20`crates/mesh-host/src/jobs.rs`, `Ranges` (a `BTreeMap<u64, u64>` there; a sorted array of pairs here,
21with the same results).
22
23## Tests
24
25`tests/ranges.c`: jobs.rs's `ranges` test, the parse error text, and 20 000 random inserts, removes,
26intersections, `nth` and `contains` against a bitset, with the word form parsed back.
27
28## Licence
29
30MIT. See the repository's LICENSE.