Base Framework
|
#include <base/collection/Array.h>
Inherits Collection.
Classes | |
class | Element |
Public Types | |
typedef TYPE | Value |
typedef Allocator< TYPE >::Iterator | Iterator |
typedef Allocator< TYPE >::ReadIterator | ReadIterator |
typedef Allocator< TYPE >::Enumerator | Enumerator |
typedef Allocator< TYPE >::ReadEnumerator | ReadEnumerator |
Public Member Functions | |
void | setSize (MemorySize size) |
void | setSize (MemorySize size, const TYPE &value) |
void | ensureCapacity (MemorySize capacity) |
MemorySize | getCapacity () const noexcept |
Value * | getElements () |
const Value * | getElements () const noexcept |
Array () | |
Array (MemorySize size) | |
Array (MemorySize size, const Value &value) | |
Array (std::initializer_list< Value > l) | |
Array (const Array ©) noexcept | |
Array (Array &&move) noexcept | |
Array & | operator= (const Array ©) noexcept |
Array & | operator= (Array &&move) noexcept |
MemorySize | getSize () const noexcept |
bool | isEmpty () const noexcept |
TYPE * | getFirstReference () noexcept |
const TYPE * | getFirstReference () const noexcept |
TYPE & | getFirst () |
const TYPE & | getFirst () const |
TYPE & | getLast () |
const TYPE & | getLast () const |
Iterator | getBeginIterator () noexcept |
Iterator | getEndIterator () noexcept |
ReadIterator | getBeginReadIterator () const noexcept |
ReadIterator | getEndReadIterator () const noexcept |
ReadIterator | begin () const noexcept |
ReadIterator | end () const noexcept |
ReadIterator | cbegin () const noexcept |
ReadIterator | cend () const noexcept |
Iterator | begin () noexcept |
Iterator | end () noexcept |
operator RandomAccessIterable< Iterator > () noexcept | |
Enumerator | getEnumerator () noexcept |
ReadEnumerator | getReadEnumerator () const noexcept |
void | append (const Value &value) |
void | append (Value &&value) |
void | append (std::initializer_list< Value > l) |
void | prepend (const Value &value) |
void | prepend (Value &&value) |
void | prepend (std::initializer_list< Value > l) |
void | insert (MemorySize index, const Value &value) |
void | insert (MemorySize index, Value &&value) |
void | insert (const Iterator &it, const Value &value) |
void | insert (const Iterator &it, Value &&value) |
void | remove (MemorySize index) |
void | remove (const Iterator &it) |
void | remove (MemorySize _begin, MemorySize _end) |
void | remove (const Iterator &_begin, const Iterator &_end) |
void | removeAll () |
Array | slice (MemorySize _begin, MemorySize _end) const |
Array | slice (const Iterator &_begin, const Iterator &_end) const |
Value & | getAt (MemorySize index) |
const Value & | getAt (MemorySize index) const |
void | setAt (MemorySize index, const Value &value) |
void | setAt (MemorySize index, Value &&value) |
TYPE & | operator[] (MemorySize index) |
const Value & | operator[] (MemorySize index) const |
bool | operator== (const Array &compare) const |
bool | operator!= (const Array &compare) const |
bool | operator< (const Array &compare) const |
bool | operator>= (const Array &compare) const |
operator bool () const noexcept | |
void | shuffle () |
MemoryDiff | indexOf (const TYPE &value) const |
MemoryDiff | lastIndexOf (const TYPE &value) const |
const TYPE * | find (const TYPE &value) const |
void | sort () |
template<class PREDICATE > | |
void | sort (PREDICATE predicate) |
Array | head (MemorySize n) const |
Array | tail (MemorySize n) const |
Array & | operator<< (const TYPE &value) |
Array & | operator<< (TYPE &&value) |
Related Functions | |
(Note that these are not member functions.) | |
template<class TYPE > | |
FormatOutputStream & | operator<< (FormatOutputStream &stream, const Array< TYPE > &value) |
Array collection.
The Array collection is a container for an ordered sequence of elements which provides random access to the individual elements. Elements must have a default constructor.
Initializes an array with the specified size.
size | The size of the array. |
Initializes array with the specified number of elements.
size | The initial number of elements in the array. |
value | The value used to initialize the elements. |
Initializes array from initializer list.
Initializes array from other array.
Initializes array from other array.
Appends the value to this array.
value | The value to be appended. |
Append from initializer list.
Appends the value to this array.
value | The value to be appended. |
|
inlinenoexcept |
Returns the first element of the allocator as a non-modifying array.
Returns the first element of the allocator as a modifying array.
|
inlinenoexcept |
Returns the first element of the allocator as a non-modifying array.
|
inlinenoexcept |
Returns the end of the allocator as a non-modifying array.
|
inlinenoexcept |
Returns the end of the allocator as a non-modifying array.
Returns the end of the allocator as a modifying array.
|
inline |
Ensure capacity.
|
inline |
Returns reference to the item if found by the given value.
Returns the element at the specified index. Raises OutOfRange if the index is invalid.
index | The index of the element. |
Returns the element at the specified index. Raises OutOfRange if the index is invalid.
index | The index of the element. |
Returns the first element of the allocator as a modifying array.
|
inlinenoexcept |
Returns the first element of the allocator as a non-modifying array.
|
inlinenoexcept |
Returns the capacity.
Returns the elements of the array for modifying access.
Returns the elements of the array for non-modifying access.
Returns the end of the allocator as a modifying array.
|
inlinenoexcept |
Returns the end of the allocator as a non-modifying array.
|
inlinenoexcept |
Returns a modifying enumerator of the array.
|
inline |
Returns the first element.
|
inline |
Returns the first element.
|
inlinenoexcept |
Returns the pointer to the first item or nullptr if empty.
|
inlinenoexcept |
Returns the pointer to the first item or nullptr if empty.
|
inline |
Returns the last element.
|
inline |
Returns the last element.
|
inlinenoexcept |
Returns a non-modifying enumerator of the array.
|
inlinenoexcept |
Returns the number fo elements in the array.
Returns the first n items.
|
inline |
Returns the index of the first found value. Returns -1 if not found.
|
inline |
Inserts values at the given position.
Inserts values at the given position.
Inserts the value at the specified position. Raises OutOfRange if the specified index is invalid.
index | Specifies the insert position. |
value | The value to be inserted. |
Inserts the value at the specified position. Raises OutOfRange if the specified index is invalid.
index | Specifies the insert position. |
value | The value to be inserted. |
|
inlinenoexcept |
Returns true if the array is empty.
|
inline |
Returns the index of the last found value. Returns -1 if not found.
|
inlinenoexcept |
Returns true if not empty.
|
inlinenoexcept |
Returns random access iterators.
Returns true if not equal.
Returns true if less than.
Assignment of array to array.
Assignment of array to array.
Returns true if equal.
Returns true if greater than or equal.
|
inline |
Returns a reference to the element at the specified index. Raises OutOfRange if the index is invalid.
index | The index of the element. |
Returns the element at the specified index. Raises OutOfRange if the index is invalid.
index | The index of the element. |
Prepends the value to this array.
value | The value to be prepended. |
Prepends from initializer list.
Prepends the value to this array.
value | The value to be prepended. |
|
inline |
Removes the elements within the given positions.
Removes the element at the given position.
|
inline |
Removes the elements within the given positions.
|
inline |
Remove the element specified by the index. Raises OutOfRange if the index is invalid.
index | The index of the element to be removed. |
|
inline |
Removes all the elements from this array.
Sets the element at the specified index. Raises OutOfRange if the index is invalid.
index | The index of the element. |
value | The desired value. |
Sets the element at the specified index. Raises OutOfRange if the index is invalid.
index | The index of the element. |
value | The desired value. |
|
inline |
Sets the size of the array.
|
inline |
Sets the size of the array by filling with the given value.
|
inline |
Shuffles the elements.
|
inline |
Returns a new Array for the given elements.
|
inline |
Returns a new Array for the given elements.
|
inline |
Sorts the array.
|
inline |
Sorts the array.
Returns the last n items.
|
related |
Writes a string representation of an array to a format stream.