24 #include "headcpp.hpp"
25 #include "dim_array.hpp"
38 class Index :
public Memory_mapped {
99 bool inc (
int increm,
int var=0) {
101 if((var >=0) && (var<=ndimm1)) {
102 coord[var] += increm ;
104 for (
int i=var ; i<ndimm1 && division.quot>0; i++) {
106 coord[i] = division.rem ;
107 coord[i+1] += division.quot ;
122 if(i>=(ndimm1+1)) {
return false;}
135 bool res = ((var >=0) && (var<
get_ndim())) ? true : false ;
137 coord[var] += increm ;
138 for (
int i=var ; i<
get_ndim()-1 ; i++) {
140 coord[i] = division.rem ;
141 coord[i+1] += division.quot ;
158 for (
int i=0 ; i<
get_ndim() && res; i++)
163 template <
class>
friend class Array ;
Template class for arrays.
Class for storing the dimensions of an array.
int get_ndim() const
Returns the number of dimensions.
void swap(Dim_array &so)
Sylvain's stuff.
Class that gives the position inside a multi-dimensional Array.
int operator()(int i) const
Read/write of the position in a given dimension.
void swap(Index &so)
Sylvain's stuff.
Memory_mapped_array< int > Data_type
Type of data.
Dim_array sizes
Sizes of the associated Array.
int & set(int i)
Read/write of the position in a given dimension.
void set_start()
Sets the position to zero in all dimensions.
bool inc()
Increment on the first dimension.
bool inc_vanilla(int increm, int var)
General increment.
void operator=(const Index &so)
Assignment operator.
friend ostream & operator<<(ostream &, const Index &)
Operator<<.
bool inc(int increm, int var=0)
Increments the position of the Index.
Data_type coord
Value of each index.
Dim_array const & get_sizes() const
Returns all the dimensions.
int get_ndim() const
Returns the number of dimensions.
bool inc1(int var)
Increment on one dimension.
Index(const Dim_array &dim)
Standard constructor.
bool operator==(const Index &xx) const
Comparison operator.