Документ взят из кэша поисковой машины. Адрес
оригинального документа
: 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 Кодировка: Поисковые слова: southern cross |
A parameterized stack of re-usable objects. More...
#include <PoolStack.h>
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. |
A parameterized stack of re-usable objects.
Public interface
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.
// 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);
To improve the speed for the auto differentiating class.
Definition at line 98 of file PoolStack.h.
casa::PoolStack< T, Key >::PoolStack | ( | ) |
Create the stack with the default Key.
casa::PoolStack< T, Key >::PoolStack | ( | const Key & | key | ) | [explicit] |
Create the stack for the specified key.
casa::PoolStack< T, Key >::~PoolStack | ( | ) |
Delete the stack.
casa::PoolStack< T, Key >::PoolStack | ( | const PoolStack< T, Key > & | other | ) | [private] |
Copy and assignment constructors and assignment (not implemented).
void casa::PoolStack< T, Key >::addElements | ( | const uInt | n | ) |
Add n elements.
Referenced by casa::PoolStack< AutoDiffRep< Double >, uInt >::get().
void casa::PoolStack< T, Key >::clear | ( | ) |
Decimate the stack by getting rid of all unused elements in it.
Bool casa::PoolStack< T, Key >::empty | ( | ) | [inline] |
Test if stack empty.
Definition at line 128 of file PoolStack.h.
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.
const Key& casa::PoolStack< T, Key >::key | ( | ) | const [inline] |
Return the key belonging to the stack.
Definition at line 131 of file PoolStack.h.
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.
PoolStack<T, Key>& casa::PoolStack< T, Key >::operator= | ( | const PoolStack< T, Key > & | other | ) | [private] |
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.
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().
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().
PtrBlock<T*> casa::PoolStack< T, Key >::stack_p [private] |
The stack.
Definition at line 140 of file PoolStack.h.
Referenced by casa::PoolStack< AutoDiffRep< Double >, uInt >::get(), and casa::PoolStack< AutoDiffRep< Double >, uInt >::release().
uInt casa::PoolStack< T, Key >::top_p [private] |
Current pointer to top-of-stack.
Definition at line 133 of file PoolStack.h.
Referenced by casa::PoolStack< AutoDiffRep< Double >, uInt >::empty(), casa::PoolStack< AutoDiffRep< Double >, uInt >::get(), and casa::PoolStack< AutoDiffRep< Double >, uInt >::release().