SourcePro® 2023.1 |
SourcePro® API Reference Guide |
Maintains a collection of some type T implemented as a singly-linked list. More...
#include <rw/stdex/slist.h>
Public Types | |
typedef std::allocator_traits< A >::template rebind_alloc< node_type > | allocator_type |
typedef rw_slist_iterator_base< const T, const base_node_type, difference_type > | const_iterator |
typedef const value_type * | const_pointer |
typedef const value_type & | const_reference |
typedef std::allocator_traits< allocator_type >::difference_type | difference_type |
typedef rw_slist_iterator_base< T, base_node_type, difference_type > | iterator |
typedef value_type * | pointer |
typedef value_type & | reference |
typedef std::allocator_traits< allocator_type >::size_type | size_type |
typedef T | value_type |
Public Member Functions | |
rw_slist () | |
rw_slist (const rw_slist< T, A > &x) | |
rw_slist (rw_slist< T, A > &&x) | |
template<typename InputIterator > | |
rw_slist (InputIterator first, InputIterator last) | |
rw_slist (size_type n, const T &value) | |
~rw_slist () | |
template<typename InputIterator > | |
void | assign (InputIterator first, InputIterator last) |
reference | back () |
const_reference | back () const |
iterator | begin () |
const_iterator | begin () const |
const_iterator | cbegin () const |
const_iterator | cend () const |
void | clear () |
bool | empty () const |
iterator | end () |
const_iterator | end () const |
iterator | erase (const_iterator position) |
iterator | erase (const_iterator position, const_iterator last) |
reference | front () |
const_reference | front () const |
iterator | insert (iterator position, const T &x) |
iterator | insert (iterator position, T &&x) |
template<typename InputIterator > | |
iterator | insert (iterator position, InputIterator first, InputIterator last) |
iterator | insert (iterator position, size_type n, const T &value) |
size_type | max_size () const |
void | merge (rw_slist< T, A > &x) |
rw_slist< T, A > & | operator= (const rw_slist< T, A > &x) |
rw_slist< T, A > & | operator= (rw_slist< T, A > &&x) |
void | pop_front () |
void | push_back (const T &x) |
void | push_back (T &&x) |
void | push_front (const T &x) |
void | push_front (T &&x) |
void | remove (const T &value) |
void | reverse () |
size_type | size () const |
void | sort () |
void | splice (iterator position, rw_slist< T, A > &x) |
void | splice (iterator position, rw_slist< T, A > &x, iterator i) |
void | splice (iterator position, rw_slist< T, A > &x, iterator first, iterator last) |
void | swap (rw_slist< T, A > &x) |
void | unique () |
Related Functions | |
(Note that these are not member functions.) | |
template<typename T , typename A > | |
bool | operator!= (const rw_slist< T, A > &lhs, const rw_slist< T, A > &rhs) |
template<typename T , typename A > | |
bool | operator< (const rw_slist< T, A > &lhs, const rw_slist< T, A > &rhs) |
template<typename T , typename A > | |
bool | operator<= (const rw_slist< T, A > &lhs, const rw_slist< T, A > &rhs) |
template<typename T , typename A > | |
bool | operator== (const rw_slist< T, A > &lhs, const rw_slist< T, A > &rhs) |
template<typename T , typename A > | |
bool | operator> (const rw_slist< T, A > &lhs, const rw_slist< T, A > &rhs) |
template<typename T , typename A > | |
bool | operator>= (const rw_slist< T, A > &lhs, const rw_slist< T, A > &rhs) |
Class rw_slist 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 provides for iterators that reference its elements.
typedef std::allocator_traits<A>::template rebind_alloc<node_type> rw_slist< T, A >::allocator_type |
A type representing the allocator type for the container.
typedef rw_slist_iterator_base<const T, const base_node_type, difference_type> rw_slist< T, A >::const_iterator |
A type that provides a const
forward iterator over the elements in the container.
typedef const value_type* rw_slist< T, A >::const_pointer |
A type that provides a const
pointer to an element in the container.
typedef const value_type& rw_slist< T, A >::const_reference |
A type that provides a const
reference to an element in the container.
typedef std::allocator_traits<allocator_type>::difference_type rw_slist< T, A >::difference_type |
A signed integral type used to indicate the distance between two valid iterators on the same container.
typedef rw_slist_iterator_base<T, base_node_type, difference_type> rw_slist< T, A >::iterator |
A type that provides a forward iterator over the elements in the container.
typedef value_type* rw_slist< T, A >::pointer |
A type that provides a pointer to an element in the container.
typedef value_type& rw_slist< T, A >::reference |
A type that provides a reference to an element in the container.
typedef std::allocator_traits<allocator_type>::size_type rw_slist< T, A >::size_type |
An unsigned integral type used for counting the number of elements in the container.
typedef T rw_slist< T, A >::value_type |
A type representing the value stored in the container.
Constructs an empty rw_slist.
Constructs an rw_slist that is a copy of x. Each element from x is copied into self.
Move constructor. The constructed list takes ownership of the data owned by x.
rw_slist< T, A >::rw_slist | ( | InputIterator | first, |
InputIterator | last | ||
) |
Constructs an rw_slist containing a copy of each element in the range [first, last).
InputIterator
is an input iterator type that points to elements that are convertible to value_type objects.
Constructs an rw_slist containing n instances of value.
The destructor releases the memory used by the links.
|
inline |
Copies each element in the range [first, last) into self, replacing any existing elements.
InputIterator
is an input iterator type that points to elements that are convertible to value_type objects.
Returns a reference to the last element in self. If self is empty, the behavior is undefined.
|
inline |
Returns a const_reference to the last element in self. If self is empty, the behavior is undefined.
Returns an iterator referring to the first element in the container.
If the container is empty, returns end().
|
inline |
Returns an iterator referring to the first element in the container.
If the container is empty, returns end().
|
inline |
Returns an iterator referring to the first element in the container.
If the container is empty, returns cend().
|
inline |
Returns an iterator referring to the element after the last element in the container.
Dereferencing the iterator returned by this function results in undefined behavior.
|
inline |
Removes all elements from self.
|
inline |
Returns true
if self is empty.
Returns an iterator referring to the element after the last element in the container.
Dereferencing the iterator returned by this function results in undefined behavior.
|
inline |
Returns an iterator referring to the element after the last element in the container.
Dereferencing the iterator returned by this function results in undefined behavior.
iterator rw_slist< T, A >::erase | ( | const_iterator | position | ) |
Removes from self the element referenced by position. If position does not reference an actual element contained in self, the behavior is undefined. Returns an iterator referencing the location just after the erased element.
iterator rw_slist< T, A >::erase | ( | const_iterator | position, |
const_iterator | last | ||
) |
Removes from self the elements referenced by the range beginning at position and bounded by last. Returns an iterator referencing a position just after the last erased element. If position does not reference an element in self the behavior is undefined.
Returns a reference to the first element in self. If self is empty, the behavior is undefined.
|
inline |
Returns a const_reference to the first element in self. If self is empty, the behavior is undefined.
iterator rw_slist< T, A >::insert | ( | iterator | position, |
const T & | x | ||
) |
Inserts x just prior to the element referenced by position. Returns an iterator referencing the newly inserted element.
iterator rw_slist< T, A >::insert | ( | iterator | position, |
T && | x | ||
) |
Inserts x just prior to the element referenced by position. Returns an iterator referencing the newly inserted element.
iterator rw_slist< T, A >::insert | ( | iterator | position, |
InputIterator | first, | ||
InputIterator | last | ||
) |
Inserts a copy of each element in the range [first, last) into self just prior to the element referenced by position. Returns an iterator referencing the first newly inserted element.
InputIterator
is an input iterator type that points to elements that are convertible to value_type objects.
iterator rw_slist< T, A >::insert | ( | iterator | position, |
size_type | n, | ||
const T & | value | ||
) |
Inserts n copies of value into self prior to the element referenced by position. Returns an iterator to the first of the newly inserted elements.
|
inline |
Returns the maximum number of elements the container could hold.
void rw_slist< T, A >::merge | ( | rw_slist< T, A > & | x | ) |
Assuming both x and self are sorted, moves every element from x into self, leaving x empty, and self sorted. If either list is unsorted, the move takes place, but the result may not be sorted. This method does not copy or destroy the elements in x, but re-links list nodes into self.
|
inline |
Copy assignment. Constructs an rw_slist containing a copy of each element in x.
|
inline |
Move assignment. Self takes ownership of the data owned by x.
|
inline |
Erases the first element of self. If self is empty, the behavior is undefined.
|
inline |
Inserts x as the last element of the list.
|
inline |
Inserts x as the last element of the list.
|
inline |
Inserts x as the first element of the list.
|
inline |
Inserts x as the first element of the list.
void rw_slist< T, A >::remove | ( | const T & | value | ) |
Removes all elements in self that compare equal (T::operator==()
or equivalent) to value.
void rw_slist< T, A >::reverse | ( | ) |
Reverses the order of the nodes containing the elements in self.
|
inline |
Returns the number of elements 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 elements exchanged during the sort, but adjusts the order of the links in the list.
void rw_slist< T, A >::splice | ( | iterator | position, |
rw_slist< T, A > & | x | ||
) |
Inserts the entire contents of x into self, just before the element referenced by position, leaving x empty. This method does not copy or destroy any of the elements moved, but re-links the list nodes from x into self.
void rw_slist< T, A >::splice | ( | iterator | position, |
rw_slist< T, A > & | x, | ||
iterator | i | ||
) |
Inserts the element referenced by i into self, just before the element referenced by position. The element referenced by i is removed from x. This method does not copy or destroy the element moved, but re-links the node from x into self. If i is not an iterator into x, the behavior is undefined.
void rw_slist< T, A >::splice | ( | iterator | position, |
rw_slist< T, A > & | x, | ||
iterator | first, | ||
iterator | last | ||
) |
Inserts the elements in the range [first, last) just before the element referenced by position. The elements in the range [first, last) are removed from x. This method does not copy or destroy any of the elements moved, but re-links the list nodes from x into self. If i is not an iterator into x, the behavior is undefined.
Exchanges the contents of self with x, retaining the ordering of each. This method does not copy or destroy any of the elements 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.
|
related |
Equivalent to !(lhs == rhs)
.
|
related |
Returns the result of calling:
|
related |
Equivalent to !(rhs < lhs)
.
|
related |
Returns true if lhs and rhs have the same number of elements and each element of rhs tests equal (T::operator==()
or equivalent) to the corresponding element of lhs.
|
related |
Equivalent to (rhs < lhs)
.
Copyright © 2023 Rogue Wave Software, Inc., a Perforce company. All Rights Reserved. |