Tools.h++ Manual
104011 Tandem Computers Incorporated 22-15
22
void apply(void (*applyFun)(T*,
void*), void* d);
Calls the function pointed to by
applyFun
to every item in the collection. This
must have the prototype:
void
yourFun
(T* item, void* d);
The item will be passed in as argument item. Client data may be passed
through as parameter
d
.
T* at(size_t i) const;
Returns the item at index
i
. The index
i
must be between zero and the
number of items in the collection less one, or an exception of type
TOOL_INDEX
will be thrown.
void clear();
Removes all items from the list.
void clearAndDestroy();
Removes and calls delete for each item in the list.
Note – This assumes that each item was allocated off the heap.
RWBoolean contains(RWBoolean
(*testFun)(const T*, void*),
void* d) const;
Returns
TRUE
if the list contains an item for which the user-defined "tester"
function pointed to by
testFun
returns
TRUE
. The tester function must have
the prototype:
RWBoolean
yourTester
(const T* item, void* d);
For each item in the list this function will be called with the item as the first
argument. Client data may be passed through as parameter
d
.
RWBoolean containsReference(const T* a)
const;
Returns
TRUE
if the list contains an item with the address
a
.
size_t entries() const;
Returns the number of items currently in the list.