StackSet

A hash set that allocates its memory on RegionAllocator. Good for building a temporary set that will not escape the current scope.

Constructors

this
this(size_t nElem, RegionAllocator alloc)

Due to the nature of RegionAllocator, you must specify on object creation * the approximate number of elements your set will have. Too large a * number will waste space and incur poor cache performance. Too low a * number will make this struct perform like a linked list. Generally, * if you're building a set from some other range, some fraction of the * size of that range is a good guess.

Members

Functions

elems
auto elems()

Returns a forward range of the elements of this struct. The range's * lifetime must not exceed the lifetime of this object.

insert
void insert(K key)
opIn_r
bool opIn_r(K key)
remove
void remove(K key)

Properties

length
size_t length [@property getter]

Examples

1 auto alloc = newRegionAllocator();
2 auto ss = StackSet!(uint)(5, alloc);
3 foreach(i; 0..5) {
4    ss.insert(i);
5 }
6 assert(3 in ss);

Meta