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. Important: The elements stored within this container must have opCmp override with attributes @safe, nothrow, pure.

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

Functions

arrayOf
E[] arrayOf()

Returns a copy of the underlying array.

back
E back()

Returns the element at the back.

empty
bool empty()

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

front
E front()

Returns the element at the front.

has
bool has(E a)

Returns whether the set has the given element.

length
size_t length()

Returns the length of the list.

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.

opIndex
E opIndex(size_t n)

Returns the n-th element.

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
void 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.

reserve
size_t reserve(size_t amount)

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

save
auto save()

Returns a copy of this struct.

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.

which
size_t which(E a)

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

Meta