Tools.h++ Manual

104011 Tandem Computers Incorporated 22-79
22
function pointed to by
testFun
returns
TRUE
and puts a copy of the matching
object into
k
. Returns
FALSE
otherwise and does not touch
k
. The tester
function must have the prototype:
RWBoolean
yourTester
(const T&, 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
. If you do not
need a copy of the found object, use
contains()
instead.
T first() const;
Returns (but does not remove) the first item in the list. The behavior is
undefined if the list is empty.
T get();
Returns and removes the first item in the list. The behavior is undefined if the
list is empty.
size_t index(const T& a);
Returns the index of the first object that is equal to the object
a
, or
RW_NPOS
if
there is no such object. Equality is measured by the class-defined equality
operator.
size_t index(RWBoolean (*testFun)
(const T&, void*), void* d)
const;
Returns the index of the first object for which the user-defined tester function
pointed to by
testFun
returns
TRUE
, or
RW_NPOS
if there is no such object.
The tester function must have the prototype:
RWBoolean
yourTester
(const T&, 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
.
void insert(const T& a);
Adds the item a to the end of the list.
void insertAt(size_t i, const T& a);
Insert the item a at the index position
i
. This position must be between zero
and the number of items in the list, or an exception of type
TOOL_INDEX
will
be thrown.
RWBoolean isEmpty() const;
Returns
TRUE
if there are no items in the list,
FALSE
otherwise.