--- parser3/src/include/pa_stack.h 2003/01/28 09:48:16 1.17.2.2 +++ parser3/src/include/pa_stack.h 2003/03/27 10:04:06 1.17.2.6.2.2 @@ -1,14 +1,14 @@ /** @file Parser: stack class decl. - Copyright (c) 2001, 2003 ArtLebedev Group (http://www.artlebedev.com) + Copyright (c) 2001-2003 ArtLebedev Group (http://www.artlebedev.com) Author: Alexandr Petrosian (http://paf.design.ru) */ #ifndef PA_STACK_H #define PA_STACK_H -static const char* IDENT_STACK_H="$Date: 2003/01/28 09:48:16 $"; +static const char* IDENT_STACK_H="$Date: 2003/03/27 10:04:06 $"; #include "pa_config_includes.h" #include "pa_array.h" @@ -26,19 +26,25 @@ public: *this+=item; // append it ftop++; } + T pop() { return get(--ftop); } - int top_index() { return ftop-1; } + size_t top_index() { return ftop-1; } void top_index(int top_index) { ftop=top_index+1; } T top_value() { return get(top_index()); } + /// 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)); + } + private: // deepest used index - int ftop; - + size_t ftop; }; #endif