The Original CHomP Software
Public Member Functions | Private Member Functions | Private Attributes | List of all members
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>

Public Member Functions

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

Private Member Functions

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

Private Attributes

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

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 54 of file pool.h.

Constructor & Destructor Documentation

◆ pool() [1/2]

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

The constructor of a pool.

Definition at line 98 of file pool.h.

98 : elemCount (0), unusedCount (0)
99{
100 return;
101} /* pool::pool */
int elemCount
The number of elements in the multitable.
Definition: pool.h:85
int unusedCount
The number of unused elements in the multitable.
Definition: pool.h:91

◆ ~pool()

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

The destructor of a pool.

Definition at line 104 of file pool.h.

105{
106 return;
107} /* pool::~pool */

◆ pool() [2/2]

template<class element >
chomp::homology::pool< element >::pool ( const pool< element > &  )
inlineprivate

The copy constructor is not allowed.

Definition at line 110 of file pool.h.

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

Member Function Documentation

◆ get()

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 124 of file pool.h.

125{
126 if (unusedCount)
127 return unused [-- unusedCount];
128 else
129 return elemCount ++;
130} /* pool::get */
multitable< int > unused
The multitable with indices of unused elements.
Definition: pool.h:88

◆ operator=()

template<class element >
pool< element > & chomp::homology::pool< element >::operator= ( const pool< element > &  )
inlineprivate

The assignment operator is not allowed.

Definition at line 117 of file pool.h.

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

◆ 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 133 of file pool.h.

134{
135 return elem [n];
136} /* pool::operator [] */
multitable< element > elem
The multitable of elements.
Definition: pool.h:82

◆ release()

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 139 of file pool.h.

140{
141 if (n == elemCount - 1)
142 -- elemCount;
143 else
144 unused [unusedCount ++] = n;
145 return;
146} /* pool::release */

Member Data Documentation

◆ elem

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

The multitable of elements.

Definition at line 82 of file pool.h.

◆ elemCount

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

The number of elements in the multitable.

Definition at line 85 of file pool.h.

◆ unused

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

The multitable with indices of unused elements.

Definition at line 88 of file pool.h.

◆ unusedCount

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

The number of unused elements in the multitable.

Definition at line 91 of file pool.h.


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