Документ взят из кэша поисковой машины. Адрес оригинального документа : http://www.atnf.csiro.au/computing/software/casacore/casacore-1.2.0/doc/html/classcasa_1_1PoolStack.html
Дата изменения: Unknown
Дата индексирования: Mon Feb 14 21:23:30 2011
Кодировка:

Поисковые слова: iapetus
casacore: casa::PoolStack< T, Key > Class Template Reference
Public Member Functions | Static Public Attributes | Private Member Functions | Private Attributes

casa::PoolStack< T, Key > Class Template Reference
[Containers_module]

A parameterized stack of re-usable objects. More...

#include <PoolStack.h>

List of all members.

Public Member Functions

 PoolStack ()
 Create the stack with the default Key.
 PoolStack (const Key &key)
 Create the stack for the specified key.
 ~PoolStack ()
 Delete the stack.
T * get ()
 Get a pointer to an object in the stack.
void release (T *obj)
 Return an object to the stack for re-use.
void addElements (const uInt n)
 Add n elements.
void clear ()
 Decimate the stack by getting rid of all unused elements in it.
Bool empty ()
 Test if stack empty.
const Key & key () const
 Return the key belonging to the stack.
uInt nelements () const
 return the stack extend (for debugging use and checking mainly)

Static Public Attributes

static const uInt NDEF
 Number of default stack entries.

Private Member Functions

 PoolStack (const PoolStack< T, Key > &other)
 Copy and assignment constructors and assignment (not implemented).
PoolStack< T, Key > & operator= (const PoolStack< T, Key > &other)

Private Attributes

uInt top_p
 Current pointer to top-of-stack.
PtrBlock< T * > stack_p
 The stack.
Key key_p
 The key belonging to this stack.

Detailed Description

template<class T, class Key>
class casa::PoolStack< T, Key >

A parameterized stack of re-usable objects.

Intended use:

Public interface

Review Status

Reviewed By:
Ger van Diepen
Date Reviewed:
2001/07/03
Test programs:
tPoolStack

Prerequisite

Synopsis

A PoolStack contains a set of pre-allocated Objects of the type T, with a parameter Key (e.g. an object could be a Vector of T Double with an uInt Key). The stack is a very simple stack, without the linking/unlinking of a normal Stack implementation. This lightweight implementation was especially designed for use with the ObjectPool class, but can be used independently.

Objects can be obtained with the get() method, and returned for re-use with release().

Objects are not initialised when popped. The user should never delete the object returned by get; but return it to the pool.

Example

      // Create a pool of length 5 vectors
      PoolStack<Vector<Double>, uInt> pool5(5);
      // Get an element
      Vector<Double> *elem(pool5.get());
      // Use it
      (*elem)(2) = 27;
      // Release it
      pool5.release(elem);

Motivation

To improve the speed for the auto differentiating class.

Template Type Argument Requirements (T)

Template Type Argument Requirements (Key)

To Do

Definition at line 98 of file PoolStack.h.


Constructor & Destructor Documentation

template<class T, class Key>
casa::PoolStack< T, Key >::PoolStack (  ) 

Create the stack with the default Key.

template<class T, class Key>
casa::PoolStack< T, Key >::PoolStack ( const Key &  key  )  [explicit]

Create the stack for the specified key.

template<class T, class Key>
casa::PoolStack< T, Key >::~PoolStack (  ) 

Delete the stack.

template<class T, class Key>
casa::PoolStack< T, Key >::PoolStack ( const PoolStack< T, Key > &  other  )  [private]

Copy and assignment constructors and assignment (not implemented).


Member Function Documentation

template<class T, class Key>
void casa::PoolStack< T, Key >::addElements ( const uInt  n  ) 
template<class T, class Key>
void casa::PoolStack< T, Key >::clear (  ) 

Decimate the stack by getting rid of all unused elements in it.

template<class T, class Key>
Bool casa::PoolStack< T, Key >::empty (  )  [inline]

Test if stack empty.

Definition at line 128 of file PoolStack.h.

template<class T, class Key>
T* casa::PoolStack< T, Key >::get (  )  [inline]

Get a pointer to an object in the stack.

The stack will be extended if no objects left. Extension is done with the NDEF number of elements. Different extension can be done manually with the addElements() method.

Definition at line 115 of file PoolStack.h.

template<class T, class Key>
const Key& casa::PoolStack< T, Key >::key (  )  const [inline]

Return the key belonging to the stack.

Definition at line 131 of file PoolStack.h.

template<class T, class Key>
uInt casa::PoolStack< T, Key >::nelements (  )  const [inline]

return the stack extend (for debugging use and checking mainly)

Definition at line 133 of file PoolStack.h.

template<class T, class Key>
PoolStack<T, Key>& casa::PoolStack< T, Key >::operator= ( const PoolStack< T, Key > &  other  )  [private]
template<class T, class Key>
void casa::PoolStack< T, Key >::release ( T *  obj  )  [inline]

Return an object to the stack for re-use.

Definition at line 119 of file PoolStack.h.


Member Data Documentation

template<class T, class Key>
Key casa::PoolStack< T, Key >::key_p [private]

The key belonging to this stack.

Definition at line 142 of file PoolStack.h.

Referenced by casa::PoolStack< AutoDiffRep< Double >, uInt >::key().

template<class T, class Key>
const uInt casa::PoolStack< T, Key >::NDEF [static]

Number of default stack entries.

Definition at line 102 of file PoolStack.h.

Referenced by casa::PoolStack< AutoDiffRep< Double >, uInt >::get().

template<class T, class Key>
PtrBlock<T*> casa::PoolStack< T, Key >::stack_p [private]
template<class T, class Key>
uInt casa::PoolStack< T, Key >::top_p [private]

The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines