Library of Assembled Shared Sources
lass::stde::slist< T, Alloc > Class Template Reference

a single linked list, just like the one in SGI STL (and STLport ...) More...

#include <slist.h>

Inheritance diagram for lass::stde::slist< T, Alloc >:

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.
 
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<.
 
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.
 

Related Symbols

(Note that these are not member symbols.)

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)
 writes list to output stream.
 
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)
 reads list from stream.
 

Detailed Description

template<typename T, class Alloc = std::allocator<T>>
class lass::stde::slist< T, Alloc >

a single linked list, just like the one in SGI STL (and STLport ...)

Author
Bram de Greve [Bramz]

Definition at line 62 of file slist.h.

Constructor & Destructor Documentation

◆ slist() [1/4]

template<typename T, class Alloc>
lass::stde::slist< T, Alloc >::slist ( const Alloc & allocator = Alloc())
explicit

Creates an empty list, using the provided allocator.

Parameters
allocatorto be used as memory model, defaults to Alloc().

complexity: O(1)

Definition at line 82 of file slist.inl.

Referenced by clear(), merge(), merge(), prior(), slist(), splice(), splice(), splice(), splice_after(), splice_after(), splice_after(), and swap().

◆ slist() [2/4]

template<typename T, class Alloc>
lass::stde::slist< T, Alloc >::slist ( size_type n,
const T & value = T(),
const Alloc & allocator = Alloc() )
explicit

Creates an list with n elements - each of which is a copy of value - and an allocator.

Parameters
nis the number of copies of value to put in the list.
valuewill be used to copy construct all of the n elements of the list, defaults to T().
allocatorto be used as memory model, defaults to Alloc().

complexity: O(N) with N = n.

Definition at line 100 of file slist.inl.

References before_begin(), and insert_after().

◆ slist() [3/4]

template<typename T, class Alloc>
template<typename InputIterator>
lass::stde::slist< T, Alloc >::slist ( InputIterator first,
InputIterator last,
const Alloc & allocator = Alloc() )

creates a list with as elements a copy of a range, and an allocator.

Parameters
firstiterator to first element of range to be copied in list.
lastiterator to position after the last element to be copied in list. last must be forward reachable from first.
allocatorto be used as memory model, defaults to Alloc().

complexity: O(N) with N = std::distance(first, last).

Definition at line 120 of file slist.inl.

References before_begin(), and insert_after().

◆ slist() [4/4]

template<typename T, class Alloc>
lass::stde::slist< T, Alloc >::slist ( const slist< T, Alloc > & other)

copies an entire list and its elements and allocator.

Parameters
otherthe list to be copied

complexity: O(N) with N = other.size()

Definition at line 136 of file slist.inl.

References before_begin(), begin(), end(), get_allocator(), insert_after(), and slist().

◆ ~slist()

template<typename T, class Alloc>
lass::stde::slist< T, Alloc >::~slist ( )

destroys all elements and frees memory.

complexity: O(N) with N = this->size()

Definition at line 150 of file slist.inl.

Member Function Documentation

◆ operator=()

template<typename T, class Alloc>
slist< T, Alloc > & lass::stde::slist< T, Alloc >::operator= ( slist< T, Alloc > other)

replace *this by a copy of other.

Parameters
otherlist to be copied

complexity: O(N1) + O(N2) with N1 = this->size() and N2 = other.size().

Definition at line 167 of file slist.inl.

◆ assign() [1/2]

template<typename T, class Alloc>
void lass::stde::slist< T, Alloc >::assign ( size_type n,
const T & value = T() )

replace *this by a list with n copies of value

Parameters
nis the number of copies of value to put in the list.
valuewill be used to copy construct all of the n elements of the list.

complexity: O(N1) + O(N2) with N1 = this->size() and N2 = n.

Definition at line 202 of file slist.inl.

◆ get_allocator()

template<typename T, class Alloc>
slist< T, Alloc >::allocator_type lass::stde::slist< T, Alloc >::get_allocator ( ) const

returns the memory model of the list.

complexity: O(1)

Definition at line 216 of file slist.inl.

Referenced by clear(), slist(), and swap().

◆ begin() [1/2]

template<typename T, class Alloc>
slist< T, Alloc >::iterator lass::stde::slist< T, Alloc >::begin ( )

