int-interval
A zero-allocation, half-open interval library for primitive integers.
- Half-open intervals
[start, end) - Branch-light, allocation-free,
const fnfriendly - Close to
std::ops::Rangeperformance
Supported types:
U8CO/I8CO, U16CO/I16CO, U32CO/I32CO, U64CO/I64CO, U128CO/I128CO, UsizeCO/IsizeCO
Interval Model
[start, end)withstart < endlen = end - start- Empty intervals are not representable
U8COtry_new =
Core API
Construction:
let x = U8COtry_new.unwrap;
let y = U8COnew_unchecked; // unchecked
Accessors:
x.start
x.end_excl
x.len
x.contains
x.iter
Predicates:
x.intersects
x.is_adjacent
x.is_contiguous_with
Interval Algebra
- Intersection
[A ∩ B]→Option<T> - Convex Hull →
T - Between →
Option<T> - Union →
OneTwo<T> - Difference →
ZeroOneTwo<T> - Symmetric Difference →
ZeroOneTwo<T>
- Fully stack-based, no heap allocation
Minkowski Arithmetic (New)
- Interval-to-interval:
add,sub,mul,div - Interval-to-scalar:
add_n,sub_n,mul_n,div_n - Checked operations, overflow-safe
- Supports negative numbers (
i8/signed types) - Fully
const fncompatible, preserves[start,end)semantics
let a = I8COtry_new.unwrap;
let b = I8COtry_new.unwrap;
let res = a.minkowski_mul.unwrap; // [-2,3)
Features
- Fast primitive interval algebra
- Predictable, allocation-free behavior
- Suitable for embedded or constrained environments
- Ideal for:
- Geometry / raster operations
- Compiler span analysis
- Scheduling ranges
- DNA / sequence slicing
- Numeric algorithms
Not designed for large interval sets or tree-based queries.
License
MIT