SourcePro C++ 12.0 |
SourcePro® C++ API Reference Guide |
SourcePro C++ Documentation Home |
Maintains a collection of some type A implemented as a singly-linked list. More...
#include <rw/stdex/slist.h>
Inherited by rw_internal_slist< T, A >.
Public Types | |
typedef T | value_type |
typedef T & | reference |
typedef const T & | const_reference |
typedef allocator_type::size_type | size_type |
typedef Iterator | iterator |
typedef ConstIterator | const_iterator |
Public Member Functions | |
rw_slist () | |
rw_slist (const rw_slist< T, A > &list) | |
rw_slist (rw_slist< T, A > &&list) | |
rw_slist (ConstIterator first, ConstIterator bound) | |
rw_slist (const T *first, const T *end) | |
~rw_slist () | |
rw_slist< T, A > & | operator= (const rw_slist< T, A > &list) |
rw_slist< T, A > & | operator= (rw_slist< T, A > &&list) |
void | swap (rw_slist< T, A > &other) |
iterator | begin () |
const_iterator | begin () const |
iterator | end () |
const_iterator | end () const |
bool | empty () const |
size_type | size () const |
T & | front () |
const T & | front () const |
void | push_front (const T &item) |
void | push_front (T &&item) |
void | push_back (const T &item) |
void | push_back (T &&item) |
iterator | insert (iterator loc, const T &val) |
iterator | insert (iterator loc, T &&val) |
void | insert (iterator loc, const_iterator first, const_iterator bound) |
void | insert (iterator loc, const T *first, const T *bound) |
void | pop_front () |
iterator | erase (iterator iter) |
iterator | erase (iterator first, iterator bound) |
void | splice (iterator to, rw_slist< T, A > &donor) |
void | splice (iterator to, rw_slist< T, A > &donor, iterator from) |
void | splice (iterator to, rw_slist< T, A > &donor, iterator from_start, iterator from_bound) |
void | unique () |
void | merge (rw_slist< T, A > &donor) |
void | reverse () |
void | sort () |
Related Functions | |
(Note that these are not member functions.) | |
template<class T , class A > | |
bool | operator== (const rw_slist< T, A > &lhs, const rw_slist< T, A > &rhs) |
template<class T , class A > | |
bool | operator< (const rw_slist< T, A > &lhs, const rw_slist< T, A > &rhs) |
Class rw_slist<T,A> maintains a collection of T
, implemented as a singly-linked list. Since this is a value-based list, objects are copied into and out of the links that make up the list. As with all classes that meet the ANSI sequence specification, rw_slist<T,A> provides for iterators that reference its elements. Operations that alter the contents of rw_slist<T,A> invalidate iterators that reference items at or after the location of change.
#include <rw/stdex/slist.h> rw_slist<T,A=std::allocator<T> >;
typedef ConstIterator rw_slist< T, A >::const_iterator |
typedef const T& rw_slist< T, A >::const_reference |
Typedef for a const reference to a value in this container.
Typedef for a non-const reference to a value in this container.
typedef allocator_type::size_type rw_slist< T, A >::size_type |
Typedef for the type used to index into this container.
typedef T rw_slist< T, A >::value_type |
Typedef for the type of elements in this container.
Constructs an empty rw_slist<T,A> .
rw_slist< T, A >::rw_slist | ( | const rw_slist< T, A > & | list | ) |
Constructs an rw_slist<T,A> that is a copy of list. Each element from list is copied into self.
rw_slist< T, A >::rw_slist | ( | rw_slist< T, A > && | list | ) |
Move constructor. The constructed list takes ownership of the data owned by list.
rw_slist< T, A >::rw_slist | ( | ConstIterator | first, | |
ConstIterator | bound | |||
) |
Constructs an rw_slist<T,A> containing a copy of each element referenced by the range starting at first and bounded by bound.
rw_slist< T, A >::rw_slist | ( | const T * | first, | |
const T * | end | |||
) |
Constructs an rw_slist<T,A> containing a copy of each element referenced by the range starting at first and bounded by bound.
The destructor releases the memory used by the links.
const_iterator rw_slist< T, A >::begin | ( | ) | const [inline] |
The iterator returned references the first item in self. If self is empty, the iterator is equal to end().
The iterator returned references the first item in self. If self is empty, the iterator is equal to end().
bool rw_slist< T, A >::empty | ( | ) | const [inline] |
Returns true
if self is empty.
const_iterator rw_slist< T, A >::end | ( | ) | const [inline] |
The iterator returned marks the location "off the end" of self. It cannot be dereferenced.
The iterator returned marks the location "off the end" of self. It cannot be dereferenced.
iterator rw_slist< T, A >::erase | ( | iterator | first, | |
iterator | bound | |||
) |
Removes from self the elements referenced by the range beginning at first and bounded by bound. Returns an iterator referencing a position just after the last erased item. If first does not reference an item in self (and if first and bound are not equal), the effect is undefined.
iterator rw_slist< T, A >::erase | ( | iterator | iter | ) |
Removes from self the element referenced by iter. If iter does not reference an actual item contained in self, the effect is undefined. Returns an iterator referencing the location just after the erased item.
const T& rw_slist< T, A >::front | ( | ) | const [inline] |
References the first item in the list as an L-value. If self is empty, the behavior is undefined.
T& rw_slist< T, A >::front | ( | void | ) | [inline] |
References the first item in the list as an L-value. If self is empty, the behavior is undefined.
void rw_slist< T, A >::insert | ( | iterator | loc, | |
const T * | first, | |||
const T * | bound | |||
) |
Inserts a copy of each item in the range beginning at first and bounded by bound into self just prior to the place referenced by loc. Returns an iterator referencing the last newly inserted element.
++(list.insert(loc, first, bound)) == loc
void rw_slist< T, A >::insert | ( | iterator | loc, | |
const_iterator | first, | |||
const_iterator | bound | |||
) |
Inserts a copy of each item in the range beginning at first and bounded by bound into self just prior to the place referenced by loc. Returns an iterator referencing the last newly inserted element.
++(list.insert(loc, first, bound)) == loc
iterator rw_slist< T, A >::insert | ( | iterator | loc, | |
T && | val | |||
) |
Inserts val just prior to the place referenced by loc. Returns an iterator referencing the newly inserted element.
++(list.insert(loc,val)) == loc
iterator rw_slist< T, A >::insert | ( | iterator | loc, | |
const T & | val | |||
) |
Inserts val just prior to the place referenced by loc. Returns an iterator referencing the newly inserted element.
++(list.insert(loc,val)) == loc
void rw_slist< T, A >::merge | ( | rw_slist< T, A > & | donor | ) |
Assuming both donor and self are sorted, moves every item from donor into self, leaving donor empty, and self sorted. If either list is unsorted, the move will take place, but the result may not be sorted. This method does not copy or destroy the items in donor, but re-links list nodes into self.
rw_slist<T,A>& rw_slist< T, A >::operator= | ( | rw_slist< T, A > && | list | ) |
Move assignment. Self takes ownership of the data owned by list.
rw_slist<T,A>& rw_slist< T, A >::operator= | ( | const rw_slist< T, A > & | list | ) |
Copy assignment. Constructs an rw_slist<T,A> containing a copy of each element in list.
void rw_slist< T, A >::pop_front | ( | ) | [inline] |
Erases the first element of self. If self is empty, the effect is undefined.
void rw_slist< T, A >::push_back | ( | T && | item | ) | [inline] |
Inserts item as the last element of the list.
void rw_slist< T, A >::push_back | ( | const T & | item | ) | [inline] |
Inserts item as the last element of the list.
void rw_slist< T, A >::push_front | ( | T && | item | ) | [inline] |
Inserts item as the first element of the list.
void rw_slist< T, A >::push_front | ( | const T & | item | ) | [inline] |
Inserts item as the first element of the list.
void rw_slist< T, A >::reverse | ( | ) |
Reverses the order of the nodes containing the elements in self.
size_type rw_slist< T, A >::size | ( | ) | const [inline] |
Returns the number of items currently held in self.
void rw_slist< T, A >::sort | ( | ) |
Sorts self according to T::operator<(T)
or equivalent. Runs in time proportional to N
log(N)
, where N
is the number of elements. This method does not copy or destroy any of the items exchanged during the sort, but adjusts the order of the links in the list.
void rw_slist< T, A >::splice | ( | iterator | to, | |
rw_slist< T, A > & | donor, | |||
iterator | from_start, | |||
iterator | from_bound | |||
) |
Removes from donor and inserts into self just before location to, the items referenced by the range beginning with from_start and bounded by from_bound. If that range does not refer to items contained by donor, the effect is undefined. This method does not copy or destroy the items referenced by the range, but re-links those list nodes from donor into self.
void rw_slist< T, A >::splice | ( | iterator | to, | |
rw_slist< T, A > & | donor, | |||
iterator | from | |||
) |
Removes from donor and inserts into self, just before location to, the item referenced by from. If from does not reference an actual item contained in donor the effect is undefined. This method does not copy or destroy the item referenced by from, but re-links the node containing it from donor into self.
void rw_slist< T, A >::splice | ( | iterator | to, | |
rw_slist< T, A > & | donor | |||
) | [inline] |
Inserts the entire contents of donor into self, just before the position referenced by to, leaving donor empty. This method does not copy or destroy any of the items moved, but re-links the list nodes from donor into self.
void rw_slist< T, A >::swap | ( | rw_slist< T, A > & | other | ) |
Exchanges the contents of self with other, retaining the ordering of each. This method does not copy or destroy any of the items exchanged, but re-links the lists.
void rw_slist< T, A >::unique | ( | ) |
Removes from self all but the first element from each equal range. A precondition is that any duplicate elements are adjacent.
bool operator< | ( | const rw_slist< T, A > & | lhs, | |
const rw_slist< T, A > & | rhs | |||
) | [related] |
Returns the result of calling:
lexicographical_compare(lhs.begin(), lhs.end(), rhs.begin(), rhs.end());
© Copyright Rogue Wave Software, Inc. All Rights Reserved.
Rogue Wave and SourcePro are registered trademarks of Rogue Wave Software, 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.