returns an iterator to the first element of the list.

complexity: O(1)

Definition at line 229 of file slist.inl.

Referenced by lass::stde::value_type< T, Alloc >::operator<(), lass::stde::value_type< T, Alloc >::operator==(), reverse(), and slist().

◆ begin() [2/2]

template<typename T, class Alloc>
slist< T, Alloc >::const_iterator lass::stde::slist< T, Alloc >::begin ( ) const

returns an iterator to the first element of the list.

complexity: O(1)

Definition at line 242 of file slist.inl.

◆ end() [1/2]

template<typename T, class Alloc>
slist< T, Alloc >::iterator lass::stde::slist< T, Alloc >::end ( )

returns an iterator for the position after the last element of the list.

complexity: O(1)

Definition at line 255 of file slist.inl.

Referenced by lass::stde::value_type< T, Alloc >::operator<(), lass::stde::value_type< T, Alloc >::operator==(), and slist().

◆ end() [2/2]

template<typename T, class Alloc>
slist< T, Alloc >::const_iterator lass::stde::slist< T, Alloc >::end ( ) const

returns an iterator for the position after the last element of the list.

complexity: O(1)

Definition at line 268 of file slist.inl.

◆ before_begin() [1/2]

template<typename T, class Alloc>
slist< T, Alloc >::iterator lass::stde::slist< T, Alloc >::before_begin ( )

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.

Referenced by prior(), prior(), slist(), slist(), and slist().

◆ before_begin() [2/2]

template<typename T, class Alloc>
slist< T, Alloc >::const_iterator lass::stde::slist< T, Alloc >::before_begin ( ) const

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.

◆ prior() [1/4]

template<typename T, class Alloc>
slist< T, Alloc >::iterator lass::stde::slist< T, Alloc >::prior ( iterator position) const

return the iterator that sits position and start searching for it from start.

Equivalent to this->prior(position, this->before_begin()).

Parameters
positionmust be valid in *this and should not be this->before_begin()

complexity: O(N) with N = std::distance(this->begin(), position)

Definition at line 318 of file slist.inl.

References before_begin(), prior(), and slist().

Referenced by erase(), erase(), insert(), insert(), insert(), prior(), prior(), splice(), splice(), and splice().

◆ prior() [2/4]

template<typename T, class Alloc>
slist< T, Alloc >::const_iterator lass::stde::slist< T, Alloc >::prior ( const_iterator position) const

return the iterator that sits position and start searching for it from start.

Equivalent to this->prior(position, this->before_begin()).

Parameters
positionmust be valid in *this and should not be this->before_begin()

complexity: O(N) with N = std::distance(this->begin(), position)

Definition at line 334 of file slist.inl.

References before_begin(), and prior().

◆ prior() [3/4]

template<typename T, class Alloc>
slist< T, Alloc >::iterator lass::stde::slist< T, Alloc >::prior ( iterator position,
iterator start ) const

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.

Parameters
positionmust be valid in *this and should not be this->before_begin()
startmust be a valid iterator in [this->begin(),position)

complexity: O(N) with N = std::distance(start, position)

Definition at line 353 of file slist.inl.

◆ prior() [4/4]

template<typename T, class Alloc>
slist< T, Alloc >::const_iterator lass::stde::slist< T, Alloc >::prior ( const_iterator position,
const_iterator start ) const

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.

Parameters
positionmust be valid in *this and should not be this->before_begin()
startmust be a valid iterator in [this->begin(),position)

complexity: O(N) with N = std::distance(start, position)

Definition at line 378 of file slist.inl.

◆ empty()

template<typename T, class Alloc>
bool lass::stde::slist< T, Alloc >::empty ( ) const

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.

◆ size()

template<typename T, class Alloc>
slist< T, Alloc >::size_type lass::stde::slist< T, Alloc >::size ( ) const

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.

Referenced by lass::stde::split().

◆ max_size()

template<typename T, class Alloc>
slist< T, Alloc >::size_type lass::stde::slist< T, Alloc >::max_size ( ) const

returns a very rough estimation on what's the maximum number of elements you can ever have in an slist.

Frankly, we don't know this number, so we return the highest number we know of =)

complexity: O(1)

Definition at line 432 of file slist.inl.

◆ resize()

template<typename T, class Alloc>
void lass::stde::slist< T, Alloc >::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.

