|
| RWTPtrDlist () |
|
| RWTPtrDlist (const container_type &lst) |
|
| RWTPtrDlist (const RWTPtrDlist< T, A > &lst) |
|
| RWTPtrDlist (container_type &&lst) |
|
template<typename InputIterator > |
| RWTPtrDlist (InputIterator first, InputIterator last) |
|
| RWTPtrDlist (RWTPtrDlist< T, A > &&lst) |
|
| RWTPtrDlist (size_type n, value_type a=0) |
|
void | append (value_type a) |
|
void | apply (void(*fn)(const T *, void *), void *d) const |
|
void | apply (void(*fn)(reference, void *), void *d) |
|
void | apply (void(*fn)(value_type, void *), void *d) |
|
template<typename InputIterator > |
void | assign (InputIterator first, InputIterator last) |
|
reference | at (size_type i) |
|
const_reference | at (size_type i) const |
|
iterator | begin () |
|
const_iterator | begin () const |
|
const_iterator | cbegin () const |
|
const_iterator | cend () const |
|
void | clear () |
|
void | clearAndDestroy () |
|
bool | contains (bool(*fn)(const T *, void *), void *d) const |
|
bool | contains (const T *a) const |
|
const_reverse_iterator | crbegin () const |
|
const_reverse_iterator | crend () const |
|
iterator | end () |
|
const_iterator | end () const |
|
size_type | entries () const |
|
iterator | erase (iterator first, iterator last) |
|
iterator | erase (iterator pos) |
|
value_type | find (bool(*fn)(const T *, void *), void *d) const |
|
value_type | find (const T *a) const |
|
reference | first () |
|
const_reference | first () const |
|
value_type | get () |
|
size_type | index (bool(*fn)(const T *, void *), void *d) const |
|
size_type | index (const T *a) const |
|
template<typename InputIterator > |
void | insert (iterator pos, InputIterator first, InputIterator last) |
|
void | insert (iterator pos, size_type n, value_type val) |
|
iterator | insert (iterator pos, value_type val) |
|
bool | insert (value_type a) |
|
void | insertAt (size_type i, value_type a) |
|
bool | isEmpty () const |
|
reference | last () |
|
const_reference | last () const |
|
reference | maxElement () |
|
const_reference | maxElement () const |
|
reference | minElement () |
|
const_reference | minElement () const |
|
size_type | occurrencesOf (bool(*fn)(const T *, void *), void *d) const |
|
size_type | occurrencesOf (const T *a) const |
|
reference | operator() (size_type i) |
|
const_reference | operator() (size_type i) const |
|
RWTPtrDlist< T, A > & | operator= (const container_type &rhs) |
|
RWTPtrDlist< T, A > & | operator= (const RWTPtrDlist< T, A > &rhs) |
|
RWTPtrDlist< T, A > & | operator= (container_type &&rhs) |
|
RWTPtrDlist< T, A > & | operator= (RWTPtrDlist< T, A > &&rhs) |
|
reference | operator[] (size_type i) |
|
const_reference | operator[] (size_type i) const |
|
void | prepend (value_type a) |
|
reverse_iterator | rbegin () |
|
const_reverse_iterator | rbegin () const |
|
value_type | remove (bool(*fn)(const T *, void *), void *d) |
|
value_type | remove (const T *a) |
|
size_type | removeAll (bool(*fn)(const T *, void *), void *d) |
|
size_type | removeAll (const T *a) |
|
value_type | removeAt (size_type i) |
|
value_type | removeFirst () |
|
value_type | removeLast () |
|
reverse_iterator | rend () |
|
const_reverse_iterator | rend () const |
|
size_type | replaceAll (bool(*fn)(const T *, void *), void *d, value_type newVal) |
|
size_type | replaceAll (const T *oldVal, value_type newVal) |
|
void | sort () |
|
container_type & | std () |
|
const container_type & | std () const |
|
void | swap (RWTPtrDlist< T, A > &rhs) |
|
|
(Note that these are not member symbols.)
|
template<class T , class A > |
RWFile & | operator<< (RWFile &strm, const RWTPtrDlist< T, A > &coll) |
|
template<class T , class A > |
RWvostream & | operator<< (RWvostream &strm, const RWTPtrDlist< T, A > &coll) |
|
template<class T , class A > |
RWFile & | operator>> (RWFile &strm, RWTPtrDlist< T, A > &coll) |
|
template<class T , class A > |
RWFile & | operator>> (RWFile &strm, RWTPtrDlist< T, A > *&p) |
|
template<class T , class A > |
RWvistream & | operator>> (RWvistream &strm, RWTPtrDlist< T, A > &coll) |
|
template<class T , class A > |
RWvistream & | operator>> (RWvistream &strm, RWTPtrDlist< T, A > *&p) |
|
template<class T, class A = std::allocator<T*>>
class RWTPtrDlist< T, A >
This class maintains a pointer-based collection of values, implemented as a doubly-linked list. Class T
is the type pointed to by the items in the collection. Class A
is an allocator of objects of class T
. For more information about using custom allocators, please see the Essential Tools Module User's Guide.
- Synopsis
#include <rw/tpdlist.h>
A pointer-based collection of values, implemented as a doubly-linked list.
Definition tpdlist.h:155
- See also
Classes RWTPtrDeque, RWTPtrSlist, and RWTPtrOrderedVector also provide a Rogue Wave pointer-based interface to C++ Standard Library sequence collections.
Class std::list<T*,A> is the C++ Standard Library collection that serves as the underlying implementation for this class.
- Persistence
- Isomorphic
- Example
In this example, a pointer-based doubly-linked list of user type Dog
is exercised.
#include <rw/tpdlist.h>
#include <iostream>
#include <string.h>
class Dog {
public:
Dog(const char* s) : name_(s) {}
Dog(const Dog& ref) : name_(ref.name_) {}
Dog& operator=(const Dog& ref) {
if (this == &ref) {
return *this;
}
name_ = ref.name_;
return *this;
}
bool operator==(const Dog& ref) const { return name_ == ref.name_; }
bool operator<(const Dog& ref) const { return name_ < ref.name_; }
friend std::ostream& operator<<(std::ostream& s, const Dog& ref) {
s << ref.name_;
return s;
}
};
int main() {
terriers.
insert(
new Dog(
"Cairn Terrier"));
terriers.
insert(
new Dog(
"Irish Terrier"));
terriers.
insert(
new Dog(
"Schnauzer"));
Dog key1("Schnauzer");
std::cout << "The list "
<< (terriers.
contains(&key1) ?
"does " :
"does not ")
<< "contain a Schnauzer\n";
Dog key2("Irish Terrier");
terriers.
insertAt(terriers.
index(&key2),
new Dog(
"Fox Terrier"));
Dog* d;
std::cout << *d << std::endl;
delete d;
}
return 0;
}
Offers powerful and convenient facilities for manipulating strings.
Definition stdcstring.h:826
size_type index(const T *a) const
bool contains(bool(*fn)(const T *, void *), void *d) const
Definition tpdlist.h:487
void insertAt(size_type i, value_type a)
Definition tpdlist.h:629
bool insert(value_type a)
Definition tpdlist.h:580
bool isEmpty() const
Definition tpdlist.h:402
value_type get()
Definition tpdlist.h:572
Program Output:
The list does contain a Schnauzer
Cairn Terrier
Fox Terrier
Irish Terrier
Schnauzer
template<class T , class A = std::allocator<T*>>
template<typename InputIterator >
Constructs a double-ended queue by copying elements from the range [first, last).
InputIterator
is an input iterator type that points to elements that are convertible to value_type objects.
template<class T , class A = std::allocator<T*>>
template<typename InputIterator >
void RWTPtrDlist< T, A >::assign |
( |
InputIterator | first, |
|
|
InputIterator | last ) |
|
inline |
Copies each element in the range [first, last) into self, replacing any existing items.
InputIterator
is an input iterator type that points to elements that are convertible to value_type objects.
- Note
- first and last must not be iterators into self.
template<class T , class A = std::allocator<T*>>
template<typename InputIterator >
Inserts the elements in the range [first, last) into self before the element at position pos.
InputIterator
is an input iterator type that points to elements that are convertible to value_type objects.
template<class T , class A = std::allocator<T*>>
Performs lexicographical comparison of lhs to rhs. Elements are dereferenced before being compared. Assumes that type T
has well-defined less-than semantics.
The return type is derived from the type being compared. If T
supports three-way comparison, the return type is decltype(t <=> t)
, where t is an instance of T
. Otherwise, the return type is std::weak_ordering
.
- Note
- If a compiler does not support rewritten expressions (i.e. before C++20), comparison operators are explicitly implemented to provide equivalent behavior.
template<class T , class A = std::allocator<T*>>
Performs lexicographical comparison of lhs to rhs. Elements are dereferenced before being compared. Assumes that type T
has well-defined less-than semantics.
The return type is derived from the type being compared. If T
supports three-way comparison, the return type is decltype(t <=> t)
, where t is an instance of T
. Otherwise, the return type is std::weak_ordering
.
- Note
- If a compiler does not support rewritten expressions (i.e. before C++20), comparison operators are explicitly implemented to provide equivalent behavior.
template<class T , class A = std::allocator<T*>>
Returns true
if lhs and rhs are equal. Otherwise, returns false
. Two collections are equal if they have the same number of entries, and iterating through both collections produces individual elements that, in turn, compare equal to each other. Elements are dereferenced before being compared.
- Note
- If a compiler does not support rewritten expressions (i.e. before C++20), equality operators are explicitly implemented to provide equivalent behavior.
template<class T , class A = std::allocator<T*>>
Returns true
if lhs and rhs are equal. Otherwise, returns false
. Two collections are equal if they have the same number of entries, and iterating through both collections produces individual elements that, in turn, compare equal to each other. Elements are dereferenced before being compared.
- Note
- If a compiler does not support rewritten expressions (i.e. before C++20), equality operators are explicitly implemented to provide equivalent behavior.