An extension of the core::sortedArray class, specialized for pointers. More...
#include <sortedRefArray.hpp>
Public Member Functions | |
sortedRefArray () | |
Default constructor. | |
template<typename... Args> | |
sortedRefArray (const T &arg1, const Args &...args) | |
List-initialized constructor. | |
virtual bool | operator() (const T &arg1, const T &arg2) const override |
Callable operator. | |
![]() | |
sortedArray () | |
Default constructor. | |
template<typename... Args> | |
sortedArray (const T &arg1, const Args &...args) | |
List-initialized constructor. | |
virtual int | add (const T &object) override |
Add an object to the array. | |
virtual int | find (const T &object) const override |
Check if a given object is in the array. | |
virtual int | findInsert (const T &object, bool allowDuplicates=true) const |
Find an index where the given object can be inserted while keeping the array sorted. | |
virtual void | shuffle () noexcept override |
Shuffle the elements of the array into a random order. | |
virtual void | reverse () noexcept override |
Reverse the order of all elements in the array. | |
![]() | |
array () | |
Default constructor. | |
array (const array &other) | |
Copy constructor. | |
array (const std::vector< T > &other) | |
Copy from std::vector. | |
template<typename... Args> | |
array (const T &arg1, const Args &...args) | |
List-initialized constructor. | |
array (const std::initializer_list< T > &other) | |
Construct from a generic initializer list. | |
virtual | ~array () |
Destructor. | |
void | clear () |
Clear the data in the array. | |
void | increase (int newSize) noexcept |
Increase the space allocated for this array. | |
void | add (const array &other) noexcept |
Add another array to this array. | |
int | push (const T &object) noexcept |
Add an object to the array. | |
void | push (const array &other) noexcept |
Add another array to this array. | |
T | pop () |
Remove the last element from this array. | |
array & | insert (const T &, int) |
Insert an object into the array. | |
void | append (const T &) |
Append an object to the end of the array. | |
array & | remove (int) |
Remove an object from the array. | |
array & | remove (int, int) |
Remove all elements in a subset of the array. | |
array & | replace (int, int, const T &) |
Replace all objects in the given range with an object. | |
array & | replace (int, int, const array< T > &) |
Replace all objects in the given range with an array of objects. | |
array | subset (int index, int count) const |
Get a contiguous subset of the elements in the array. | |
size_t | size () const noexcept override |
Get the size of the array. | |
int | length () const noexcept override |
Get the length of the array. | |
T & | at (int) |
Function to get the object at the given index. | |
const T & | at (int) const override |
Const function to get the object at the given index. | |
const T & | operator[] (int index) const override |
Function to get the object at the given index. | |
T & | operator[] (int index) |
Function to get the object at the given index. | |
bool | contains (const T &object) const noexcept |
Check if a given object is in the array. | |
void | sort () noexcept |
Sort the array based on default comparison operator. | |
void | sort (std::function< bool(const T &, const T &)> lambda) noexcept |
Sort the array based on an arbitrary function. | |
array | sorted () const noexcept |
Sort the array based on default comparison operator. | |
array | sorted (std::function< bool(const T &, const T &)> lambda) const noexcept |
Sort the array based on an arbitrary function. | |
array | shuffled () const noexcept |
Shuffle the elements of the array into a random order. | |
array | reversed () const noexcept |
Reverse the order of all elements in the array. | |
array & | operator= (const array &other) |
Array assignment operator. | |
array & | operator= (const std::initializer_list< T > &other) |
Initializer list assignment operator. | |
bool | operator== (const array &other) const |
Check whether two arrays' contents are the same. | |
bool | operator> (const array &other) const |
Array greater-than operator. | |
bool | operator< (const array &other) const |
Array less-than operator. | |
bool | operator>= (const array &other) const |
Array greater-than-or-equal operator. | |
bool | operator<= (const array &other) const |
Array less-than-or-equal operator. | |
bool | isValid (int index) const |
Check if an index is within the bounds of the array. | |
array & | swap (int index1, int index2) |
Swap two elements in an array. | |
template<typename U > | |
array< U > | map (std::function< U(const T &)> lambda) const |
Applies a transformation function to each element of the array and returns a new array with the results. | |
array | filter (std::function< bool(const T &)> lambda) const |
Filters the array based on a predicate and returns a new array containing the elements that satisfy the predicate. | |
T | reduce (const T &defaultValue, std::function< T(const T &, const T &)> lambda) const |
Reduces the array to a single value by applying a binary operation cumulatively to the elements. | |
T | randomElement () const |
Get a random element from the array. | |
array | randomElements (int count) const noexcept |
Get N random elements from the array. | |
T * | begin () const noexcept override |
Get pointer to the beginning of the array. | |
T * | end () const noexcept override |
Get pointer to the end of the array. | |
void | save (cereal::JSONOutputArchive &ar) const |
JSON specialization of serialization output. | |
void | save (cereal::XMLOutputArchive &ar) const |
XML specialization of serialization output. | |
template<typename archive > | |
void | save (archive &ar) const |
Binary specialization of serialization output. | |
void | load (cereal::JSONInputArchive &ar) |
JSON specialization of serialization input. | |
void | load (cereal::XMLInputArchive &ar) |
XML specialization of serialization input. | |
template<class archive > | |
void | load (archive &ar) |
Binary specialization of serialization input. | |
![]() | |
virtual | ~sizable () noexcept |
Virtual destructor. | |
![]() | |
virtual | ~indexable () noexcept |
Virtual destructor. | |
![]() | |
virtual | ~iterable () noexcept |
Virtual destructor. | |
Protected Member Functions | |
virtual bool | eq (const T &arg1, const T &arg2) const override |
Check if two objects are equal. | |
virtual bool | gt (const T &arg1, const T &arg2) const override |
Check if one object is greater than another. | |
virtual bool | lt (const T &arg1, const T &arg2) const override |
Check if one object is less than another. | |
![]() | |
void | init (const T &arg1) |
Helper function for single object initialization. | |
template<typename... Args> | |
void | init (const T &arg1, const Args &...args) |
Helper function for brace-enclosed list initialization. | |
Additional Inherited Members | |
![]() | |
std::vector< T > | array_data |
The data in the array. | |
An extension of the core::sortedArray class, specialized for pointers.
Unlike with the sortedArray, elements are assumed to be pointers and are sorted with this in mind.
|
inline |
List-initialized constructor.
Constructs the array with an arbitrary number of elements already contained.
arg1 | initializing data. |
args | cont. initializing data. |
|
inlineoverrideprotectedvirtual |
Check if two objects are equal.
This member function allows object comparison to be different for different array types (e.g. reference arrays will need to sort by value after dereference).
arg1 | First object to compare. |
arg2 | Second object to compare. |
Reimplemented from z::core::array< T >.
|
inlineoverrideprotectedvirtual |
Check if one object is greater than another.
This member function allows object comparison to be different for different array types (e.g. reference arrays will need to sort by value after dereference).
arg1 | First object to compare. |
arg2 | Second object to compare. |
Reimplemented from z::core::array< T >.
|
inlineoverrideprotectedvirtual |
Check if one object is less than another.
This member function allows object comparison to be different for different array types (e.g. reference arrays will need to sort by value after dereference).
arg1 | First object to compare. |
arg2 | Second object to compare. |
Reimplemented from z::core::array< T >.
|
inlineoverridevirtual |
Callable operator.
This is used to compare array elements for sorting.
arg1 | The first element to compare. |
arg2 | The second element to compare. |
Reimplemented from z::core::array< T >.