Parameters
nthe size of the list after inserting or erasing elements.
valueif the list must grow, copies of value are inserted at the end. Defaults to T().

complexity: O(N) with N = n.

Definition at line 450 of file slist.inl.

References insert_after().

◆ front() [1/2]

template<typename T, class Alloc>
slist< T, Alloc >::reference lass::stde::slist< T, Alloc >::front ( )

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.

◆ front() [2/2]

template<typename T, class Alloc>
slist< T, Alloc >::const_reference lass::stde::slist< T, Alloc >::front ( ) const

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.

◆ push_front()

template<typename T, class Alloc>
void lass::stde::slist< T, Alloc >::push_front ( const T & value)

insert a copy of value at the front of the list so that the current list comes behind it.

Parameters
valueto be inserted at front

It's semantically equivalent to this->insert(this->begin(), value). All iterators stay valid.

complexity: O(1)

Definition at line 515 of file slist.inl.

◆ pop_front()

template<typename T, class Alloc>
void lass::stde::slist< T, Alloc >::pop_front ( )

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.

◆ insert() [1/3]

template<typename T, class Alloc>
slist< T, Alloc >::iterator lass::stde::slist< T, Alloc >::insert ( iterator position,
const T & value )

inserts a new element before iterator position and returns iterator to it.

Parameters
positionmust be valid in *this and should not be this->before_begin()
valueto be inserted
Warning
this operation is in linear time because it has to call prior(position). Try to use insert_after whenever you can.

All iterators stay valid.

complexity: O(N) with N = std::distance(this->begin(), position)

Definition at line 553 of file slist.inl.

References insert_after(), and prior().

◆ insert() [2/3]

template<typename T, class Alloc>
void lass::stde::slist< T, Alloc >::insert ( iterator position,
size_type n,
const T & value )

inserts n copies of value before iterator position.

Parameters
positionmust be valid in *this and should not be this->before_begin()
nnumber of copies to be inserted.
valueto be inserted
Warning
this operation is in linear time because it has to call prior(position). Try to use insert_after whenever you can.

All iterators stay valid.

complexity: O(N1) + O(N2) with N1 = std::distance(this->begin(), position) and N2 = n.

Definition at line 576 of file slist.inl.

References insert_after(), and prior().

◆ insert() [3/3]

template<typename T, class Alloc>
template<typename InputIterator>
void lass::stde::slist< T, Alloc >::insert ( iterator position,
InputIterator first,
InputIterator last )

inserts a copy of a range before iterator position.

Parameters
positionmust be valid in *this and should not be this->before_begin()
firstiterator to first element to be inserted.
lastiterator to position after last element to be insert. Must be forward reachable from first.
Warning
this operation is in linear time because it has to call prior(position). Try to use insert_after whenever you can.

All iterators stay valid.

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 insert_after(), and prior().

◆ insert_after() [1/3]

template<typename T, class Alloc>
slist< T, Alloc >::iterator lass::stde::slist< T, Alloc >::insert_after ( iterator position,
const T & value )

inserts a new element after iterator position and returns iterator to it.

Parameters
positionmust be valid in *this and should not be this->end()
valueto be inserted

All iterators stay valid.

complexity: O(1)

Definition at line 620 of file slist.inl.

Referenced by insert(), insert(), insert(), insert_after(), resize(), slist(), slist(), and slist().

◆ insert_after() [2/3]

template<typename T, class Alloc>
void lass::stde::slist< T, Alloc >::insert_after ( iterator position,
size_type n,
const T & value )

inserts n copies of value after iterator position.

Parameters
positionmust be valid in *this and should not be this->end()
nnumber of copies to be inserted.
valueto be inserted

All iterators stay valid.

complexity: O(N) with N = n.

Definition at line 640 of file slist.inl.

◆ insert_after() [3/3]

template<typename T, class Alloc>
template<typename InputIterator>
void lass::stde::slist< T, Alloc >::insert_after ( iterator position,
InputIterator first,
InputIterator last )

inserts a copy of a range before iterator position.

Parameters
positionmust be valid in *this and should not be this->end()
firstiterator to first element to be inserted.
lastiterator to position after last element to be insert. Must be forward reachable from first.

All iterators stay valid.

complexity: O(N) with N = std::distance(first, last).

