OrderedSet

An ordered set. Internally a red-black-tree. Value-semantics.

Constructors

this
this(Stuff data)

constructor that gets content from arbitrary range

Postblit

this(this)
this(this)

post-blit that does a full copy

Members

Aliases

ConstRange
alias ConstRange = .Range!(const(V), const(Node))
Undocumented in source.
ImmutableRange
alias ImmutableRange = .Range!(immutable(V), immutable(Node))
Undocumented in source.
Node
alias Node = .Node!V
Undocumented in source.
Range
alias Range = .Range!(V, Node)

Range types for iterating over elements of the set. Implements std.range.isBidirectionalRange

less
alias less = binaryFun!_less
Undocumented in source.
opSlice
alias opSlice = range

convenience alias

Functions

add
bool add(V value)

Add an element to the set.

add
size_t add(Stuff data)

Add elements from a range to the set.

empty
bool empty()
find
inout(V)* find(const(T) value)

find an element, null if not found

findApprox
inout(Node)* findApprox(const(T) value)

private helper, null if set is empty

findNode
inout(Node)* findNode(const(T) value)

private helper, null if not found

length
size_t length()
opIn_r
bool opIn_r(const(T) value)
range
Range range()
ConstRange range()
ImmutableRange range()
range
Range range(const(T) left, const(T) right)
remove
bool remove(const(T) v)

Remove an element from the set.

remove
size_t remove(Stuff data)

Remove elements from a range to the set.

Examples

basic usage

OrderedSet!int a;
assert(a.add(1) == true);
assert(a.add([4,2,3,1,5]) == 4);
assert(a.remove(7) == false);
assert(a.remove([1,1,8,2]) == 2);
assert(a.remove(3) == true);
assert(equal(a[], [4,5]));

Meta