Module: Essential Tools Module Group: Generic Classes
Does not inherit
clear() contains() containsReference() |
entries() isEmpty() occurrencesOf() |
occurrencesOfReference() operator=() pop() |
push() RWGStack(type)() top() |
#include <rw/gstack.h> declare(RWGStackT) RWGStack(type) a ;
Class RWGStack(type) represents a group of ordered elements, not accessible by an external key. A RWGStack(type) is a last in, first out (LIFO) sequential list for which insertions and removals are made at the beginning of the list. Hence, the ordering is determined externally by the ordering of the insertions. Duplicates are allowed. This class is implemented as a singly-linked list. Objects of type RWGStack(type) are declared with macros defined in the standard C++ header file <generic.h>.
NOTE -- RWGStack is deprecated. Please use RWTStack.
In order to find a particular item within the collection, a user-provided global "tester" function is required to test for a "match," definable in any consistent way. This function should have prototype:
bool yourTesterFunction(const type* c, const void* d);
The argument c is a candidate within the collection to be tested for a match. The argument d is for your convenience and will be passed to yourTesterFunction(). The function should return true if a "match" is found between c and d.
In order to simplify the documentation below, an imaginary typedef:
typedef bool (*yourTester)(const type*, const void*);
has been used for this tester function.
None
RWGStack(type)();
Constructs an empty stack.
RWGStack(type)(type* a);
Constructs a stack with one entry a.
RWGStack(type)(const RWGStack(type)& a);
Copy constructor. A shallow copy of a is made.
void operator=(const RWGStack(type)& a);
Assignment operator. A shallow copy of a is made.
void clear();
Removes all items from the stack.
bool contains(yourTester t, const void* d) const;
Returns true if the stack contains an item for which the user-defined function pointed to by t finds a match with d.
bool containsReference(const type* e) const;
Returns true if the stack contains an item with the address e.
size_t entries() const;
Returns the number of items in the stack.
bool isEmpty() const;
Returns true if the stack is empty, otherwise false.
size_t occurrencesOf(yourTester t, const void* d) const;
Returns the number of items in the stack for which the user-provided function pointed to by t finds a match with d.
size_t occurrencesOfReference(const type* e) const;
Returns the number of items in the stack with the address e.
type* pop();
Removes and returns the item at the top of the stack, or returns nil if the stack is empty.
void push(type* a);
Adds an item to the top of the stack.
type* top() const;
Returns the item at the top of the stack or nil if the stack is empty.
© Copyright Rogue Wave Software, Inc. All Rights Reserved.
Rogue Wave and SourcePro are registered trademarks of Rogue Wave Software, Inc. in the United States and other countries. All other trademarks are the property of their respective owners.
Contact Rogue Wave about documentation or support issues.