Does not inherit
#include rwsf/core/List.h
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.)
Deprecated. Use std::list instead.
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.
void append(const T & a);
Adds the item a to the end of the collection.
void apply(void(*)(T &, void *) applyFun, void * d);
Applies the user-defined function pointed to by applyFun to every item in the collection. This function must have the prototype:
void <i>yourfun/i>(T& a, void* d);
Client data may be passed through parameter d.
T & at(size_t i);
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.
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(*)(const T &, void *) testFun, void * d) const;
Returns true if there exists an element a 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 <i>yourTester</i>(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(*)(const T &, void *) testFun, void * d, 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 \c <i>yourTester</i>(const T& a, void* d);
Client data may be passed through parameter d.
T & first();
Returns a reference to the first element of self.
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(*)(const T &, void *) testFun, void * d) 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 <i>yourTester</i>(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();
Returns a reference to the last item in the collection.
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(*)(const T &, void *) testFun, 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 <i>yourTester</i>(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(*)(const T &, void *) testFun, 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 <i>yourTester</i>(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(*)(const T &, void *) testFun, 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 <i>yourTester</i>(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.
T & operator[](size_t i);
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.
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.
List< T > & operator=(const List< T > &);
Assignment operator. Calls the destructor on all elements of self and replaces them by copying all elements of s.
operator std::list() const;
Conversion operator. Converts an rwsf::List to a std::list value.
© Copyright Rogue Wave Software, Inc. All Rights Reserved. All Rights Reserved. Rogue Wave is a registered trademark of Rogue Wave Software, Inc. in the United States and other countries. HydraExpress is a trademark of Rogue Wave Software, Inc. All other trademarks are the property of their respective owners.
Contact Rogue Wave about documentation or support issues.