Click on the banner to return to the Class Reference home page.

©Copyright 1996 Rogue Wave Software

RWGStack(type)

Synopsis

#include <rw/gstack.h>
declare(RWGStack,type)

RWGStack(type) a ;

Description

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>.

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:

RWBoolean 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 RWBoolean (*yourTester)(const type*, const void*);

has been used for this tester function.

Persistence

None

Public Constructors

RWGStack(type)();
RWGStack(type)(type* a);
RWGStack(type)(const RWGStack(type)& a);

Assignment Operator

void
operator=(const RWGStack(type)& a);

Public Member Functions

void
clear();
RWBoolean
contains(yourTester t, const void* d) const;
RWBoolean
containsReference(const type* e) const;
size_t
entries() const; 
RWBoolean
isEmpty() const;
size_t
occurrencesOf(yourTester t, const void* d) const;
size_t
occurrencesOfReference(const type* e) const;
type*
pop();
void
push(type* a);
type*
top() const;