set - multiple declarations
Function set
Constructor of a Set
on an implicitly derived base type with a given
sequence of intervals.
auto set(T)();
Function set
Constructor of the empty set.
Example
auto s1 = set(interval('a'), interval('e', 'g'));
assert('f' in s1);
auto s2 = set(interval(6), interval(10, 14));
assert(11 in s2);
auto s3 = set(interval(8, 12));
auto s4 = s2 - s3;
assert(11 !in s4);
assert(6 in s4);
assert(13 in s4);
auto s5 = set();
assert(s5 .card == 0);
Example
assert(4 in set(interval(0, 10)));
assert(4 !in set(interval(-3, 3)));
assert(-4 !in set(interval(-3, 3)));
enum Count {One, Two, Three, Four, Five, Six, Seven, Eight, Nine, Ten}
auto i1 = interval(Count .Three, Count .Six);
auto i2 = interval(Count .Eight, Count .Ten);
auto s1 = set(i1, i2);
assert(s1 .card == 7);
assert(Count .Nine in s1);
assert(Count .Seven !in s1);
s1 -= set(i2);
assert(s1 .card == 4);
assert(Count .Four in s1);
assert(Count .Nine !in s1);
Function set
Constructor of Set
s on an implicitly derived base type. It cannot support
the range-like notation for Interval
s like SetFactory
does, but offers
a 2-element array notation for intervals.
auto auto set(Args...)
(
Args args
)
if (compatibleIntervals!Args);
Example
int i = 5;
auto s1 = set(1);
auto s2 = set(1, [1,2], i);
assert(2 in s2);
enum Count {One, Two, Three, Four, Five}
auto s3 = set([Count .Three, Count .Five]);
s3 += set(Count .One);
assert(Count .Four in s3);
assert(Count .One in s3);
assert(Count .Two !in s3);