make set for [0, 1, ..., n-1]
return range that contain less than x
return minimum element that isn't less than x
return maximum element that isn't greater than x
return range that contain greater than x
bidirectional range
1 import std.algorithm : equal, map; 2 import std.range : iota; 3 auto fs = FastSet(10); 4 fs.insert(1); 5 fs.insert(5); 6 fs.insert(6); 7 fs.remove(5); 8 fs.insert(4); 9 // [1, 4, 6] 10 assert(1 in fs); 11 assert(2 !in fs); 12 assert(5 !in fs); 13 assert(6 in fs); 14 assert(equal([1, 4, 6], fs[])); 15 assert(equal( 16 iota(8).map!(i => fs.next(i)), 17 [1, 1, 4, 4, 4, 6, 6, 10] 18 )); 19 assert(equal( 20 iota(8).map!(i => fs.prev(i)), 21 [-1, 1, 1, 1, 4, 4, 6, 6] 22 )); 23 assert(equal([1], fs.lowerBound(4))); 24 assert(equal([1, 4], fs.lowerBound(5))); 25 assert(equal([1, 4, 6], fs.upperBound(0))); 26 assert(equal([4, 6], fs.upperBound(1)));
almost same boolint, except key range is stricted