Public Member Functions | Private Member Functions | Private Attributes

chomp::homology::multitable< element > Class Template Reference

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>

List of all members.

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.

Detailed Description

template<class element>
class chomp::homology::multitable< element >

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.


Constructor & Destructor Documentation

template<class element >
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.

template<class element>
chomp::homology::multitable< element >::multitable ( const multitable< element > &  m )
template<class element >
chomp::homology::multitable< element >::~multitable (  ) [inline]

The destructor.

Definition at line 327 of file multitab.h.


Member Function Documentation

template<class element >
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.

template<class element>
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.

template<class element >
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.

template<class element >
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.

template<class element>
multitable< element > & chomp::homology::multitable< element >::operator= ( const multitable< element > &  m )

The assignment operator.

Definition at line 169 of file multitab.h.

template<class element >
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.

template<class element >
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.

template<class element>
void chomp::homology::multitable< element >::swap ( multitable< element > &  other ) [inline]

Swaps data with another multitable object.

Definition at line 441 of file multitab.h.


Member Data Documentation

template<class element>
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().

template<class element>
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.

template<class element>
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().

template<class element>
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().


The documentation for this class was generated from the following file: