Clear entirely the HashRangeMap
Tells whether the HashRangeMap is empty.
Check if the hash ranges in the map have any gaps between them or boundaries of hash_t type.
Check if there is any overlap between the hash ranges in the map
Check if the hash ranges in the map have neither gaps nor overlaps and cover the whole space of hash_t values.
foreach iterator over ranges and corresponding values. This iterator prevents true ref iteration over the keys of the internal map by passing a copy of the range to the iteration delegate.
'in' operator: looks up the value mapped by a given HashRange
Looks up the mapping for non-empty range or adds one if not found
Removes the mapping for the specified range
type to store in values of map
test instantiation with int
HashRangeMap!(int) ihrm; testPut([1, 2, 3, 4, 5, 6, 7, 8][]); testRemove([1, 2, 3, 4, 5][]); testOpInR([1, 2, 3, 4, 5][]); testOpApply([1, 2, 3, 4, 5][]);
test instantiation with ulong
HashRangeMap!(ulong) uhrm; testPut([1UL, 2UL, 3UL, 4UL, 5UL, 6UL, 7UL, 8UL]); testRemove([1UL, 2UL, 3UL, 4UL, 5UL]); testOpInR([1UL, 2UL, 3UL, 4UL, 5UL]); testOpApply([1UL, 2UL, 3UL, 4UL, 5UL]);
test instantiation with float
HashRangeMap!(float) fhrm; testPut([1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f]); testRemove([1.0f, 2.0f, 3.0f, 4.0f, 5.0f]); testOpInR([1.0f, 2.0f, 3.0f, 4.0f, 5.0f]); testOpApply([1.0f, 2.0f, 3.0f, 4.0f, 5.0f]);
test instantiation with pointer
int v1, v2, v3, v4, v5, v6, v7, v8; HashRangeMap!(int*) phrm; testPut([&v1, &v2, &v3, &v4, &v5, &v6, &v7, &v8]); testRemove([&v1, &v2, &v3, &v4, &v5]); testOpInR([&v1, &v2, &v3, &v4, &v5]); testOpApply([&v1, &v2, &v3, &v4, &v5]);
test instantiation with arbitrary struct that supports opEquals
static struct S { import ocean.util.Convert; int x; static S opCall(int x) { S s; s.x = x; return s; } equals_t opEquals(S other) { return this.x == other.x; } istring toString() { return "S(" ~ to!(istring)(this.x) ~ ")"; } } HashRangeMap!(S) shrm; testPut([S(1), S(2), S(3), S(4), S(5), S(6), S(7), S(8)]); testRemove([S(1), S(2), S(3), S(4), S(5)]); testOpInR([S(1), S(2), S(3), S(4), S(5)]); testOpApply([S(1), S(2), S(3), S(4), S(5)]);
test instantiation with array
HashRangeMap!(int[]) arhrm; testPut([[1], [2, 1], [3, 1, 2], [4], [5], [6], [7], [8]]); testRemove([[1], [2, 1], [3, 1, 2], [4], [5]]); testOpInR([[1], [2, 1], [3, 1, 2], [4], [5]]); testOpApply([[1], [2, 1], [3, 1, 2], [4], [5]]);
Provides a mapping from HashRange to the specified type
Note: Unittests for put, remove and opopBinaryRight!"in" are not placed directly in this struct as they depend on the assumption that type Value (the template argument) has a meaningful equality operator (opEquals). Instead, private external functions exist to test these methods. These are then called on HashRangeMaps with various different types of Value, in a unittest block outside the struct.