Basic integer array class. More...
#include <itbl.h>
Public Member Functions | |
Itbl (int size0) | |
1D constructor. | |
Itbl (int size1, int size0) | |
2D constructor. | |
Itbl (int size2, int size1, int size0) | |
3D constructor This constructor sets the Itbl in the logical state ETATQCQ , so that it is ready for initialization via the method set(int, int, int ) . | |
Itbl (const Dim_tbl &) | |
Constructor from a Dim_tbl . | |
Itbl (FILE *) | |
Constructor from a file (see sauve(FILE* ) ). | |
Itbl (const Itbl &) | |
Copy constructor. | |
~Itbl () | |
Destructor. | |
void | operator= (const Itbl &) |
Assignment to another Itbl . | |
void | operator= (int) |
Assignment to a int . | |
void | set_etat_nondef () |
Sets the logical state to ETATNONDEF (undefined). | |
void | set_etat_zero () |
Sets the logical state to ETATZERO (zero). | |
void | set_etat_qcq () |
Sets the logical state to ETATQCQ (ordinary state). | |
void | annule_hard () |
Sets the Itbl to zero in a hard way. | |
int & | set (int i) |
Read/write of a particular element (index i ) (1D case). | |
int | operator() (int i) const |
Read-only of a particular element (index i ) (1D case). | |
int & | set (int j, int i) |
Read/write of a particular element (index (j,i) ) (2D case). | |
int | operator() (int j, int i) const |
Read-only of a particular element (index (j,i) ) (2D case). | |
int & | set (int k, int j, int i) |
Read/write of a particular element (index (k,j,i) ) (3D case). | |
int | operator() (int k, int j, int i) const |
Read-only of a particular element (index (k,j,i) ) (3D case). | |
int | get_etat () const |
Gives the logical state. | |
int | get_taille () const |
Gives the total size (ie dim.taille ). | |
int | get_ndim () const |
Gives the number of dimensions (ie dim.ndim ). | |
int | get_dim (int i) const |
Gives the i th dimension (ie {tt dim.dim[i] ). | |
void | sauve (FILE *) const |
Save in a file. | |
void | operator+= (const Itbl &) |
Addition of a Itbl to this . | |
void | operator+= (int) |
Addition of a int to this . | |
void | operator-= (const Itbl &) |
Subtraction of a Itbl to this . | |
void | operator-= (int) |
Subtraction of a int to this . | |
void | operator*= (const Itbl &) |
Multiplication of this by a Itbl . | |
void | operator*= (int) |
Multiplication of this by a int . | |
Public Attributes | |
Dim_tbl | dim |
Number of dimensions, size,... | |
int * | t |
The array of int 's. | |
Private Member Functions | |
void | del_t () |
Logical destructor: dellocates the memory occupied by the array t and sets the logical state to ETATNONDEF. | |
Private Attributes | |
int | etat |
logical state (ETATNONDEF , ETATQCQ or ETATZERO ). | |
Friends | |
ostream & | operator<< (ostream &, const Itbl &) |
Display. |
Basic integer array class.
This class is essentially an int
array class. The elements of the array are stored continuously using the C convention.
The general logical state of an initialized Itbl
is ETATQCQ
; it is the only state for which the memory allocation is performed for the int
array t
. The value zero is treated as a special logical state (ETATZERO
), without any memory allocation.
Contrary to a Tbl
, an Itbl
is initialy created in a logical state ETATQCQ
(i.e. ordinary state, with memory allocated for the array t
).
Arithmetic operations are provided with the usual meaning (see below).
A 1D Itbl can be of dimension 0 (size 0). Its logical state is then ETATZERO
(by convention).
()
Definition at line 118 of file itbl.h.
Itbl::Itbl | ( | int | size0 | ) | [explicit] |
1D constructor.
This constructor sets the Itbl
in the logical state ETATQCQ
, so that it is ready for initialization via the method set(int )
.
size0 | [input] Number of elements of the array t . Will be assigned to dim.dim [0] . The size 0 is allowed (the corresponding logical state will be then ETATZERO). |
Itbl::Itbl | ( | int | size1, | |
int | size0 | |||
) |
2D constructor.
This constructor sets the Itbl
in the logical state ETATQCQ
, so that it is ready for initialization via the method set(int, int )
.
size1 | [input] Defines the range [0, size1-1] of the outermost index in the storage of the array t . Will be assigned to dim.dim [1] . | |
size0 | [input] Defines the range [0, size0-1] of the innermost index in the storage of the array t . Will be assigned to dim.dim [0] . |
Definition at line 106 of file itbl.C.
References get_taille(), and t.
Itbl::Itbl | ( | int | size2, | |
int | size1, | |||
int | size0 | |||
) |
3D constructor This constructor sets the Itbl
in the logical state ETATQCQ
, so that it is ready for initialization via the method set(int, int, int )
.
size2 | [input] Defines the range [0, size2-1] of the outermost index in the storage of the array t . Will be assigned to dim.dim [2] . | |
size1 | [input] Defines the range [0, size1-1] of the intermediate index in the storage of the array t . Will be assigned to dim.dim [1] . | |
size0 | [input] Defines the range [0, size0-1] of the innermost index in the storage of the array t . Will be assigned to dim.dim [0] . |
Definition at line 112 of file itbl.C.
References get_taille(), and t.
Itbl::Itbl | ( | const Dim_tbl & | dt | ) | [explicit] |
Constructor from a Dim_tbl
.
This constructor sets the Itbl
in the logical state ETATQCQ
, so that it is ready for initialization via the method set
.
Definition at line 118 of file itbl.C.
References get_taille(), set_etat_zero(), and t.
Itbl::Itbl | ( | FILE * | fd | ) | [explicit] |
Constructor from a file (see sauve(FILE* )
).
Definition at line 145 of file itbl.C.
References etat, fread_be(), get_taille(), and t.
Itbl::Itbl | ( | const Itbl & | tc | ) |
void Itbl::annule_hard | ( | ) |
Sets the Itbl
to zero in a hard way.
1/ Sets the logical state to ETATQCQ
, i.e. to an ordinary state. 2/ Allocates the memory of the int
array t
, and fills it with zeros. NB: this function must be used for debugging purposes only. For other operations, the function set_etat_zero()
must be perferred.
Definition at line 268 of file itbl.C.
References etat, get_taille(), and t.
void Itbl::del_t | ( | ) | [private] |
int Itbl::get_dim | ( | int | i | ) | const [inline] |
Gives the i
th dimension (ie {tt dim.dim[i] ).
Definition at line 322 of file itbl.h.
References Dim_tbl::dim, dim, and Dim_tbl::ndim.
int Itbl::get_etat | ( | ) | const [inline] |
int Itbl::get_ndim | ( | ) | const [inline] |
Gives the number of dimensions (ie dim.ndim
).
Definition at line 319 of file itbl.h.
References dim, and Dim_tbl::ndim.
int Itbl::get_taille | ( | ) | const [inline] |
Gives the total size (ie dim.taille
).
Definition at line 316 of file itbl.h.
References dim, and Dim_tbl::taille.
int Itbl::operator() | ( | int | k, | |
int | j, | |||
int | i | |||
) | const [inline] |
Read-only of a particular element (index (k,j,i) ) (3D case).
Definition at line 297 of file itbl.h.
References Dim_tbl::dim, dim, etat, Dim_tbl::ndim, and t.
int Itbl::operator() | ( | int | j, | |
int | i | |||
) | const [inline] |
Read-only of a particular element (index (j,i) ) (2D case).
Definition at line 274 of file itbl.h.
References Dim_tbl::dim, dim, etat, Dim_tbl::ndim, and t.
int Itbl::operator() | ( | int | i | ) | const [inline] |
Read-only of a particular element (index i
) (1D case).
Definition at line 252 of file itbl.h.
References Dim_tbl::dim, dim, etat, Dim_tbl::ndim, and t.
void Itbl::operator*= | ( | int | x | ) |
Multiplication of this
by a int
.
Definition at line 483 of file itbl_arithm.C.
References etat, get_taille(), set_etat_zero(), and t.
void Itbl::operator*= | ( | const Itbl & | ti | ) |
Multiplication of this
by a Itbl
.
Definition at line 458 of file itbl_arithm.C.
References dim, etat, get_etat(), get_taille(), set_etat_zero(), and t.
void Itbl::operator+= | ( | int | x | ) |
Addition of a int
to this
.
Definition at line 351 of file itbl_arithm.C.
References etat, get_taille(), set_etat_qcq(), and t.
void Itbl::operator+= | ( | const Itbl & | ti | ) |
Addition of a Itbl
to this
.
Definition at line 314 of file itbl_arithm.C.
References dim, etat, get_etat(), get_taille(), set_etat_qcq(), and t.
void Itbl::operator-= | ( | int | x | ) |
Subtraction of a int
to this
.
Definition at line 423 of file itbl_arithm.C.
References etat, get_taille(), set_etat_qcq(), and t.
void Itbl::operator-= | ( | const Itbl & | ti | ) |
Subtraction of a Itbl
to this
.
Definition at line 386 of file itbl_arithm.C.
References dim, etat, get_etat(), get_taille(), set_etat_qcq(), and t.
void Itbl::operator= | ( | int | a | ) |
Assignment to a int
.
Definition at line 199 of file itbl.C.
References get_taille(), set_etat_qcq(), set_etat_zero(), and t.
void Itbl::operator= | ( | const Itbl & | tx | ) |
Assignment to another Itbl
.
Definition at line 172 of file itbl.C.
References dim, etat, get_etat(), get_taille(), set_etat_qcq(), set_etat_zero(), and t.
void Itbl::sauve | ( | FILE * | fd | ) | const |
Save in a file.
Definition at line 222 of file itbl.C.
References dim, etat, fwrite_be(), get_taille(), Dim_tbl::sauve(), and t.
int& Itbl::set | ( | int | k, | |
int | j, | |||
int | i | |||
) | [inline] |
Read/write of a particular element (index (k,j,i) ) (3D case).
Definition at line 287 of file itbl.h.
References Dim_tbl::dim, dim, etat, Dim_tbl::ndim, and t.
int& Itbl::set | ( | int | j, | |
int | i | |||
) | [inline] |
Read/write of a particular element (index (j,i) ) (2D case).
Definition at line 265 of file itbl.h.
References Dim_tbl::dim, dim, etat, Dim_tbl::ndim, and t.
int& Itbl::set | ( | int | i | ) | [inline] |
Read/write of a particular element (index i
) (1D case).
Definition at line 243 of file itbl.h.
References Dim_tbl::dim, dim, etat, Dim_tbl::ndim, and t.
void Itbl::set_etat_nondef | ( | ) |
void Itbl::set_etat_qcq | ( | ) |
Sets the logical state to ETATQCQ
(ordinary state).
If the state (member etat
) is already ETATQCQ
, this function does nothing. Otherwise, it performs the memory allocation for the int
array t
.
Definition at line 257 of file itbl.C.
References etat, get_taille(), and t.
void Itbl::set_etat_zero | ( | ) |
ostream& operator<< | ( | ostream & | , | |
const Itbl & | ||||
) | [friend] |
Display.
int Itbl::etat [private] |