library of assembled shared sources |
http://lass.cocamware.com |
#include <slist.h>
Data Structures | |
class | const_iterator |
class | iterator |
struct | node_base_t |
struct | node_t |
Public Types | |
typedef Alloc::template rebind < T >::other | allocator_type |
typedef T | value_type |
typedef allocator_type::pointer | pointer |
typedef allocator_type::const_pointer | const_pointer |
typedef allocator_type::reference | reference |
typedef allocator_type::const_reference | const_reference |
typedef allocator_type::size_type | size_type |
typedef allocator_type::difference_type | difference_type |
Public Member Functions | |
slist (const Alloc &allocator=Alloc()) | |
Creates an empty list, using the provided allocator. | |
slist (size_type n, const T &value=T(), const Alloc &allocator=Alloc()) | |
Creates an list with n elements - each of which is a copy of value - and an allocator. | |
template<typename InputIterator > | |
slist (InputIterator first, InputIterator last, const Alloc &allocator=Alloc()) | |
creates a list with as elements a copy of a range, and an allocator. | |
slist (const slist< T, Alloc > &other) | |
copies an entire list and its elements and allocator. | |
~slist () | |
destroys all elements and frees memory. | |
slist< T, Alloc > & | operator= (slist< T, Alloc > other) |
replace *this by a copy of other. | |
template<typename InputIterator > | |
void | assign (InputIterator first, InputIterator last) |
void | assign (size_type n, const T &value=T()) |
replace *this by a list with n copies of value | |
allocator_type | get_allocator () const |
returns the memory model of the list. | |
iterator | begin () |
returns an iterator to the first element of the list. | |
const_iterator | begin () const |
returns an iterator to the first element of the list. | |
iterator | end () |
returns an iterator for the position after the last element of the list. | |
const_iterator | end () const |
returns an iterator for the position after the last element of the list. | |
iterator | before_begin () |
returns an iterator for the position before the first element of the list. | |
const_iterator | before_begin () const |
returns an iterator for the position before the first element of the list. | |
iterator | prior (iterator position) const |
return the iterator that sits position and start searching for it from start. | |
const_iterator | prior (const_iterator position) const |
return the iterator that sits position and start searching for it from start. | |
iterator | prior (iterator position, iterator start) const |
return the iterator that sits position and start searching for it from start. | |
const_iterator | prior (const_iterator position, const_iterator start) const |
return the iterator that sits position and start searching for it from start. | |
bool | empty () const |
returns wether the list is empty. | |
size_type | size () const |
returns the N, the number of elements in the list. | |
size_type | max_size () const |
returns a very rough estimation on what's the maximum number of elements you can ever have in an slist . | |
void | resize (size_type n, const T &value=T()) |
at the end of the list, inserts copies of value or erases elements so that list size is n. | |
reference | front () |
returns reference to first element in list. | |
const_reference | front () const |
returns reference to first element in list. | |
void | push_front (const T &value) |
insert a copy of value at the front of the list so that the current list comes behind it. | |
void | pop_front () |
erases the first element in the list. | |
iterator | insert (iterator position, const T &value) |
inserts a new element before iterator position and returns iterator to it. | |
void | insert (iterator position, size_type n, const T &value) |
inserts n copies of value before iterator position. | |
template<typename InputIterator > | |
void | insert (iterator position, InputIterator first, InputIterator last) |
inserts a copy of a range before iterator position. | |
iterator | insert_after (iterator position, const T &value) |
inserts a new element after iterator position and returns iterator to it. | |
void | insert_after (iterator position, size_type n, const T &value) |
inserts n copies of value after iterator position. | |
template<typename InputIterator > | |
void | insert_after (iterator position, InputIterator first, InputIterator last) |
inserts a copy of a range before iterator position. | |
iterator | erase (iterator position) |
removes element at iterator position from the list and return iterator to the next element. | |
iterator | erase (iterator position, iterator last) |
removes element in range from the list and return iterator to the next element. | |
void | erase_after (iterator position) |
removes element after iterator position from the list. | |
void | erase_after (iterator position, iterator last) |
removes element in range from the list and return iterator to the next element. | |
void | swap (slist< T, Alloc > &other) |
exchange all data between two lists. | |
void | clear () |
removes all elements from the list | |
void | splice (iterator position, slist< T, Alloc > &other) |
moves all elements from other to *this before position without copying, and clears other. | |
void | splice (iterator position, slist< T, Alloc > &other, iterator x) |
moves x from other to *this before position without copying. | |
void | splice (iterator position, slist< T, Alloc > &other, iterator first, iterator last) |
moves [ first , last ) from other to *this before position without copying. | |
void | splice_after (iterator position, slist< T, Alloc > &other) |
moves all elements from other to *this after position without copying, and clears other. | |
void | splice_after (iterator position, slist< T, Alloc > &other, iterator before_x) |
moves element before before_x from other to *this after position without copying. | |
void | splice_after (iterator position, slist< T, Alloc > &other, iterator before_first, iterator before_last) |
moves ( before_first, before_last ] from other to *this after position without copying. | |
void | remove (const T &value) |
removes all elements with iterarors i for which *i == value | |
template<class UnaryPredicate > | |
void | remove_if (UnaryPredicate predicate) |
removes all elements with iterarors i for which predicate(*i) yields true . | |
void | unique () |
removes all but the first element in every consecutive group of equal elements. | |
template<class BinaryPredicate > | |
void | unique (BinaryPredicate predicate) |
removes all but the first element in every consecutive group of equivalent elements by a predicate. | |
void | merge (slist< T, Alloc > &other) |
Merge two sorted containers to one big sorted. | |
template<class BinaryPredicate > | |
void | merge (slist< T, Alloc > &other, BinaryPredicate compare) |
Merge two by compare sorted containers to one big sorted. | |
void | sort () |
Sorts *this according to operator< . | |
template<class Compare > | |
void | sort (Compare compare) |
void | reverse () |
reverses the order of the elements. | |
template<typename ForwardIterator > | |
void | assign (ForwardIterator first, ForwardIterator last) |
replace *this by a list copied from a range. | |
template<class BinaryPredicate > | |
void | sort (BinaryPredicate compare) |
Sorts *this according to compare. | |
Private Types | |
typedef allocator_type::template rebind< node_t >::other | node_allocator_type |
Private Member Functions | |
node_t * | make_node (const T &value) const |
void | unlink_and_destroy_after (node_base_t *position) const |
void | link_after (node_base_t *position, node_base_t *node) const |
void | splice_after (node_base_t *position, node_base_t *before_first, node_base_t *before_last) const |
void | insert_after (iterator position, size_type n, const value_type &value, meta::Wrap< meta::True > parameter_is_integral) |
template<typename InputIterator > | |
void | insert_after (iterator position, InputIterator first, InputIterator last, meta::Wrap< meta::False > parameter_is_iterator) |
Private Attributes | |
node_base_t | head_ |
Friends | |
class | const_iterator |
class | iterator |
Related Functions | |
(Note that these are not member functions.) | |
template<typename T , class Alloc > | |
bool | operator== (const slist< T, Alloc > &a, const slist< T, Alloc > &b) |
returns wether a and b are lexicographical idential. | |
template<typename T , class Alloc > | |
bool | operator!= (const slist< T, Alloc > &a, const slist< T, Alloc > &b) |
returns wether a and b are not lexicographical idential. | |
template<typename T , class Alloc > | |
bool | operator< (const slist< T, Alloc > &a, const slist< T, Alloc > &b) |
returns wether a is lexicographical less than b. | |
template<typename T , class Alloc > | |
bool | operator> (const slist< T, Alloc > &a, const slist< T, Alloc > &b) |
returns wether b is lexicographical less than a. | |
template<typename T , class Alloc > | |
bool | operator<= (const slist< T, Alloc > &a, const slist< T, Alloc > &b) |
returns wether a is lexicographical less or equal to b. | |
template<typename T , class Alloc > | |
bool | operator>= (const slist< T, Alloc > &a, const slist< T, Alloc > &b) |
returns wether b is lexicographical less or equal to a. | |
template<typename T , class Alloc , typename Char , typename Traits > | |
std::basic_ostream< Char, Traits > & | operator<< (std::basic_ostream< Char, Traits > &ostream, const slist< T, Alloc > &container) |
template<typename T , class Alloc , typename Char , typename Traits > | |
std::basic_istream< Char, Traits > & | operator>> (std::basic_istream< Char, Traits > &istream, slist< T, Alloc > &container) |
..)
Definition at line 62 of file slist.h.
typedef Alloc::template rebind<T>::other lass::stde::slist< T, Alloc >::allocator_type |
typedef T lass::stde::slist< T, Alloc >::value_type |
typedef allocator_type::pointer lass::stde::slist< T, Alloc >::pointer |
typedef allocator_type::const_pointer lass::stde::slist< T, Alloc >::const_pointer |
typedef allocator_type::reference lass::stde::slist< T, Alloc >::reference |
typedef allocator_type::const_reference lass::stde::slist< T, Alloc >::const_reference |
typedef allocator_type::size_type lass::stde::slist< T, Alloc >::size_type |
typedef allocator_type::difference_type lass::stde::slist< T, Alloc >::difference_type |
typedef allocator_type::template rebind<node_t>::other lass::stde::slist< T, Alloc >::node_allocator_type [private] |
lass::stde::slist< T, Alloc >::slist | ( | const Alloc & | allocator = Alloc() |
) | [inline, explicit] |
Creates an empty list, using the provided allocator.
allocator | to be used as memory model, defaults to Alloc() . |
Definition at line 82 of file slist.inl.
References lass::stde::slist< T, Alloc >::head_, and lass::stde::slist< T, Alloc >::node_base_t::next.
lass::stde::slist< T, Alloc >::slist | ( | size_type | n, | |
const T & | value = T() , |
|||
const Alloc & | allocator = Alloc() | |||
) | [inline, explicit] |
Creates an list with n elements - each of which is a copy of value - and an allocator.
n | is the number of copies of value to put in the list. | |
value | will be used to copy construct all of the n elements of the list, defaults to T() . | |
allocator | to be used as memory model, defaults to Alloc() . |
Definition at line 100 of file slist.inl.
References lass::stde::slist< T, Alloc >::before_begin(), lass::stde::slist< T, Alloc >::head_, lass::stde::slist< T, Alloc >::insert_after(), and lass::stde::slist< T, Alloc >::node_base_t::next.
lass::stde::slist< T, Alloc >::slist | ( | InputIterator | first, | |
InputIterator | last, | |||
const Alloc & | allocator = Alloc() | |||
) | [inline] |
creates a list with as elements a copy of a range, and an allocator.
first | iterator to first element of range to be copied in list. | |
last | iterator to position after the last element to be copied in list. last must be forward reachable from first. | |
allocator | to be used as memory model, defaults to Alloc() . |
std::distance(first, last)
.
Definition at line 120 of file slist.inl.
References lass::stde::slist< T, Alloc >::before_begin(), lass::stde::slist< T, Alloc >::head_, lass::stde::slist< T, Alloc >::insert_after(), and lass::stde::slist< T, Alloc >::node_base_t::next.
lass::stde::slist< T, Alloc >::slist | ( | const slist< T, Alloc > & | other | ) | [inline] |
copies an entire list and its elements and allocator.
other | the list to be copied |
other.size()
Definition at line 136 of file slist.inl.
References lass::stde::slist< T, Alloc >::before_begin(), lass::stde::slist< T, Alloc >::begin(), lass::stde::slist< T, Alloc >::end(), lass::stde::slist< T, Alloc >::head_, lass::stde::slist< T, Alloc >::insert_after(), and lass::stde::slist< T, Alloc >::node_base_t::next.
lass::stde::slist< T, Alloc >::~slist | ( | ) | [inline] |
destroys all elements and frees memory.
complexity: O(N) with N = this->size()
Definition at line 150 of file slist.inl.
References lass::stde::slist< T, Alloc >::head_, lass::stde::slist< T, Alloc >::node_base_t::next, and lass::stde::slist< T, Alloc >::unlink_and_destroy_after().
slist< T, Alloc > & lass::stde::slist< T, Alloc >::operator= | ( | slist< T, Alloc > | other | ) | [inline] |
replace *this
by a copy of other.
other | list to be copied |
this->size()
and N2 = other.size()
.
Definition at line 167 of file slist.inl.
References lass::stde::slist< T, Alloc >::swap().
void lass::stde::slist< T, Alloc >::assign | ( | InputIterator | first, | |
InputIterator | last | |||
) | [inline] |
void lass::stde::slist< T, Alloc >::assign | ( | size_type | n, | |
const T & | value = T() | |||
) | [inline] |
replace *this
by a list with n copies of value
n | is the number of copies of value to put in the list. | |
value | will be used to copy construct all of the n elements of the list. |
this->size()
and N2 = n.
Definition at line 202 of file slist.inl.
References lass::stde::slist< T, Alloc >::get_allocator(), and lass::stde::slist< T, Alloc >::swap().
slist< T, Alloc >::allocator_type lass::stde::slist< T, Alloc >::get_allocator | ( | ) | const [inline] |
returns the memory model of the list.
complexity: O(1)
Definition at line 216 of file slist.inl.
Referenced by lass::stde::slist< T, Alloc >::assign(), lass::stde::slist< T, Alloc >::clear(), lass::stde::slist< T, Alloc >::make_node(), lass::stde::slist< T, Alloc >::swap(), and lass::stde::slist< T, Alloc >::unlink_and_destroy_after().
slist< T, Alloc >::iterator lass::stde::slist< T, Alloc >::begin | ( | ) | [inline] |
returns an iterator to the first element of the list.
complexity: O(1)
Definition at line 229 of file slist.inl.
References lass::stde::slist< T, Alloc >::head_, lass::stde::slist< T, Alloc >::iterator, and lass::stde::slist< T, Alloc >::node_base_t::next.
Referenced by lass::stde::slist< T, Alloc >::operator==(), lass::stde::slist< T, Alloc >::reverse(), and lass::stde::slist< T, Alloc >::slist().
slist< T, Alloc >::const_iterator lass::stde::slist< T, Alloc >::begin | ( | ) | const [inline] |
returns an iterator to the first element of the list.
complexity: O(1)
Definition at line 242 of file slist.inl.
References lass::stde::slist< T, Alloc >::const_iterator, lass::stde::slist< T, Alloc >::head_, and lass::stde::slist< T, Alloc >::node_base_t::next.
slist< T, Alloc >::iterator lass::stde::slist< T, Alloc >::end | ( | ) | [inline] |
returns an iterator for the position after the last element of the list.
complexity: O(1)
Definition at line 255 of file slist.inl.
References lass::stde::slist< T, Alloc >::iterator.
Referenced by lass::stde::slist< T, Alloc >::operator==(), and lass::stde::slist< T, Alloc >::slist().
slist< T, Alloc >::const_iterator lass::stde::slist< T, Alloc >::end | ( | ) | const [inline] |
returns an iterator for the position after the last element of the list.
complexity: O(1)
Definition at line 268 of file slist.inl.
References lass::stde::slist< T, Alloc >::const_iterator.
slist< T, Alloc >::iterator lass::stde::slist< T, Alloc >::before_begin | ( | ) | [inline] |
returns an iterator for the position before the first element of the list.
This iterator is not dereferencable! It's only an iterator for which the next one is this->begin()
. Use this one in methods like insert_after
and erase_after
when you want the method to affect on the first element in the list. Using begin()
would fail for this purpose the element after this->begin()
is already the second in the list.
complexity: O(1)
Definition at line 285 of file slist.inl.
References lass::stde::slist< T, Alloc >::head_, and lass::stde::slist< T, Alloc >::iterator.
Referenced by lass::stde::slist< T, Alloc >::prior(), and lass::stde::slist< T, Alloc >::slist().
slist< T, Alloc >::const_iterator lass::stde::slist< T, Alloc >::before_begin | ( | ) | const [inline] |
returns an iterator for the position before the first element of the list.
This iterator is not dereferencable! It's only an iterator for which the next one is this->begin()
. Use this one in methods like insert_after
and erase_after
when you want the method to affect on the first element in the list. Using begin()
would fail for this purpose the element after this->begin()
is already the second in the list.
complexity: O(1)
Definition at line 302 of file slist.inl.
References lass::stde::slist< T, Alloc >::const_iterator, and lass::stde::slist< T, Alloc >::head_.
slist< T, Alloc >::iterator lass::stde::slist< T, Alloc >::prior | ( | iterator | position | ) | const [inline] |
return the iterator that sits position and start searching for it from start.
Equivalent to this->prior(position, this->before_begin())
.
position | must be valid in *this and should not be this->before_begin() |
std::distance(this->begin(), position)
Definition at line 318 of file slist.inl.
References lass::stde::slist< T, Alloc >::before_begin().
Referenced by lass::stde::slist< T, Alloc >::erase(), lass::stde::slist< T, Alloc >::insert(), lass::stde::slist< T, Alloc >::prior(), and lass::stde::slist< T, Alloc >::splice().
slist< T, Alloc >::const_iterator lass::stde::slist< T, Alloc >::prior | ( | const_iterator | position | ) | const [inline] |
return the iterator that sits position and start searching for it from start.
Equivalent to this->prior(position, this->before_begin())
.
position | must be valid in *this and should not be this->before_begin() |
std::distance(this->begin(), position)
Definition at line 334 of file slist.inl.
References lass::stde::slist< T, Alloc >::before_begin(), and lass::stde::slist< T, Alloc >::prior().
slist< T, Alloc >::iterator lass::stde::slist< T, Alloc >::prior | ( | iterator | position, | |
iterator | start | |||
) | const [inline] |
return the iterator that sits position and start searching for it from start.
The method scans linearly all iterators from start until it find the one for which the next one is position. It returns the same result as std::prior(position)
would have returned if the iterator had support for the decrement operation.
position | must be valid in *this and should not be this->before_begin() | |
start | must be a valid iterator in [this->begin(),position) |
std::distance(start, position)
Definition at line 353 of file slist.inl.
References LASS_ASSERT, lass::stde::slist< T, Alloc >::node_base_t::next, and lass::stde::slist< T, Alloc >::iterator::node_.
slist< T, Alloc >::const_iterator lass::stde::slist< T, Alloc >::prior | ( | const_iterator | position, | |
const_iterator | start | |||
) | const [inline] |
return the iterator that sits position and start searching for it from start.
The method scans linearly all iterators from start until it find the one for which the next one is position. It returns the same result as std::prior(position)
would have returned if the iterator had support for the decrement operation.
position | must be valid in *this and should not be this->before_begin() | |
start | must be a valid iterator in [this->begin(),position) |
std::distance(start, position)
Definition at line 378 of file slist.inl.
References LASS_ASSERT, lass::stde::slist< T, Alloc >::node_base_t::next, and lass::stde::slist< T, Alloc >::const_iterator::node_.
bool lass::stde::slist< T, Alloc >::empty | ( | ) | const [inline] |
returns wether the list is empty.
Is semantically identical to this->size() == 0
, but it is a lot faster. So use it whenever you can ... even to do the dishes.
complexity: O(1)
Definition at line 398 of file slist.inl.
References lass::stde::slist< T, Alloc >::head_, and lass::stde::slist< T, Alloc >::node_base_t::next.
Referenced by lass::stde::slist< T, Alloc >::sort().
slist< T, Alloc >::size_type lass::stde::slist< T, Alloc >::size | ( | ) | const [inline] |
returns the N, the number of elements in the list.
complexity: O(N) with N = this->size()
.
Definition at line 411 of file slist.inl.
References lass::stde::slist< T, Alloc >::head_, and lass::stde::slist< T, Alloc >::node_base_t::next.
slist< T, Alloc >::size_type lass::stde::slist< T, Alloc >::max_size | ( | ) | const [inline] |
void lass::stde::slist< T, Alloc >::resize | ( | size_type | n, | |
const T & | value = T() | |||
) | [inline] |
at the end of the list, inserts copies of value or erases elements so that list size is n.
n | the size of the list after inserting or erasing elements. | |
value | if the list must grow, copies of value are inserted at the end. Defaults to T(). |
Definition at line 450 of file slist.inl.
References lass::stde::slist< T, Alloc >::head_, lass::stde::slist< T, Alloc >::insert_after(), lass::stde::slist< T, Alloc >::iterator, lass::stde::slist< T, Alloc >::node_base_t::next, and lass::stde::slist< T, Alloc >::unlink_and_destroy_after().
slist< T, Alloc >::reference lass::stde::slist< T, Alloc >::front | ( | ) | [inline] |
returns reference to first element in list.
*this
must not be empty. There's no check on wheter the first element exists. It's semantically equivalent to *this->begin()
complexity: O(1)
Definition at line 482 of file slist.inl.
References lass::stde::slist< T, Alloc >::head_, and lass::stde::slist< T, Alloc >::node_base_t::next.
slist< T, Alloc >::const_reference lass::stde::slist< T, Alloc >::front | ( | ) | const [inline] |
returns reference to first element in list.
*this
must not be empty. There's no check on wheter the first element exists. It's semantically equivalent to *this->begin()
complexity: O(1)
Definition at line 498 of file slist.inl.
References lass::stde::slist< T, Alloc >::head_, and lass::stde::slist< T, Alloc >::node_base_t::next.
void lass::stde::slist< T, Alloc >::push_front | ( | const T & | value | ) | [inline] |
insert a copy of value at the front of the list so that the current list comes behind it.
value | to be inserted at front |
this->insert(this->begin(), value)
. All iterators stay valid.complexity: O(1)
Definition at line 515 of file slist.inl.
References lass::stde::slist< T, Alloc >::head_, lass::stde::slist< T, Alloc >::make_node(), and lass::stde::slist< T, Alloc >::node_base_t::next.
void lass::stde::slist< T, Alloc >::pop_front | ( | ) | [inline] |
erases the first element in the list.
It's semantically equivalent to this->erase(this->begin())
. All iterators except this->begin()
stay valid.
complexity: O(1)
Definition at line 532 of file slist.inl.
References lass::stde::slist< T, Alloc >::head_, and lass::stde::slist< T, Alloc >::unlink_and_destroy_after().
slist< T, Alloc >::iterator lass::stde::slist< T, Alloc >::insert | ( | iterator | position, | |
const T & | value | |||
) | [inline] |
inserts a new element before iterator position and returns iterator to it.
position | must be valid in *this and should not be this->before_begin() | |
value | to be inserted |
prior(position)
. Try to use insert_after
whenever you can.
complexity: O(N) with N = std::distance(this->begin(), position)
Definition at line 553 of file slist.inl.
References lass::stde::slist< T, Alloc >::insert_after(), and lass::stde::slist< T, Alloc >::prior().
void lass::stde::slist< T, Alloc >::insert | ( | iterator | position, | |
size_type | n, | |||
const T & | value | |||
) | [inline] |
inserts n copies of value before iterator position.
position | must be valid in *this and should not be this->before_begin() | |
n | number of copies to be inserted. | |
value | to be inserted |
prior(position)
. Try to use insert_after
whenever you can.
complexity: O(N1) + O(N2) with N1 = std::distance(this->begin(), position)
and N2 = n.
Definition at line 576 of file slist.inl.
References lass::stde::slist< T, Alloc >::insert_after(), and lass::stde::slist< T, Alloc >::prior().
void lass::stde::slist< T, Alloc >::insert | ( | iterator | position, | |
InputIterator | first, | |||
InputIterator | last | |||
) | [inline] |
inserts a copy of a range before iterator position.
position | must be valid in *this and should not be this->before_begin() | |
first | iterator to first element to be inserted. | |
last | iterator to position after last element to be insert. Must be forward reachable from first. |
prior(position)
. Try to use insert_after
whenever you can.
complexity: O(N1) + O(N2) with N1 = std::distance(this->begin(), position)
and N2 = std::distance(first, last)
Definition at line 601 of file slist.inl.
References lass::stde::slist< T, Alloc >::insert_after(), and lass::stde::slist< T, Alloc >::prior().
slist< T, Alloc >::iterator lass::stde::slist< T, Alloc >::insert_after | ( | iterator | position, | |
const T & | value | |||
) | [inline] |
inserts a new element after iterator position and returns iterator to it.
position | must be valid in *this and should not be this->end() | |
value | to be inserted |
complexity: O(1)
Definition at line 620 of file slist.inl.
References lass::stde::slist< T, Alloc >::iterator, lass::stde::slist< T, Alloc >::link_after(), lass::stde::slist< T, Alloc >::make_node(), and lass::stde::slist< T, Alloc >::iterator::node_.
Referenced by lass::stde::slist< T, Alloc >::insert(), lass::stde::slist< T, Alloc >::insert_after(), lass::stde::slist< T, Alloc >::resize(), and lass::stde::slist< T, Alloc >::slist().
void lass::stde::slist< T, Alloc >::insert_after | ( | iterator | position, | |
size_type | n, | |||
const T & | value | |||
) | [inline] |
inserts n copies of value after iterator position.
position | must be valid in *this and should not be this->end() | |
n | number of copies to be inserted. | |
value | to be inserted |
complexity: O(N) with N = n.
Definition at line 640 of file slist.inl.
References lass::stde::slist< T, Alloc >::link_after(), lass::stde::slist< T, Alloc >::make_node(), and lass::stde::slist< T, Alloc >::iterator::node_.
void lass::stde::slist< T, Alloc >::insert_after | ( | iterator | position, | |
InputIterator | first, | |||
InputIterator | last | |||
) | [inline] |
inserts a copy of a range before iterator position.
position | must be valid in *this and should not be this->end() | |
first | iterator to first element to be inserted. | |
last | iterator to position after last element to be insert. Must be forward reachable from first. |
complexity: O(N) with N = std::distance(first, last)
.
Definition at line 666 of file slist.inl.
References lass::stde::slist< T, Alloc >::insert_after().
slist< T, Alloc >::iterator lass::stde::slist< T, Alloc >::erase | ( | iterator | position | ) | [inline] |
removes element at iterator position from the list and return iterator to the next element.
position | element to be erased. Must be valid in *this and should not be this->before_begin() or this->end() . |
prior(position)
. Try to use erase_after
whenever you can.
complexity: O(N) with N = std::distance(this->begin(), position)
Definition at line 687 of file slist.inl.
References lass::stde::slist< T, Alloc >::erase_after(), and lass::stde::slist< T, Alloc >::prior().
slist< T, Alloc >::iterator lass::stde::slist< T, Alloc >::erase | ( | iterator | position, | |
iterator | last | |||
) | [inline] |
removes element in range from the list and return iterator to the next element.
position | iterator to first element to be erased. Must be valid in *this and should not be this->before_begin() or this->end() . | |
last | iterator to position behind last element to be erased, must be valid in *this and forward reachable from position. |
prior(position)
. Try to use erase_after
whenever you can.
complexity: O(N1) + O(N2) with N1 = std::distance(this->begin(), position)
and N2 = std::distance(position, last)
Definition at line 713 of file slist.inl.
References lass::stde::slist< T, Alloc >::erase_after(), and lass::stde::slist< T, Alloc >::prior().
void lass::stde::slist< T, Alloc >::erase_after | ( | iterator | position | ) | [inline] |
removes element after iterator position from the list.
position | iterator to position before element to be erased, must be valid in *this , and should not be this->end() |
complexity: O(1)
Definition at line 732 of file slist.inl.
References LASS_ASSERT, lass::stde::slist< T, Alloc >::node_base_t::next, lass::stde::slist< T, Alloc >::iterator::node_, and lass::stde::slist< T, Alloc >::unlink_and_destroy_after().
Referenced by lass::stde::slist< T, Alloc >::erase(), and lass::stde::slist< T, Alloc >::erase_after().
void lass::stde::slist< T, Alloc >::erase_after | ( | iterator | position, | |
iterator | last | |||
) | [inline] |
removes element in range from the list and return iterator to the next element.
position | iterator to position before first element to be erased. Must be valid in *this and should not be this->end() | |
last | iterator to position behind last element to be erased, must be valid in *this and forward reachable from position. |
complexity: O(N) with N = std::distance(position, last)
Definition at line 752 of file slist.inl.
References lass::stde::slist< T, Alloc >::erase_after(), LASS_ASSERT, lass::stde::slist< T, Alloc >::node_base_t::next, and lass::stde::slist< T, Alloc >::iterator::node_.
void lass::stde::slist< T, Alloc >::swap | ( | slist< T, Alloc > & | other | ) | [inline] |
exchange all data between two lists.
All iterators stay valid.
complexity: O(1)
Definition at line 770 of file slist.inl.
References lass::stde::slist< T, Alloc >::get_allocator(), lass::stde::slist< T, Alloc >::head_, LASS_ASSERT, and lass::stde::slist< T, Alloc >::node_base_t::next.
Referenced by lass::stde::slist< T, Alloc >::assign(), lass::stde::slist< T, Alloc >::clear(), lass::stde::slist< T, Alloc >::operator=(), and lass::stde::slist< T, Alloc >::sort().
void lass::stde::slist< T, Alloc >::clear | ( | ) | [inline] |
removes all elements from the list
complexity: O(N) with N = this->size()
Definition at line 783 of file slist.inl.
References lass::stde::slist< T, Alloc >::get_allocator(), and lass::stde::slist< T, Alloc >::swap().
void lass::stde::slist< T, Alloc >::splice | ( | iterator | position, | |
slist< T, Alloc > & | other | |||
) | [inline] |
moves all elements from other to *this
before position without copying, and clears other.
position | must be valid in *this and should not be this->before_begin() | |
other | must not be the same as *this (&other != this ). |
prior(position)
. Try to use splice_after
whenever you can.
complexity: O(N1) + O(N2) with N1 = std::distance(this->begin(), position)
and N2 = other.size()
Definition at line 806 of file slist.inl.
References lass::stde::slist< T, Alloc >::prior(), and lass::stde::slist< T, Alloc >::splice_after().
void lass::stde::slist< T, Alloc >::splice | ( | iterator | position, | |
slist< T, Alloc > & | other, | |||
iterator | x | |||
) | [inline] |
moves x from other to *this
before position without copying.
position | must be valid in *this and should not be this->before_begin() | |
other | may be the same as *this . | |
x | must be valid in other and should not be other.before_begin() |
prior(position)
and prior(x)
. Try to use splice_after
whenever you can.
complexity: O(N1) + O(N2) with N1 = std::distance(this->begin(), position)
and N2 = std::distance(other.begin(), x)
Definition at line 829 of file slist.inl.
References lass::stde::slist< T, Alloc >::prior(), and lass::stde::slist< T, Alloc >::splice_after().
void lass::stde::slist< T, Alloc >::splice | ( | iterator | position, | |
slist< T, Alloc > & | other, | |||
iterator | first, | |||
iterator | last | |||
) | [inline] |
moves [ first , last ) from other to *this
before position without copying.
position | must be valid in *this and should not be this->before_begin() . position should not be an element of [ first , last ). | |
other | may be the same as *this . | |
first | must be valid in other and should not be other.before_begin() | |
last | must be valid in other and should be forward reachable from first. |
prior(position)
and prior(x)
. Try to use splice_after
whenever you can.
complexity: O(N1) + O(N2) with N1 = std::distance(this->begin(), position)
and N2 = std::distance(other.begin(), x)
Definition at line 855 of file slist.inl.
References lass::stde::slist< T, Alloc >::prior(), and lass::stde::slist< T, Alloc >::splice_after().
void lass::stde::slist< T, Alloc >::splice_after | ( | iterator | position, | |
slist< T, Alloc > & | other | |||
) | [inline] |
moves all elements from other to *this
after position without copying, and clears other.
position | must be valid in *this and should not be this->end() | |
other | must not be the same as *this (&other != this ). |
complexity: O(N) with N = other.size()
Definition at line 876 of file slist.inl.
References lass::stde::slist< T, Alloc >::head_, lass::stde::slist< T, Alloc >::node_base_t::next, and lass::stde::slist< T, Alloc >::iterator::node_.
Referenced by lass::stde::slist< T, Alloc >::merge(), lass::stde::slist< T, Alloc >::sort(), lass::stde::slist< T, Alloc >::splice(), and lass::stde::slist< T, Alloc >::splice_after().
void lass::stde::slist< T, Alloc >::splice_after | ( | iterator | position, | |
slist< T, Alloc > & | other, | |||
iterator | before_x | |||
) | [inline] |
moves element before before_x from other to *this
after position without copying.
position | must be valid in *this and should not be this->end() | |
other | may be the same as *this . | |
before_x | must be valid in other and should not be other.end() |
complexity: O(1)
Definition at line 900 of file slist.inl.
References lass::stde::slist< T, Alloc >::node_base_t::next, lass::stde::slist< T, Alloc >::iterator::node_, and lass::stde::slist< T, Alloc >::splice_after().
void lass::stde::slist< T, Alloc >::splice_after | ( | iterator | position, | |
slist< T, Alloc > & | other, | |||
iterator | before_first, | |||
iterator | before_last | |||
) | [inline] |
moves ( before_first, before_last ] from other to *this
after position without copying.
position | must be valid in *this and should not be this->end() . position should not be an element of ( before_first, before_last ]. | |
other | may be the same as *this . | |
before_first | must be valid in other and should not be other.end() | |
before_last | must be valid in other and should be forward reachable from before_first. |
complexity: O(1)
Definition at line 920 of file slist.inl.
References lass::stde::slist< T, Alloc >::iterator::node_, and lass::stde::slist< T, Alloc >::splice_after().
void lass::stde::slist< T, Alloc >::remove | ( | const T & | value | ) | [inline] |
removes all elements with iterarors i
for which *i == value
value | value of the elements that must be removed. |
this->size()
Definition at line 935 of file slist.inl.
References lass::stde::slist< T, Alloc >::head_, lass::stde::slist< T, Alloc >::node_base_t::next, and lass::stde::slist< T, Alloc >::unlink_and_destroy_after().
void lass::stde::slist< T, Alloc >::remove_if | ( | UnaryPredicate | predicate | ) | [inline] |
removes all elements with iterarors i
for which predicate(*i)
yields true
.
predicate | should returns true for the elements that must be removed. |
this->size()
Definition at line 961 of file slist.inl.
References lass::stde::slist< T, Alloc >::head_, lass::stde::slist< T, Alloc >::node_base_t::next, and lass::stde::slist< T, Alloc >::unlink_and_destroy_after().
void lass::stde::slist< T, Alloc >::unique | ( | ) | [inline] |
removes all but the first element in every consecutive group of equal elements.
The relative order of elements that are not removed is unchanged, and iterators to elements that are not removed remain valid.
complexity: O(N) with N = this->size()
Definition at line 987 of file slist.inl.
References lass::stde::slist< T, Alloc >::head_, lass::stde::slist< T, Alloc >::node_base_t::next, and lass::stde::slist< T, Alloc >::unlink_and_destroy_after().
void lass::stde::slist< T, Alloc >::unique | ( | BinaryPredicate | predicate | ) | [inline] |
removes all but the first element in every consecutive group of equivalent elements by a predicate.
predicate | two elements *i and *j are considered equivalent if predicate(*i, *j) is true. |
complexity: O(N) with N = this->size()
Definition at line 1021 of file slist.inl.
References lass::stde::slist< T, Alloc >::head_, lass::stde::slist< T, Alloc >::node_base_t::next, and lass::stde::slist< T, Alloc >::unlink_and_destroy_after().
void lass::stde::slist< T, Alloc >::merge | ( | slist< T, Alloc > & | other | ) | [inline] |
Merge two sorted containers to one big sorted.
Both *this
and other must be sorted according to operator<
, and they must be distinct (&other != this
). This function removes all of other's elements and inserts them in order into *this
. The merge is stable; that is, if an element from *this
is equivalent to one from other, then the element from *this
will precede the one from other. All iterators to elements in *this
and other remain valid.
other | the other sorted slist |
this->size()
and N2 = other.size()
Definition at line 1056 of file slist.inl.
Referenced by lass::stde::slist< T, Alloc >::sort().
void lass::stde::slist< T, Alloc >::merge | ( | slist< T, Alloc > & | other, | |
BinaryPredicate | compare | |||
) | [inline] |
Merge two by compare sorted containers to one big sorted.
Both *this
and other must be sorted according to compare, and they must be distinct (&other != this
). This function removes all of other's elements and inserts them in order into *this
. The merge is stable; that is, if an element from *this
is equivalent to one from other, then the element from *this
will precede the one from other. All iterators to elements in *this
and other remain valid.
other | the other sorted slist | |
compare | must define strict weak ordening. Both containers must be sorted by this predicate. |
this->size()
and N2 = other.size()
Definition at line 1079 of file slist.inl.
References lass::stde::slist< T, Alloc >::head_, lass::stde::slist< T, Alloc >::node_base_t::next, and lass::stde::slist< T, Alloc >::splice_after().
void lass::stde::slist< T, Alloc >::sort | ( | ) | [inline] |
void lass::stde::slist< T, Alloc >::sort | ( | Compare | compare | ) | [inline] |
void lass::stde::slist< T, Alloc >::reverse | ( | ) | [inline] |
reverses the order of the elements.
All iterators stay valid.
complexity: O(N) with N = this->size()
Definition at line 1171 of file slist.inl.
References lass::stde::slist< T, Alloc >::begin(), lass::stde::slist< T, Alloc >::head_, and lass::stde::slist< T, Alloc >::node_base_t::next.
slist< T, Alloc >::node_t * lass::stde::slist< T, Alloc >::make_node | ( | const T & | value | ) | const [inline, private] |
Definition at line 1194 of file slist.inl.
References lass::stde::slist< T, Alloc >::get_allocator(), lass::stde::slist< T, Alloc >::node_base_t::next, and lass::stde::slist< T, Alloc >::node_t::value.
Referenced by lass::stde::slist< T, Alloc >::insert_after(), and lass::stde::slist< T, Alloc >::push_front().
void lass::stde::slist< T, Alloc >::unlink_and_destroy_after | ( | node_base_t * | position | ) | const [inline, private] |
Definition at line 1218 of file slist.inl.
References lass::stde::slist< T, Alloc >::get_allocator(), LASS_ASSERT, and lass::stde::slist< T, Alloc >::node_base_t::next.
Referenced by lass::stde::slist< T, Alloc >::erase_after(), lass::stde::slist< T, Alloc >::pop_front(), lass::stde::slist< T, Alloc >::remove(), lass::stde::slist< T, Alloc >::remove_if(), lass::stde::slist< T, Alloc >::resize(), lass::stde::slist< T, Alloc >::unique(), and lass::stde::slist< T, Alloc >::~slist().
void lass::stde::slist< T, Alloc >::link_after | ( | node_base_t * | position, | |
node_base_t * | node | |||
) | const [inline, private] |
Definition at line 1236 of file slist.inl.
References LASS_ASSERT, and lass::stde::slist< T, Alloc >::node_base_t::next.
Referenced by lass::stde::slist< T, Alloc >::insert_after().
void lass::stde::slist< T, Alloc >::splice_after | ( | node_base_t * | position, | |
node_base_t * | before_first, | |||
node_base_t * | before_last | |||
) | const [inline, private] |
Definition at line 1248 of file slist.inl.
References LASS_ASSERT, and lass::stde::slist< T, Alloc >::node_base_t::next.
void lass::stde::slist< T, Alloc >::insert_after | ( | iterator | position, | |
size_type | n, | |||
const value_type & | value, | |||
meta::Wrap< meta::True > | parameter_is_integral | |||
) | [inline, private] |
Definition at line 1266 of file slist.inl.
References lass::stde::slist< T, Alloc >::link_after(), lass::stde::slist< T, Alloc >::make_node(), and lass::stde::slist< T, Alloc >::iterator::node_.
void lass::stde::slist< T, Alloc >::insert_after | ( | iterator | position, | |
InputIterator | first, | |||
InputIterator | last, | |||
meta::Wrap< meta::False > | parameter_is_iterator | |||
) | [inline, private] |
Definition at line 1284 of file slist.inl.
References lass::stde::slist< T, Alloc >::link_after(), lass::stde::slist< T, Alloc >::make_node(), and lass::stde::slist< T, Alloc >::iterator::node_.
void lass::stde::slist< T, Alloc >::assign | ( | ForwardIterator | first, | |
ForwardIterator | last | |||
) | [inline] |
replace *this
by a list copied from a range.
first | iterator to first element of range to be copied in list. | |
last | iterator to position after the last element to be copied in list. last must be forward reachable from first. |
this->size()
and N2 = std::distance(first, last)
.
Definition at line 186 of file slist.inl.
References lass::stde::slist< T, Alloc >::get_allocator(), and lass::stde::slist< T, Alloc >::swap().
void lass::stde::slist< T, Alloc >::sort | ( | BinaryPredicate | compare | ) | [inline] |
Sorts *this
according to compare.
compare | must define strict weak ordening. Both containers must be sorted by this predicate. |
complexity: O(N log N) with N = this->size()
Definition at line 1131 of file slist.inl.
References lass::stde::slist< T, Alloc >::empty(), lass::stde::slist< T, Alloc >::head_, lass::stde::slist< T, Alloc >::merge(), lass::stde::slist< T, Alloc >::node_base_t::next, lass::stde::slist< T, Alloc >::splice_after(), and lass::stde::slist< T, Alloc >::swap().
friend class const_iterator [friend] |
Definition at line 87 of file slist.h.
Referenced by lass::stde::slist< T, Alloc >::before_begin(), lass::stde::slist< T, Alloc >::begin(), and lass::stde::slist< T, Alloc >::end().
friend class iterator [friend] |
Definition at line 89 of file slist.h.
Referenced by lass::stde::slist< T, Alloc >::before_begin(), lass::stde::slist< T, Alloc >::begin(), lass::stde::slist< T, Alloc >::end(), lass::stde::slist< T, Alloc >::insert_after(), and lass::stde::slist< T, Alloc >::resize().
bool operator== | ( | const slist< T, Alloc > & | a, | |
const slist< T, Alloc > & | b | |||
) | [related] |
returns wether a and b are lexicographical idential.
returns true if
a.size() == b.size()
and each element of is considered equal to its corresponding element in b by using operator==
O(N) with N = a.size() == b.size() ? a.size() : 1
Definition at line 1312 of file slist.inl.
References lass::stde::slist< T, Alloc >::begin(), and lass::stde::slist< T, Alloc >::end().
bool operator< | ( | const slist< T, Alloc > & | a, | |
const slist< T, Alloc > & | b | |||
) | [related] |
returns wether a is lexicographical less than b.
returns true if for the first difference between a and b the element of a is less than the corresponding one of b. In case no different elements between and b can be found, it returns true if
a.size() < b.size()
O(N) with N = std::min(a.size(), b.size())
std::basic_ostream< Char, Traits > & operator<< | ( | std::basic_ostream< Char, Traits > & | ostream, | |
const slist< T, Alloc > & | container | |||
) | [related] |
writes list to output stream.
ostream | should be a good stream. | |
container | slist to be written as [foo, bar, spam, ham] |
container.size()
Definition at line 1449 of file slist.inl.
References lass::stde::impl::print_sequence().
node_base_t lass::stde::slist< T, Alloc >::head_ [private] |
Definition at line 243 of file slist.h.
Referenced by lass::stde::slist< T, Alloc >::before_begin(), lass::stde::slist< T, Alloc >::begin(), lass::stde::slist< T, Alloc >::empty(), lass::stde::slist< T, Alloc >::front(), lass::stde::slist< T, Alloc >::merge(), lass::stde::slist< T, Alloc >::pop_front(), lass::stde::slist< T, Alloc >::push_front(), lass::stde::slist< T, Alloc >::remove(), lass::stde::slist< T, Alloc >::remove_if(), lass::stde::slist< T, Alloc >::resize(), lass::stde::slist< T, Alloc >::reverse(), lass::stde::slist< T, Alloc >::size(), lass::stde::slist< T, Alloc >::slist(), lass::stde::slist< T, Alloc >::sort(), lass::stde::slist< T, Alloc >::splice_after(), lass::stde::slist< T, Alloc >::swap(), lass::stde::slist< T, Alloc >::unique(), and lass::stde::slist< T, Alloc >::~slist().
Generated on Mon Nov 10 14:22:16 2008 for Library of Assembled Shared Sources by 1.5.7.1 |