SortedList

Implements a sorted list of type T. The container ensures that all of it's elements are ordered after any insertion. Has some optimization to stop searching after a given value has passed. cmp can set both the direction of the array, and what parameters should be tested. If allowDuplicates set false, the collection will act like a sorted set over an array, and won't allow any insertion of preexisting values.

Constructors

this
this(E[] _array)

Constructs a sorted list out from an array.

this
this(Range src)

Constructs a sorted list out from a range.

Members

Aliases

opDollar
alias opDollar = length
Undocumented in source.

Functions

has
bool has(E a)

Returns whether the set has the given element.

hasRange
size_t hasRange(R range)

Returns the amount of elements found in the set.

moveAt
E moveAt(size_t n)

Moves to the n-th position and returns the element of that position.

moveFront
E moveFront()

Returns the element at begin and increments the position by one.

opBinary
SortedList!(E, cmp, allowDuplicates, equal) opBinary(R rhs)

Set operators. Enables math operations on sets, like unions and intersections. Could work on ranges in general as long as they implement some basic functions, like iteration.

opBinaryRight
auto opBinaryRight(E key)
Undocumented in source. Be warned that the author may not have intended to support it.
opIndex
E opIndex(size_t n)

Returns the n-th element.

opOpAssign
SortedList!(E, cmp, allowDuplicates, equal) opOpAssign(E value)

Set operators.

opOpAssign
SortedList!(E, cmp, allowDuplicates, equal) opOpAssign(R range)

Set operators.

opSlice
SortedList!(E, cmp, allowDuplicates, equal) opSlice(size_t i0, size_t i1)

Returns a slice from the list.

popBack
void popBack()

Decrements the back iteration position by one

popFront
void popFront()

Increments the front iteration position by one

put
E put(E a)

Adds a new element while keeping the order intact.

remove
E remove(size_t n)

Removes the n-th element while keeping the order intact. Returns the removed element.

removeByElem
E removeByElem(E a)

Removes the element which is equal with the given one if the template is set to not allow duplicates. Returns the removed element, or E.init if not found.

sliceByElem
SortedList!(E, cmp, allowDuplicates, equal) sliceByElem(E from, E to)

Returns a slice from the list, but the slicing is done by element. * Search is done in a way that if either cmp or equals is true to an element, its position will be chosen * for the slice.

toString
string toString()
Undocumented in source. Be warned that the author may not have intended to support it.
which
size_t which(E a)

Returns the index of the given element, or throws an ElementNotFoundException if not found.

Properties

arrayOf
E[] arrayOf [@property getter]

Returns a copy of the underlying array.

back
E back [@property getter]

Returns the element at the back.

empty
bool empty [@property getter]

Returns true when the end of the list have been reached.

front
E front [@property getter]

Returns the element at the front.

length
size_t length [@property getter]

Returns the length of the list.

reserve
size_t reserve [@property setter]

Sets the reserve of the underlying array and returns the current reserve.

save
auto save [@property getter]

Returns a copy of this struct.

Meta