Module: Essential Tools Module Group: Generic Classes
Does not inherit
append() clear() contains() containsReference() |
entries() first() get() insert() |
isEmpty() last() occurrencesOf() occurrencesOfReference() |
operator=() RWGQueue() |
#include <rw/gqueue.h> declare(RWGQueue, type) RWGQueue(type) a ;
Class RWGQueue(type) represents a group of ordered elements, not accessible by an external key. A RWGQueue(type) is a first in, first out (FIFO) sequential list for which insertions are made at one end (the "tail"), but all removals are made at the other (the "head"). 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 RWGQueue(type) are declared with macros defined in the standard C++ header file <generic.h>.
NOTE -- RWGQueue is deprecated. Please use RWTQueue.
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
RWGQueue(type)();
Construct an empty queue.
RWGQueue(type)(type* a);
Construct a queue with one entry a.
RWGQueue(type)(const RWGQueue(type)& q);
Copy constructor. A shallow copy of q is made.
void operator=(const RWGQueue(type)& q);
Assignment operator. A shallow copy of q is made.
type* append(type* a);
Adds a to the end of the queue and returns it. Returns nil if the insertion was unsuccessful.
void clear();
Removes all items from the queue.
bool contains(yourTester t, const void* d) const;
Returns true if the queue 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 queue contains an item with the address e.
size_t entries() const;
Returns the number of items in the queue.
type* first() const;
Returns the first item in the queue, or nil if the queue is empty.
type* get();
Returns and removes the first item in the queue. Returns nil if the queue is empty.
bool isEmpty() const;
Returns true if the queue is empty, otherwise false.
type* insert(type* a);
Calls append(type*) with a as the argument.
type* last();
Returns the last (most recently inserted) item in the queue, or nil if the queue is empty.
size_t occurrencesOf(yourTester t, const void* d) const;
Returns the number of items in the queue 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 queue with the address e.
© 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.