Definition at line 666 of file slist.inl.

References insert_after().

◆ erase() [1/2]

template<typename T, class Alloc>
slist< T, Alloc >::iterator lass::stde::slist< T, Alloc >::erase ( iterator position)

removes element at iterator position from the list and return iterator to the next element.

Parameters
positionelement to be erased. Must be valid in *this and should not be this->before_begin() or this->end().
Warning
this operation is in linear time because it has to call prior(position). Try to use erase_after whenever you can.

All iterators except position stay valid.

complexity: O(N) with N = std::distance(this->begin(), position)

Definition at line 687 of file slist.inl.

References erase_after(), and prior().

◆ erase() [2/2]

template<typename T, class Alloc>
slist< T, Alloc >::iterator lass::stde::slist< T, Alloc >::erase ( iterator position,
iterator last )

removes element in range from the list and return iterator to the next element.

Parameters
positioniterator to first element to be erased. Must be valid in *this and should not be this->before_begin() or this->end().
lastiterator to position behind last element to be erased, must be valid in *this and forward reachable from position.
Warning
this operation is in linear time because it has to call prior(position). Try to use erase_after whenever you can.

All iterators except these in range [ position, last ) stay valid.

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 erase_after(), and prior().

◆ erase_after() [1/2]

template<typename T, class Alloc>
void lass::stde::slist< T, Alloc >::erase_after ( iterator position)

removes element after iterator position from the list.

Parameters
positioniterator to position before element to be erased, must be valid in *this, and should not be this->end()

All iterators except the one after position stay valid.

complexity: O(1)

Definition at line 732 of file slist.inl.

Referenced by erase(), erase(), and erase_after().

◆ erase_after() [2/2]

template<typename T, class Alloc>
void lass::stde::slist< T, Alloc >::erase_after ( iterator position,
iterator last )

removes element in range from the list and return iterator to the next element.

Parameters
positioniterator to position before first element to be erased. Must be valid in *this and should not be this->end()
lastiterator to position behind last element to be erased, must be valid in *this and forward reachable from position.

All iterators except these in range ( position, last ) stay valid.

complexity: O(N) with N = std::distance(position, last)

Definition at line 752 of file slist.inl.

References erase_after().

◆ swap()

template<typename T, class Alloc>
void lass::stde::slist< T, Alloc >::swap ( slist< T, Alloc > & other)

exchange all data between two lists.

All iterators stay valid.

complexity: O(1)

Definition at line 770 of file slist.inl.

References get_allocator(), and slist().

Referenced by clear(), and lass::stde::value_type< T, Alloc >::sort().

◆ clear()

template<typename T, class Alloc>
void lass::stde::slist< T, Alloc >::clear ( )

removes all elements from the list

complexity: O(N) with N = this->size()

Definition at line 783 of file slist.inl.

References get_allocator(), slist(), and swap().

◆ splice() [1/3]

template<typename T, class Alloc>
void lass::stde::slist< T, Alloc >::splice ( iterator position,
slist< T, Alloc > & other )

moves all elements from other to *this before position without copying, and clears other.

Parameters
positionmust be valid in *this and should not be this->before_begin()
othermust not be the same as *this (&other != this).
Warning
this operation is in linear time because it has to call prior(position). Try to use splice_after whenever you can.

All iterators stay valid.

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 prior(), slist(), and splice_after().

◆ splice() [2/3]

template<typename T, class Alloc>
void lass::stde::slist< T, Alloc >::splice ( iterator position,
slist< T, Alloc > & other,
iterator x )

moves x from other to *this before position without copying.

Parameters
positionmust be valid in *this and should not be this->before_begin()
othermay be the same as *this.
xmust be valid in other and should not be other.before_begin()
Warning
this operation is in linear time because it has to call prior(position) and prior(x). Try to use splice_after whenever you can.

All iterators stay valid.

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 prior(), slist(), and splice_after().

◆ splice() [3/3]

template<typename T, class Alloc>
void lass::stde::slist< T, Alloc >::splice ( iterator position,
slist< T, Alloc > & other,
iterator first,
iterator last )

moves [ first , last ) from other to *this before position without copying.

