46#include <initializer_list>
71 std::vector< int > :: iterator
begin() {
return this->values.begin(); }
72 std::vector< int > :: iterator
end() {
return this->values.end(); }
73 std::vector< int > :: const_iterator
begin()
const {
return this->values.begin(); }
74 std::vector< int > :: const_iterator
end()
const {
return this->values.end(); }
77 constexpr static int Dim = 1;
96 inline IntArray &operator = (std :: initializer_list< int >list) {
values = list;
return *
this; }
104 inline int &
at(std::size_t i)
117 inline int at(std::size_t i)
const
130 inline int &operator() (std::size_t i) {
return this->
operator[](i); }
131 inline int &operator[] (std::size_t i)
144 inline const int &operator() (std::size_t i)
const {
return this->
operator[](i); }
145 inline const int &operator[] (std::size_t i)
const
163 }
else if ( i >
values.size()) {
175 void resizeWithValues(
int n,
int allocChunk = 0);
185 void clear() { this->values.clear(); }
190 void preallocate(
int futureSize);
195 void enumerate(
int maxVal);
202 void followedBy(
const IntArray &b,
int allocChunk = 0);
209 void followedBy(
int b,
int allocChunk = 0);
222 bool containsOnlyZeroes()
const;
227 int findSorted(
int value)
const;
242 void findNonzeros(
const IntArray &logical);
255 void insertSorted(
int value,
int allocChunk = 0);
264 bool insertSortedOnce(
int value,
int allocChunk = 0);
271 void eraseSorted(
int value);
281 int findCommonValuesSorted(
const IntArray &iarray,
IntArray &common,
int allocChunk = 0)
const;
288 int findFirstIndexOf(
int value)
const;
298 void insertOnce(
int p);
320 void printYourself()
const;
329 void printYourself(
const std::string name)
const;
336 void printYourselfToFile(
const std::string filename,
const bool showDimensions=
true)
const;
339 bool isAllFinite()
const;
363 friend std :: ostream &operator << ( std :: ostream & out,
const IntArray & x );
365 std::vector<int>
minusOne()
const { std::vector<int> ret(
values.size());
for(
size_t i=0; i<
values.size(); i++) ret[i]=
values[i]-1;
return ret; }
369template<
class operation >
int
372 int i = l - 1, j = r;
377 while ( ( op(arry.
at(++i), v) ) < 0 ) {
381 while ( ( op( v, arry.
at(--j) ) ) < 0 ) {
392 arry.
at(i) = arry.
at(j);
397 arry.
at(i) = arry.
at(r);
std::vector< int > minusOne() const
void checkBounds(std::size_t i) const
IntArray(IntArray &&src) noexcept
Move constructor. Creates the array from another array.
std::vector< int >::iterator end()
std::vector< int >::const_iterator end() const
bool containsSorted(int value) const
IntArray(int n=0)
Constructor for sized array. Data is zeroed.
int & operator[](std::size_t i)
IntArray(std ::initializer_list< int >list)
Initializer list constructor.
int findSorted(int value) const
bool contains(int value) const
std::vector< int >::iterator begin()
const int * givePointer() const
std::vector< int > values
Stored values.
std::vector< int >::const_iterator begin() const
int findFirstIndexOf(int value) const
IntArray(const IntArray &src)
Copy constructor. Creates the array from another array.
int at(std::size_t i) const
void quickSort(IntArray &arry, int l, int r, operation op)
int quickSortPartition(IntArray &arry, int l, int r, operation op)
FloatMatrixF< N, M > zero()
Constructs a zero matrix (this is the default behavior when constructing a matrix,...
void sort(IntArray &arry, operation op)