#include <ace/Containers.h>
template<class T> class ACE_Unbounded_Stack {
public:
friend class ACE_Unbounded_Stack_Iterator<T>;
typedef ACE_Unbounded_Stack_Iterator<T> ITERATOR;
ACE_Unbounded_Stack (ACE_Allocator *alloc = 0);
ACE_Unbounded_Stack (const ACE_Unbounded_Stack<T> &s);
void operator= (const ACE_Unbounded_Stack<T> &s);
~ACE_Unbounded_Stack (void);
int push (const T &new_item);
int pop (T &item);
int top (T &item) const;
int is_empty (void) const;
int is_full (void) const;
int insert (const T &new_item);
int remove (const T &item);
int find (const T &item) const;
size_t size (void) const;
void dump (void) const;
ACE_ALLOC_HOOK_DECLARE;
private:
void delete_all_nodes (void);
void copy_all_nodes (const ACE_Unbounded_Stack<T> &s);
ACE_Node<T> *head_;
size_t cur_size_;
ACE_Allocator *allocator_;
};
insert
or remove
methods you should keep
in mind that duplicate entries aren't allowed. In general,
therefore, you should avoid the use of these methods since
they aren't really part of the ADT stack.
ACE_Unbounded_Stack (ACE_Allocator *alloc = 0);
ACE_Unbounded_Stack (const ACE_Unbounded_Stack<T> &s);
void operator= (const ACE_Unbounded_Stack<T> &s);
~ACE_Unbounded_Stack (void);
int push (const T &new_item);
int pop (T &item);
int top (T &item) const;
int is_empty (void) const;
int is_full (void) const;
int insert (const T &new_item);
new_item
into the Stack at the head (but doesn't allow
duplicates). Returns -1 if failures occur, 1 if item is already
present (i.e., no duplicates are allowed), else 0.
int remove (const T &item);
item
from the Stack. Returns 0 if it removes the item,
-1 if it can't find the item, and -1 if a failure occurs.
int find (const T &item) const;
item
occurs the set. Returns 0 if finds, else -1.
size_t size (void) const;
void dump (void) const;
ACE_ALLOC_HOOK_DECLARE;