A container for elements placed in a table (like a vector) that is actually built of many smaller tables. More...
#include <chomp/struct/multitab.h>
Public Member Functions | |
multitable (int piecesize=0) | |
The default constructor for a table with the given size of each piece (should be a power of 2 or is rounded up). | |
multitable (const multitable< element > &m) | |
The copy constructor. | |
multitable< element > & | operator= (const multitable< element > &m) |
The assignment operator. | |
~multitable () | |
The destructor. | |
element & | operator[] (int_t n) |
Returns a reference of an element for reading/writing. | |
const element & | operator() (int_t n) const |
Returns a reference of an element for reading only. | |
const element & | operator[] (int_t n) const |
Returns a reference of an element for reading only. | |
void | allocate (int_t n) |
Allocates the table for holding 'n' elements. | |
void | fill (const element &e, int_t n) |
Fills the table from 0 to the given index with the given element. | |
void | swap (multitable< element > &other) |
Swaps data with another multitable object. | |
Private Member Functions | |
void | increase (int_t n) |
Increases the number of pieces to the desired one. | |
Private Attributes | |
int_t | npieces |
The number of pieces ready to allocate. | |
int | shiftbits |
The number of bits to shift the index of an element in the table. | |
int | offsetmask |
The mask to get the offset of an element in a table piece. | |
element ** | tab |
The actual tables. |
A container for elements placed in a table (like a vector) that is actually built of many smaller tables.
This may be important for good memory allocation. The table extends automatically upon use of elements that are outside the range of its indices.
Definition at line 65 of file multitab.h.
chomp::homology::multitable< element >::multitable | ( | int | piecesize = 0 ) |
[inline] |
The default constructor for a table with the given size of each piece (should be a power of 2 or is rounded up).
Definition at line 127 of file multitab.h.
References DEFAULTPIECESIZE.
chomp::homology::multitable< element >::multitable | ( | const multitable< element > & | m ) |
The copy constructor.
Definition at line 141 of file multitab.h.
References chomp::homology::multitable< element >::npieces, chomp::homology::multitable< element >::shiftbits, and chomp::homology::multitable< element >::tab.
chomp::homology::multitable< element >::~multitable | ( | ) | [inline] |
The destructor.
Definition at line 327 of file multitab.h.
void chomp::homology::multitable< element >::allocate | ( | int_t | n ) |
Allocates the table for holding 'n' elements.
The table is still able to grow further if necessary.
Definition at line 391 of file multitab.h.
void chomp::homology::multitable< element >::fill | ( | const element & | e, |
int_t | n | ||
) |
Fills the table from 0 to the given index with the given element.
Definition at line 415 of file multitab.h.
void chomp::homology::multitable< element >::increase | ( | int_t | n ) | [private] |
Increases the number of pieces to the desired one.
Definition at line 451 of file multitab.h.
const element & chomp::homology::multitable< element >::operator() | ( | int_t | n ) | const [inline] |
Returns a reference of an element for reading only.
Throws an error message if the index is out of range.
Definition at line 370 of file multitab.h.
multitable< element > & chomp::homology::multitable< element >::operator= | ( | const multitable< element > & | m ) |
The assignment operator.
Definition at line 169 of file multitab.h.
const element & chomp::homology::multitable< element >::operator[] | ( | int_t | n ) | const [inline] |
Returns a reference of an element for reading only.
Throws an error message if the index is out of range.
Definition at line 385 of file multitab.h.
element & chomp::homology::multitable< element >::operator[] | ( | int_t | n ) | [inline] |
Returns a reference of an element for reading/writing.
If the index is out of range, the table is automatically extended.
Definition at line 341 of file multitab.h.
void chomp::homology::multitable< element >::swap | ( | multitable< element > & | other ) | [inline] |
Swaps data with another multitable object.
Definition at line 441 of file multitab.h.
int_t chomp::homology::multitable< element >::npieces [private] |
The number of pieces ready to allocate.
Definition at line 107 of file multitab.h.
Referenced by chomp::homology::multitable< element >::multitable().
int chomp::homology::multitable< element >::offsetmask [private] |
The mask to get the offset of an element in a table piece.
Definition at line 114 of file multitab.h.
int chomp::homology::multitable< element >::shiftbits [private] |
The number of bits to shift the index of an element in the table.
Definition at line 111 of file multitab.h.
Referenced by chomp::homology::multitable< element >::multitable().
element** chomp::homology::multitable< element >::tab [private] |
The actual tables.
Definition at line 117 of file multitab.h.
Referenced by chomp::homology::multitable< element >::multitable().