2#ifndef SORTEDARRAY_H_INCLUDED
3#define SORTEDARRAY_H_INCLUDED
33 template <
typename...
Args>
49 virtual int add(
const T &
object)
override;
65 virtual int find(
const T &
object)
const override;
90 int index = findInsert(
object);
92 this->
insert(
object, index);
106 while (left < right) {
107 int center = (left + right) / 2;
111 }
else if (this->
gt(this->
array_data.at(center),
object)) {
134 while (left < right) {
135 int center = (left + right) / 2;
139 }
else if (this->
gt(this->
array_data.at(center),
object)) {
A wrapper for std::vector.
Definition array.hpp:72
virtual bool eq(const T &arg1, const T &arg2) const
Check if two objects are equal.
Definition array.hpp:108
void init(const T &arg1)
Helper function for single object initialization.
Definition array.hpp:81
std::vector< T > array_data
The data in the array.
Definition array.hpp:75
size_t size() const noexcept override
Get the size of the array.
Definition array.hpp:1000
array()
Default constructor.
Definition array.hpp:146
array & insert(const T &, int)
Insert an object into the array.
Definition array.hpp:899
virtual bool gt(const T &arg1, const T &arg2) const
Check if one object is greater than another.
Definition array.hpp:124
virtual bool lt(const T &arg1, const T &arg2) const
Check if one object is less than another.
Definition array.hpp:140
An extension of the core::array class which attempts to keep all data sorted.
Definition sortedArray.hpp:18
virtual void shuffle() noexcept override
Shuffle the elements of the array into a random order.
Definition sortedArray.hpp:82
sortedArray(const T &arg1, const Args &...args)
List-initialized constructor.
Definition sortedArray.hpp:34
virtual void reverse() noexcept override
Reverse the order of all elements in the array.
Definition sortedArray.hpp:85
virtual int find(const T &object) const override
Check if a given object is in the array.
Definition sortedArray.hpp:98
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.
Definition sortedArray.hpp:126
sortedArray()
Default constructor.
Definition sortedArray.hpp:21
virtual int add(const T &object) override
Add an object to the array.
Definition sortedArray.hpp:89