Tools.h++ Manual

104011 Tandem Computers Incorporated 22-9
22
size_t occurrencesOf(RWBoolean
(*testFun)(const T*, void*),
void* d) const;
Traverses the list and returns the number of times for which the user-defined
"tester" function pointed to by
testFun
returned
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
.
size_t occurrencesOfReference(const T*
a) const;
Returns the number of times which the item pointed to by
a
occurs in the list.
Because items cannot be inserted into a list more than once, this function can
only return zero or one.
void prepend(T* a);
Prepends the item pointed to by
a
to the beginning of the list.
T* remove(RWBoolean
(*testFun)(const T*, void*),
void* d);
Removes and returns the first item for which the user-defined tester function
pointed to by
testFun
returns
TRUE
, or nil if there is no such item. 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
.
T* removeAt(size_t i);
Removes and 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.
T* removeFirst();
Removes and returns the first item in the list, or nil if there are no items in the
list.