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 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.


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 78 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 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.

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

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


Member Function Documentation

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

The assignment operator.

Definition at line 178 of file multitab.h.

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

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

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

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

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

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

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


Member Data Documentation

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

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 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().

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 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().

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


The documentation for this class was generated from the following file:
Generated on Wed Nov 21 11:08:42 2007 for The Uniform Expansion Software by  doxygen 1.5.3