#include <rwsf/core/List.h>
This class is deprecated. Please use std::list instead.
This class maintains a collection of values, implemented as a singly-linked list. The value type must have operator== and operator< defined.
This class stores a copy of the inserted item in self.
Assumes that T has:
a well-defined copy constructor (T::T(const T&) or equivalent.);
a well-defined assignment operator (T::operator=(const T&) or equivalent.);
a well-defined equality operator (T::operator==(const T&) or equivalent.)
List();
Default constructor. Constructs an empty singly-linked list.
List(const List<T>& s);
Copy constructor. Constructs a singly-linked list by copying all elements of s.
~List();
Destructor.
List<T>& operator=(const List<T>& s);
Assignment operator. Calls the destructor on all elements of self and replaces them by copying all elements of s.
T& operator[](size_t i); const T& operator[](size_t i) const;
Returns a reference to the ith element of self. Index i must be between 0 and one less then the number of entries in self, otherwise the function throws an exception of type rwsf::OutOfBoundsException.
operator std::list<T>() const;
Conversion operator. Converts an rwsf::List to a std::list value.
void append(const T& a);
Adds the item a to the end of the collection.
void apply(void (*applyFun)(T&, void*), void* d);
Applies the user-defined function pointed to by applyFun to every item in the collection. This function must have the prototype:
void yourfun(T& a, void* d);
Client data may be passed through parameter d.
T& at(size_t i); const T& at(size_t i) const;
Returns a reference to the ith element of self. Index i must be between 0 and one less then the number of entries in self, otherwise the function throws an exception of type rwsf::OutOfBoundsException.
void clear();
Clears the collection by removing all items from self. Each item will have its destructor called.
bool contains(const T& a) const;
Returns true if there exists an element t in self such that the expression(t == a) is true, otherwise returns false.
bool contains(bool (*testFun)(const T&, void*), void*) const;
Returns true if there exists an element t in self such that the expression ((*testFun)(t,d)) is true, otherwise returns false. testFun points to a user-defined tester function which must have prototype:
bool yourTester(const T& a, void* d);
Client data may be passed through parameter d.
size_t entries() const;
Returns the number of elements in self.
bool find(const T& a, T& ret) const;
If there exists an element t in self such that the expression (t == a) is true, assigns t to ret and returns true. Otherwise, returns false and leaves the value of ret unchanged.
bool find(bool (*testFun)(const T&, void* d), void*, T& ret) const;
If there exists an element t in self such that the expression ((*testFun)(t,d)) is true, assigns t to ret and returns true. Otherwise, returns false and leaves the value of ret unchanged. testFun points to a user-defined tester function which must have prototype:
bool yourTester(const T& a, void* d);
Client data may be passed through parameter d.
T& first(); const T& first() const;
Returns a reference to the first element of self.
T get();
Remove and return the link after the argument. The argument must occur in the list and cannot be the last link in the list.
size_t index(const T& a) const;
Returns the position of the first item t in self such that (t == a), or returns RWSF_NPOS if no such item exists.
size_t index(bool (*testFun)(const T&, void*), void*) const;
Returns the position of the first item t in self such that((*testFun)(t,d)) is true, or returns RWSF_NPOS if no such item exists. testFun points to a user-defined tester function which must have prototype:
bool yourTester(const T& a, void* d);
Client data may be passed through parameter d.
void insert(const T& a);
Adds the item a to the end of the collection.
void insertAt(size_t i, const T& a);
Inserts the item a in front of the item at position i in self. This position must be between 0 and the number of entries in the collection, otherwise the function throws an exception of type rwsf::OutOfBoundsException.
bool isEmpty() const;
Returns true if there are no items in the collection, false otherwise.
T& last(); const T& last() const;
Returns a reference to the last item in the collection.
size_t occurrencesOf(const T& a) const;
Returns the number of elements t in self such that the expression (t == a) is true.
size_t occurrencesOf(bool (*testFun)(const T&,void*), void* d) const;
Returns the number of elements t in self such that the expression((*testFun)(t,d)) is true. testFun points to a user-defined tester function which must have prototype:
bool yourTester(const T& a, void* d);
Client data may be passed through parameter d.
void prepend(const T& a);
Adds the item a to the beginning of the collection.
bool remove(const T& val);
Removes the first element t in self such that the expression (t == val) is true and returns true. Returns false if there is no such element.
bool remove(bool (*testFun)(const T&,void*), void* d);
Removes the first element t in self such that the expression ((*testFun)(t,d)) is true and returns true. Returns false if there is no such element. testFun points to a user-defined tester function which must have prototype:
bool yourTester(const T& a, void* d);
Client data may be passed through parameter d.
size_t removeAll(const T& a);
Removes all elements t in self such that the expression (t == a) is true. Returns the number of items removed.
size_t removeAll(bool (*testFun)(const T&,void*), void* d);
Removes all elements t in self such that the expression ((*testFun)(t,d))is true. Returns the number of items removed. testFun points to a user-defined tester function which must have prototype:
bool yourTester(const T& a, void* d);
Client data may be passed through parameter d.
T removeAt(size_t i);
Removes and returns the item at position i in self. This position must be between 0 and one less then the number of entries in the collection, otherwise the function throws an exception of type rwsf::OutOfBoundsException.
T removeFirst();
Removes and returns the first item in the collection.
T removeLast();
Removes and returns the last item in the collection.
©2004-2007 Copyright Quovadx, Inc. All Rights Reserved.
Quovadx and Rogue Wave are registered trademarks and HydraSDO is a trademark of Quovadx, 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.