#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 n) |
Returns a reference of an element for reading/writing. | |
const element & | operator() (int n) const |
Returns a reference of an element for reading only. | |
const element & | operator[] (int n) const |
Returns a reference of an element for reading only. | |
void | allocate (int n) |
Allocates the table for holding 'n' elements. | |
void | fill (const element &e, int 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 n) |
Increases the number of pieces to the desired one. | |
Private Attributes | |
int | 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. |
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 78 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 140 of file multitab.h.
References DEFAULTPIECESIZE, chomp::homology::multitable< element >::npieces, chomp::homology::multitable< element >::offsetmask, chomp::homology::multitable< element >::shiftbits, and chomp::homology::multitable< element >::tab.
chomp::homology::multitable< element >::multitable | ( | const multitable< element > & | m | ) | [inline] |
The copy constructor.
Definition at line 154 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 322 of file multitab.h.
References chomp::homology::multitable< element >::npieces, and chomp::homology::multitable< element >::tab.
multitable< element > & chomp::homology::multitable< element >::operator= | ( | const multitable< element > & | m | ) | [inline] |
element & chomp::homology::multitable< element >::operator[] | ( | int | 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 334 of file multitab.h.
References chomp::homology::multitable< element >::increase(), chomp::homology::multitable< element >::npieces, chomp::homology::multitable< element >::offsetmask, chomp::homology::multitable< element >::shiftbits, and chomp::homology::multitable< element >::tab.
const element & chomp::homology::multitable< element >::operator() | ( | int | 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 363 of file multitab.h.
References chomp::homology::multitable< element >::npieces, chomp::homology::multitable< element >::offsetmask, chomp::homology::multitable< element >::shiftbits, and chomp::homology::multitable< element >::tab.
const element & chomp::homology::multitable< element >::operator[] | ( | int | 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 378 of file multitab.h.
void chomp::homology::multitable< element >::allocate | ( | int | n | ) | [inline] |
Allocates the table for holding 'n' elements.
The table is still able to grow further if necessary.
Definition at line 384 of file multitab.h.
References chomp::homology::multitable< element >::increase(), chomp::homology::multitable< element >::npieces, chomp::homology::multitable< element >::shiftbits, and chomp::homology::multitable< element >::tab.
void chomp::homology::multitable< element >::fill | ( | const element & | e, | |
int | n | |||
) | [inline] |
Fills the table from 0 to the given index with the given element.
Definition at line 406 of file multitab.h.
References chomp::homology::multitable< element >::increase(), chomp::homology::multitable< element >::npieces, chomp::homology::multitable< element >::offsetmask, chomp::homology::multitable< element >::shiftbits, and chomp::homology::multitable< element >::tab.
void chomp::homology::multitable< element >::swap | ( | multitable< element > & | other | ) | [inline] |
Swaps data with another multitable object.
Definition at line 432 of file multitab.h.
References chomp::homology::my_swap(), chomp::homology::multitable< element >::npieces, chomp::homology::multitable< element >::offsetmask, chomp::homology::multitable< element >::shiftbits, and chomp::homology::multitable< element >::tab.
void chomp::homology::multitable< element >::increase | ( | int | n | ) | [inline, private] |
Increases the number of pieces to the desired one.
Definition at line 442 of file multitab.h.
References chomp::homology::multitable< element >::npieces, and chomp::homology::multitable< element >::tab.
Referenced by chomp::homology::multitable< element >::allocate(), chomp::homology::multitable< element >::fill(), and chomp::homology::multitable< element >::operator[]().
int chomp::homology::multitable< element >::npieces [private] |
The number of pieces ready to allocate.
Definition at line 120 of file multitab.h.
Referenced by chomp::homology::multitable< element >::allocate(), chomp::homology::multitable< element >::fill(), chomp::homology::multitable< element >::increase(), chomp::homology::multitable< element >::multitable(), chomp::homology::multitable< element >::operator()(), chomp::homology::multitable< element >::operator[](), chomp::homology::multitable< element >::swap(), and chomp::homology::multitable< element >::~multitable().
int chomp::homology::multitable< element >::shiftbits [private] |
The number of bits to shift the index of an element in the table.
Definition at line 124 of file multitab.h.
Referenced by chomp::homology::multitable< element >::allocate(), chomp::homology::multitable< element >::fill(), chomp::homology::multitable< element >::multitable(), chomp::homology::multitable< element >::operator()(), chomp::homology::multitable< element >::operator[](), and chomp::homology::multitable< element >::swap().
int chomp::homology::multitable< element >::offsetmask [private] |
The mask to get the offset of an element in a table piece.
Definition at line 127 of file multitab.h.
Referenced by chomp::homology::multitable< element >::fill(), chomp::homology::multitable< element >::multitable(), chomp::homology::multitable< element >::operator()(), chomp::homology::multitable< element >::operator[](), and chomp::homology::multitable< element >::swap().
element** chomp::homology::multitable< element >::tab [private] |
The actual tables.
Definition at line 130 of file multitab.h.
Referenced by chomp::homology::multitable< element >::allocate(), chomp::homology::multitable< element >::fill(), chomp::homology::multitable< element >::increase(), chomp::homology::multitable< element >::multitable(), chomp::homology::multitable< element >::operator()(), chomp::homology::multitable< element >::operator[](), chomp::homology::multitable< element >::swap(), and chomp::homology::multitable< element >::~multitable().