FastSet

almost same boolint, except key range is stricted

Constructors

this
this(size_t n)

make set for [0, 1, ..., n-1]

Members

Functions

empty
bool empty()
Undocumented in source. Be warned that the author may not have intended to support it.
insert
void insert(size_t x)
Undocumented in source. Be warned that the author may not have intended to support it.
length
size_t length()
Undocumented in source. Be warned that the author may not have intended to support it.
lowerBound
Range lowerBound(ptrdiff_t x)

return range that contain less than x

next
ptrdiff_t next(ptrdiff_t x)

return minimum element that isn't less than x

opBinaryRight
bool opBinaryRight(size_t i)
Undocumented in source. Be warned that the author may not have intended to support it.
opIndex
Range opIndex()
prev
ptrdiff_t prev(ptrdiff_t x)

return maximum element that isn't greater than x

remove
void remove(size_t x)
Undocumented in source. Be warned that the author may not have intended to support it.
upperBound
Range upperBound(ptrdiff_t x)

return range that contain greater than x

Structs

Range
struct Range

bidirectional range

Variables

seg
ulong[][] seg;
Undocumented in source.

Examples

import std.algorithm : equal, map;
import std.range : iota;
auto fs = FastSet(10);
fs.insert(1);
fs.insert(5);
fs.insert(6);
fs.remove(5);
fs.insert(4);
// [1, 4, 6]
assert(1 in fs);
assert(2 !in fs);
assert(5 !in fs);
assert(6 in fs);
assert(equal([1, 4, 6], fs[]));
assert(equal(
    iota(8).map!(i => fs.next(i)),
    [1, 1, 4, 4, 4, 6, 6, 10]
));
assert(equal(
    iota(8).map!(i => fs.prev(i)),
    [-1, 1, 1, 1, 4, 4, 6, 6]
));
assert(equal([1], fs.lowerBound(4)));
assert(equal([1, 4], fs.lowerBound(5)));
assert(equal([1, 4, 6], fs.upperBound(0)));
assert(equal([4, 6], fs.upperBound(1)));

Meta