Parameters
positionmust be valid in *this and should not be this->before_begin(). position should not be an element of [ first , last ).
othermay be the same as *this.
firstmust be valid in other and should not be other.before_begin()
lastmust be valid in other and should be forward reachable from first.
Warning
this operation is in linear time because it has to call prior(position) and prior(x). Try to use splice_after whenever you can.

All iterators stay valid.

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 prior(), slist(), and splice_after().

◆ splice_after() [1/3]

template<typename T, class Alloc>
void lass::stde::slist< T, Alloc >::splice_after ( iterator position,
slist< T, Alloc > & other )

moves all elements from other to *this after position without copying, and clears other.

Parameters
positionmust be valid in *this and should not be this->end()
othermust not be the same as *this (&other != this).

All iterators stay valid.

complexity: O(N) with N = other.size()

Definition at line 876 of file slist.inl.

References slist(), and splice_after().

Referenced by merge(), splice(), splice(), splice(), splice_after(), splice_after(), and splice_after().

◆ splice_after() [2/3]

template<typename T, class Alloc>
void lass::stde::slist< T, Alloc >::splice_after ( iterator position,
slist< T, Alloc > & other,
iterator before_x )

moves element before before_x from other to *this after position without copying.

Parameters
positionmust be valid in *this and should not be this->end()
othermay be the same as *this.
before_xmust be valid in other and should not be other.end()

All iterators stay valid.

complexity: O(1)

Definition at line 900 of file slist.inl.

References slist(), and splice_after().

◆ splice_after() [3/3]

template<typename T, class Alloc>
void lass::stde::slist< T, Alloc >::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.

Parameters
positionmust be valid in *this and should not be this->end(). position should not be an element of ( before_first, before_last ].
othermay be the same as *this.
before_firstmust be valid in other and should not be other.end()
before_lastmust be valid in other and should be forward reachable from before_first.

All iterators stay valid.

complexity: O(1)

Definition at line 920 of file slist.inl.

References slist(), and splice_after().

◆ remove()

template<typename T, class Alloc>
void lass::stde::slist< T, Alloc >::remove ( const T & value)

removes all elements with iterarors i for which *i == value

Parameters
valuevalue of the elements that must be removed.

complexity: O(N) with N = this->size()

Definition at line 935 of file slist.inl.

◆ remove_if()

template<typename T, class Alloc>
template<class UnaryPredicate>
void lass::stde::slist< T, Alloc >::remove_if ( UnaryPredicate predicate)

removes all elements with iterarors i for which predicate(*i) yields true.

Parameters
predicateshould returns true for the elements that must be removed.

complexity: O(N) with N = this->size()

Definition at line 961 of file slist.inl.

◆ unique() [1/2]

template<typename T, class Alloc>
void lass::stde::slist< T, Alloc >::unique ( )

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.

◆ unique() [2/2]

template<typename T, class Alloc>
template<class BinaryPredicate>
void lass::stde::slist< T, Alloc >::unique ( BinaryPredicate predicate)

removes all but the first element in every consecutive group of equivalent elements by a predicate.

Parameters
predicatetwo elements *i and *j are considered equivalent if predicate(*i, *j) is true.

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 1021 of file slist.inl.

◆ merge() [1/2]

template<typename T, class Alloc>
void lass::stde::slist< T, Alloc >::merge ( slist< T, Alloc > & other)

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.

Parameters
otherthe other sorted slist

complexity: O(N1) + O(N2) with N1 = this->size() and N2 = other.size()

Definition at line 1056 of file slist.inl.

References merge(), and slist().

Referenced by merge(), and lass::stde::value_type< T, Alloc >::sort().

◆ merge() [2/2]

template<typename T, class Alloc>
template<class BinaryPredicate>
void lass::stde::slist< T, Alloc >::merge ( slist< T, Alloc > & other,
BinaryPredicate compare )

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.

Parameters
otherthe other sorted slist
comparemust define strict weak ordening. Both containers must be sorted by this predicate.

complexity: O(N1) + O(N2) with N1 = this->size() and N2 = other.size()

Definition at line 1079 of file slist.inl.

References slist(), and splice_after().

◆ sort() [1/2]

template<typename T, class Alloc>
void lass::stde::slist< T, Alloc >::sort ( )

Sorts *this according to operator<.

The sort is stable, that is, the relative order of equivalent elements is preserved. All iterators remain valid and continue to point to the same elements.

complexity: O(N log N) with N = this->size()

