45 #include <initializer_list> 70 std::vector< int > :: iterator
begin() {
return this->values.begin(); }
71 std::vector< int > :: iterator
end() {
return this->values.end(); }
72 std::vector< int > :: const_iterator
begin()
const {
return this->values.begin(); }
73 std::vector< int > :: const_iterator
end()
const {
return this->values.end(); }
83 inline IntArray(std :: initializer_list< int >list) : values(list) { }
90 IntArray &operator = (
IntArray &&src) { values = std::move(src.values);
return *
this; }
92 inline IntArray &operator = (std :: initializer_list< int >list) { values = list;
return *
this; }
103 inline int &
at(
int i) {
return values [ i - 1 ]; }
114 inline int at(
int i)
const {
return values [ i - 1 ]; }
123 int &operator() (
int i);
125 inline int &operator() (
int i) {
return values [ i ]; }
134 const int &operator() (
int i)
const;
136 inline const int &operator() (
int i)
const {
return values [ i ]; }
140 int &operator[] (
int i );
142 inline int &operator[] (
int i ) {
return values [ i ]; }
146 const int &operator[] (
int i )
const;
148 inline const int &operator[] (
int i )
const {
return values [ i ]; }
158 void checkBounds(
int i)
const;
167 void resizeWithValues(
int n,
int allocChunk = 0);
177 void clear() { this->values.clear(); }
182 void preallocate(
int futureSize);
187 void enumerate(
int maxVal);
194 void followedBy(
const IntArray &b,
int allocChunk = 0);
201 void followedBy(
int b,
int allocChunk = 0);
203 int giveSize()
const {
return (
int)values.size(); }
208 bool isEmpty()
const {
return values.size() == 0; }
213 bool containsOnlyZeroes()
const;
218 int findSorted(
int value)
const;
233 void findNonzeros(
const IntArray &logical);
246 void insertSorted(
int value,
int allocChunk = 0);
255 bool insertSortedOnce(
int value,
int allocChunk = 0);
262 void eraseSorted(
int value);
272 int findCommonValuesSorted(
const IntArray &iarray,
IntArray &common,
int allocChunk = 0)
const;
279 int findFirstIndexOf(
int value)
const;
283 bool contains(
int value)
const {
return ( findFirstIndexOf(value) > 0 ); }
289 void insertOnce(
int p);
311 void printYourself()
const;
320 void printYourself(
const std::string name)
const;
327 void printYourselfToFile(
const std::string filename,
const bool showDimensions=
true)
const;
330 bool isFinite()
const;
357 void __setitem__(
int i,
int val) { this->at(i + 1) = val; }
358 int __getitem__(
int i) {
return this->at(i + 1); }
359 void beCopyOf(
const IntArray &src) { this->operator = ( src ); }
364 template<
class operation >
int 366 int i = l - 1, j = r;
371 while ( ( op(arry.
at(++i), v) ) < 0 ) {
375 while ( ( op( v, arry.
at(--j) ) ) < 0 ) {
386 arry.
at(i) = arry.
at(j);
391 arry.
at(i) = arry.
at(r);
bool contains(int value) const
std::vector< int > values
Stored values.
The purpose of DataStream abstract class is to allow to store/restore context to different streams...
bool isEmpty() const
Checks if receiver is empty (i.e., zero sized).
int at(int i) const
Coefficient access function.
IntArray(std::initializer_list< int >list)
Initializer list constructor.
std::vector< int >::iterator end()
std::vector< int >::const_iterator end() const
const int * givePointer() const
Breaks encapsulation.
IntArray(IntArray &&src)
Move constructor. Creates the array from another array.
Class implementing an array of integers.
int & at(int i)
Coefficient access function.
void sort(IntArray &arry, operation op)
Sorts the receiver using quicksort algorithm.
std::ostream & operator<<(std::ostream &out, const Dictionary &r)
void clear()
Clears the array (zero size).
void quickSort(IntArray &arry, int l, int r, operation op)
int quickSortPartition(IntArray &arry, int l, int r, operation op)
IntArray(const IntArray &src)
Copy constructor. Creates the array from another array.
IntArray(int n=0)
Constructor for sized array. Data is zeroed.
std::vector< int >::iterator begin()
std::vector< int >::const_iterator begin() const
the oofem namespace is to define a context or scope in which all oofem names are defined.
bool containsSorted(int value) const
Checks if sorted receiver contains a given value.