NaturalNumberSet.elements

Returns a range of the elements in this set. The elements are ordered ascending.

struct NaturalNumberSet
@property
elements
const pure nothrow
(
)

Examples

1 import std.algorithm : equal;
2 import std.range : iota;
3 
4 NaturalNumberSet set;
5 auto someNumbers = iota(set.partSize).filter!"a % 3 == 0";
6 
7 foreach (i; someNumbers)
8 {
9     set.add(i);
10 }
11 
12 assert(equal(someNumbers, set.elements));

The set may be modified while iterating:

1 import std.algorithm : equal;
2 import std.range : iota;
3 
4 enum numElements = 64;
5 auto set = NaturalNumberSet(numElements, Yes.addAll);
6 
7 foreach (i; set.elements)
8 {
9     if (i % 10 == 0)
10         set.remove(i + 1);
11 }
12 
13 auto expectedNumbers = iota(numElements).filter!"a == 0 || !((a - 1) % 10 == 0)";
14 assert(equal(expectedNumbers, set.elements));

Meta