Definition at line 1108 of file slist.inl.

References sort().

Referenced by sort().

◆ reverse()

template<typename T, class Alloc>
void lass::stde::slist< T, Alloc >::reverse ( )

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 begin().

Referenced by lass::stde::value_type< T, Alloc >::operator>>().

◆ assign() [2/2]

template<typename T, class Alloc = std::allocator<T>>
template<typename ForwardIterator>
void lass::stde::slist< T, Alloc >::assign ( ForwardIterator first,
ForwardIterator last )

replace *this by a list copied from a range.

Parameters
firstiterator to first element of range to be copied in list.
lastiterator to position after the last element to be copied in list. last must be forward reachable from first.

complexity: O(N1) + O(N2) with N1 = this->size() and N2 = std::distance(first, last).

Definition at line 186 of file slist.inl.

◆ sort() [2/2]

template<typename T, class Alloc = std::allocator<T>>
template<class BinaryPredicate>
void lass::stde::slist< T, Alloc >::sort ( BinaryPredicate compare)

Sorts *this according to compare.

Parameters
comparemust define strict weak ordening. Both containers must be sorted by this predicate.

The sort is stable, that is, the relative order of equivalent elements is preserved. All iterators remain valid and continue to point to the same elements.

complexity: O(N log N) with N = this->size()

Definition at line 1131 of file slist.inl.

Friends And Related Symbol Documentation

◆ operator==()

template<typename T, class Alloc>
bool operator== ( const slist< T, Alloc > & a,
const slist< T, Alloc > & b )
related

returns wether a and b are lexicographical idential.

Parameters
afirst slist
bsecond slist

returns true if a.size() == b.size() and each element of is considered equal to its corresponding element in b by using operator==

@complexity O(N) with N = a.size() == b.size() ? a.size() : 1

Definition at line 1305 of file slist.inl.

◆ operator!=()

template<typename T, class Alloc>
bool operator!= ( const slist< T, Alloc > & a,
const slist< T, Alloc > & b )
related

returns wether a and b are not lexicographical idential.

Parameters
afirst slist
bsecond slist

Is equivalent to !(a == b)

@complexity O(N) with N = a.size() == b.size() ? a.size() : 1

Definition at line 1337 of file slist.inl.

◆ operator<()

template<typename T, class Alloc>
bool operator< ( const slist< T, Alloc > & a,
const slist< T, Alloc > & b )
related

returns wether a is lexicographical less than b.

Parameters
afirst slist
bsecond slist

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()

@complexity O(N) with N = std::min(a.size(), b.size())

Definition at line 1357 of file slist.inl.

◆ operator>()

template<typename T, class Alloc>
bool operator> ( const slist< T, Alloc > & a,
const slist< T, Alloc > & b )
related

returns wether b is lexicographical less than a.

Parameters
afirst slist
bsecond slist

Is equivalent to (b < a)

@complexity O(N) with N = std::min(a.size(), b.size())

Definition at line 1389 of file slist.inl.

◆ operator<=()

template<typename T, class Alloc>
bool operator<= ( const slist< T, Alloc > & a,
const slist< T, Alloc > & b )
related

returns wether a is lexicographical less or equal to b.

Parameters
afirst slist
bsecond slist

Is equivalent to !(b < a)

@complexity O(N) with N = std::min(a.size(), b.size())

Definition at line 1407 of file slist.inl.

◆ operator>=()

template<typename T, class Alloc>
bool operator>= ( const slist< T, Alloc > & a,
const slist< T, Alloc > & b )
related

returns wether b is lexicographical less or equal to a.

Parameters
afirst slist
bsecond slist

Is equivalent to !(a < b)

@complexity O(N) with N = std::min(a.size(), b.size())

Definition at line 1425 of file slist.inl.

◆ operator<<()

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 )
related

writes list to output stream.

Parameters
ostreamshould be a good stream.
containerslist to be written as [foo, bar, spam, ham]

complexity: O(N) with N = container.size()

Definition at line 1425 of file slist.inl.

◆ operator>>()

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 )
related

reads list from stream.

Parameters
istreamshould be a good stream.
containerslist to be read as [foo, bar, spam, ham]

complexity: O(N) with N = number of elements to be read.

Definition at line 1461 of file slist.inl.


The documentation for this class was generated from the following files: