This file contains an attempt to make the template pile. A pile is a finite size LIFO stack. When a element is pushed on that increases the stack beyond its maximum size, the oldest element is deleted from the stack. A subroutine can be used on that oldest element first.

The orginal use of this stack was to store old HepDouble arrays. When a new array is needed, we can simply pull one off the pile. However, we don't want to keep too many old array's around, after a while we just want to start getting rid of them. When the pile gets too large, or when the pile is destroyed, we want to call subroutines to get rid of some of these arrays.

Unfortunately, in version 2.2 of g++ templates don't seem to work unless they are declared inline. So this class has ridiculously long inline functions. Also, g++ doesn't seem to allow multiple arguements to templates, so the size of the pile is hardwired in. To change the size, change the value of the const int sz.


Nobu Katayama and Mike Smyth


#include "CLHEP/Matrix/Pile.h"

template<class T> 
class HepPile

Public Member Functions

HepPile(void (*f)(T)=0)
HepBoolean is_empty() const
Returns true when the pile is empty.
T pop()
Get the most recent item from the pile.
void push(T item)
Add an item to the pile.
void set_destroy(void (*f)(T))
Set a routine which will be called when the pile begins to overflow. It is okay to not supply a function, in that case nothing is done when an item falls off the bottom of the pile. It is simply lost.

19 June 2001