--- parser3/src/include/pa_stack.h 2003/02/17 17:05:03 1.17.2.5 +++ parser3/src/include/pa_stack.h 2003/04/02 08:35:43 1.17.2.6.2.5 @@ -8,7 +8,7 @@ #ifndef PA_STACK_H #define PA_STACK_H -static const char* IDENT_STACK_H="$Date: 2003/02/17 17:05:03 $"; +static const char* IDENT_STACK_H="$Date: 2003/04/02 08:35:43 $"; #include "pa_config_includes.h" #include "pa_array.h" @@ -27,23 +27,24 @@ public: ftop++; } - /// @test to think: freeing unused stack item right now, may no do that? - /// [delay that till next push?] T pop() { - T result=get(--ftop); - put(ftop, T()); - return result; + return get(--ftop); } - int top_index() { return ftop-1; } - void top_index(int top_index) { ftop=top_index+1; } + size_t top_index() { return ftop-1; } + void top_index(size_t top_index) { ftop=top_index+1; } T top_value() { return get(top_index()); } -private: + /// call this prior to collecting garbage [in unused part of stack there may be pointers(unused)] + void wipe_unused() { + if(!is_full()) + memset(&felements[fused], 0, (fallocated-fused)*sizeof(T)); + } - // deepest used index - int ftop; +private: + // deepest used index+1 + size_t ftop; }; #endif