Public Member Functions | Private Member Functions | Private Attributes

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

This template contains the definition of a pool of elements that are stored in an extensible table. More...

#include <pool.h>

List of all members.

Public Member Functions

 pool ()
 The constructor of a pool.
 ~pool ()
 The destructor of a pool.
int get ()
 Allocates a new element in the pool or finds a used one.
element & operator[] (int number)
 Retrieves the element in the pool with the given number.
void release (int number)
 Marks the given element as unused and available for retrieval the next time the pool is asked for an element.

Private Member Functions

 pool (const pool< element > &)
 The copy constructor is not allowed.
pool< element > & operator= (const pool< element > &)
 The assignment operator is not allowed.

Private Attributes

multitable< element > elem
 The multitable of elements.
int elemCount
 The number of elements in the multitable.
multitable< int > unused
 The multitable with indices of unused elements.
int unusedCount
 The number of unused elements in the multitable.

Detailed Description

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

This template contains the definition of a pool of elements that are stored in an extensible table.

Elements that are returned to the pool can be reused. Indexing of the elements is done by integer numbers.

Definition at line 55 of file pool.h.


Constructor & Destructor Documentation

template<class element >
chomp::homology::pool< element >::pool (  )  [inline]

The constructor of a pool.

Definition at line 99 of file pool.h.

                           : elemCount (0), unusedCount (0)
{
        return;
} /* pool::pool */

template<class element >
chomp::homology::pool< element >::~pool (  )  [inline]

The destructor of a pool.

Definition at line 105 of file pool.h.

{
        return;
} /* pool::~pool */

template<class element >
chomp::homology::pool< element >::pool ( const pool< element > &   )  [inline, private]

The copy constructor is not allowed.

Definition at line 111 of file pool.h.

{
        throw "Copy constructor for a pool not implemented.";
        return;
} /* pool::pool */


Member Function Documentation

template<class element >
int chomp::homology::pool< element >::get (  )  [inline]

Allocates a new element in the pool or finds a used one.

Returns its number.

Definition at line 125 of file pool.h.

References chomp::homology::pool< element >::elemCount, chomp::homology::pool< element >::unused, and chomp::homology::pool< element >::unusedCount.

{
        if (unusedCount)
                return unused [-- unusedCount];
        else
                return elemCount ++;
} /* pool::get */

template<class element >
pool< element > & chomp::homology::pool< element >::operator= ( const pool< element > &   )  [inline, private]

The assignment operator is not allowed.

Definition at line 118 of file pool.h.

{
        throw "Assignment operator for a pool not implemented.";
        return *this;
} /* pool::operator = */

template<class element >
element & chomp::homology::pool< element >::operator[] ( int  number  )  [inline]

Retrieves the element in the pool with the given number.

Definition at line 134 of file pool.h.

References chomp::homology::pool< element >::elem.

{
        return elem [n];
} /* pool::operator [] */

template<class element >
void chomp::homology::pool< element >::release ( int  number  )  [inline]

Marks the given element as unused and available for retrieval the next time the pool is asked for an element.

Definition at line 140 of file pool.h.

References chomp::homology::pool< element >::elemCount, chomp::homology::pool< element >::unused, and chomp::homology::pool< element >::unusedCount.

{
        if (n == elemCount - 1)
                -- elemCount;
        else
                unused [unusedCount ++] = n;
        return;
} /* pool::release */


Member Data Documentation

template<class element>
multitable<element> chomp::homology::pool< element >::elem [private]

The multitable of elements.

Definition at line 83 of file pool.h.

Referenced by chomp::homology::pool< element >::operator[]().

template<class element>
int chomp::homology::pool< element >::elemCount [private]

The number of elements in the multitable.

Definition at line 86 of file pool.h.

Referenced by chomp::homology::pool< element >::get(), and chomp::homology::pool< element >::release().

template<class element>
multitable<int> chomp::homology::pool< element >::unused [private]

The multitable with indices of unused elements.

Definition at line 89 of file pool.h.

Referenced by chomp::homology::pool< element >::get(), and chomp::homology::pool< element >::release().

template<class element>
int chomp::homology::pool< element >::unusedCount [private]

The number of unused elements in the multitable.

Definition at line 92 of file pool.h.

Referenced by chomp::homology::pool< element >::get(), and chomp::homology::pool< element >::release().


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