library of assembled shared sources

http://lass.cocamware.com

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>

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

Collaboration graph
[legend]

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

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.


Member Typedef Documentation

template<typename T , class Alloc = std::allocator<T>>
typedef Alloc::template rebind<T>::other lass::stde::slist< T, Alloc >::allocator_type

Definition at line 78 of file slist.h.

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

Definition at line 79 of file slist.h.

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

Definition at line 80 of file slist.h.

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

Definition at line 81 of file slist.h.

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

Definition at line 82 of file slist.h.

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

Definition at line 83 of file slist.h.

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

Definition at line 84 of file slist.h.

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

Definition at line 85 of file slist.h.

template<typename T , class Alloc = std::allocator<T>>
typedef allocator_type::template rebind<node_t>::other lass::stde::slist< T, Alloc >::node_allocator_type [private]

Definition at line 230 of file slist.h.


Constructor & Destructor Documentation

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

Creates an empty list, using the provided allocator.

Parameters:
allocator to be used as memory model, defaults to Alloc().
complexity: O(1)

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.

template<typename T , class Alloc >
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.

Parameters:
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().
complexity: O(N) with N = n.

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.

template<typename T , class Alloc >
template<typename InputIterator >
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.

Parameters:
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().
complexity: O(N) with N = 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.

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

copies an entire list and its elements and allocator.

Parameters:
other the list to be copied
complexity: O(N) with N = 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.

template<typename T , class Alloc >
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().


Member Function Documentation

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

replace *this by a copy of other.

Parameters:
other list to be copied
complexity: O(N1) + O(N2) with N1 = this->size() and N2 = other.size().

Definition at line 167 of file slist.inl.

References lass::stde::slist< T, Alloc >::swap().

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

template<typename T , class Alloc >
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

Parameters:
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.
complexity: O(N1) + O(N2) with N1 = 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().

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

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

template<typename T , class Alloc >
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.

template<typename T , class Alloc >
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().

template<typename T , class Alloc >
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.

template<typename T , class Alloc >
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().

template<typename T , class Alloc >
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_.

template<typename T , class Alloc >
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()).

Parameters:
position must 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 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().

template<typename T , class Alloc >
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()).

Parameters:
position must 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 lass::stde::slist< T, Alloc >::before_begin(), and lass::stde::slist< T, Alloc >::prior().

template<typename T , class Alloc >
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.

Parameters:
position must be valid in *this and should not be this->before_begin()
start must 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.

References LASS_ASSERT, lass::stde::slist< T, Alloc >::node_base_t::next, and lass::stde::slist< T, Alloc >::iterator::node_.

template<typename T , class Alloc >
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.

Parameters:
position must be valid in *this and should not be this->before_begin()
start must 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.

References LASS_ASSERT, lass::stde::slist< T, Alloc >::node_base_t::next, and lass::stde::slist< T, Alloc >::const_iterator::node_.

template<typename T , class Alloc >
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().

template<typename T , class Alloc >
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.

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

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.

template<typename T , class Alloc >
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.

Parameters:
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().
complexity: O(N) with N = n.

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

template<typename T , class Alloc >
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.

template<typename T , class Alloc >
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.

template<typename T , class Alloc >
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.

Parameters:
value to 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.

References lass::stde::slist< T, Alloc >::head_, lass::stde::slist< T, Alloc >::make_node(), and lass::stde::slist< T, Alloc >::node_base_t::next.

template<typename T , class Alloc >
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().

template<typename T , class Alloc >
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.

Parameters:
position must be valid in *this and should not be this->before_begin()
value to 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 lass::stde::slist< T, Alloc >::insert_after(), and lass::stde::slist< T, Alloc >::prior().

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

inserts n copies of value before iterator position.

Parameters:
position must be valid in *this and should not be this->before_begin()
n number of copies to be inserted.
value to 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 lass::stde::slist< T, Alloc >::insert_after(), and lass::stde::slist< T, Alloc >::prior().

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

inserts a copy of a range before iterator position.

Parameters:
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.
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 lass::stde::slist< T, Alloc >::insert_after(), and lass::stde::slist< T, Alloc >::prior().

template<typename T , class Alloc >
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.

Parameters:
position must be valid in *this and should not be this->end()
value to be inserted
All iterators stay valid.

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

template<typename T , class Alloc >
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.

Parameters:
position must be valid in *this and should not be this->end()
n number of copies to be inserted.
value to be inserted
All iterators stay valid.

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

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

inserts a copy of a range before iterator position.

Parameters:
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.
All iterators stay valid.

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

template<typename T , class Alloc >
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.

Parameters:
position element 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 lass::stde::slist< T, Alloc >::erase_after(), and lass::stde::slist< T, Alloc >::prior().

template<typename T , class Alloc >
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.

Parameters:
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.
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 lass::stde::slist< T, Alloc >::erase_after(), and lass::stde::slist< T, Alloc >::prior().

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

removes element after iterator position from the list.

Parameters:
position iterator 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.

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

template<typename T , class Alloc >
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.

Parameters:
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.
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 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_.

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

template<typename T , class Alloc >
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().

template<typename T , class Alloc >
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.

Parameters:
position must be valid in *this and should not be this->before_begin()
other must 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 lass::stde::slist< T, Alloc >::prior(), and lass::stde::slist< T, Alloc >::splice_after().

template<typename T , class Alloc >
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.

Parameters:
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()
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 lass::stde::slist< T, Alloc >::prior(), and lass::stde::slist< T, Alloc >::splice_after().

template<typename T , class Alloc >
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.

Parameters:
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.
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 lass::stde::slist< T, Alloc >::prior(), and lass::stde::slist< T, Alloc >::splice_after().

template<typename T , class Alloc >
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.

Parameters:
position must be valid in *this and should not be this->end()
other must 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 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().

template<typename T , class Alloc >
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.

Parameters:
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()
All iterators stay valid.

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

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 
) [inline]

moves ( before_first, before_last ] from other to *this after position without copying.

Parameters:
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.
All iterators stay valid.

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

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

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

Parameters:
value value of the elements that must be removed.
complexity: O(N) with N = 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().

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

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

Parameters:
predicate should returns true for the elements that must be removed.
complexity: O(N) with N = 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().

template<typename T , class Alloc >
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().

template<typename T , class Alloc >
template<class BinaryPredicate >
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.

Parameters:
predicate two 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.

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

template<typename T , class Alloc >
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.

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

Definition at line 1056 of file slist.inl.

Referenced by lass::stde::slist< T, Alloc >::sort().

template<typename T , class Alloc >
template<class BinaryPredicate >
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.

Parameters:
other the other sorted slist
compare must 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 lass::stde::slist< T, Alloc >::head_, lass::stde::slist< T, Alloc >::node_base_t::next, and lass::stde::slist< T, Alloc >::splice_after().

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

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.

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

template<typename T , class Alloc >
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.

template<typename T , class Alloc >
slist< T, Alloc >::node_t * lass::stde::slist< T, Alloc >::make_node ( const T value  )  const [inline, private]

template<typename T , class Alloc >
void lass::stde::slist< T, Alloc >::unlink_and_destroy_after ( node_base_t position  )  const [inline, private]

template<typename T , class Alloc >
void lass::stde::slist< T, Alloc >::link_after ( node_base_t position,
node_base_t node 
) const [inline, private]

template<typename T , class Alloc >
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.

template<typename T , class Alloc >
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]

template<typename T , class Alloc >
template<typename InputIterator >
void lass::stde::slist< T, Alloc >::insert_after ( iterator  position,
InputIterator  first,
InputIterator  last,
meta::Wrap< meta::False parameter_is_iterator 
) [inline, private]

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

replace *this by a list copied from a range.

Parameters:
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.
complexity: O(N1) + O(N2) with N1 = 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().

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

Sorts *this according to compare.

Parameters:
compare must 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.

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


Friends And Related Function Documentation

template<typename T , class Alloc = std::allocator<T>>
friend class const_iterator [friend]

template<typename T , class Alloc = std::allocator<T>>
friend class iterator [friend]

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:
a first slist
b second slist
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().

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:
a first slist
b second slist
Is equivalent to !(a == b)

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

Definition at line 1344 of file slist.inl.

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:
a first slist
b second 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()

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

Definition at line 1364 of file slist.inl.

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:
a first slist
b second slist
Is equivalent to (b < a)

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

Definition at line 1396 of file slist.inl.

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:
a first slist
b second slist
Is equivalent to !(b < a)

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

Definition at line 1414 of file slist.inl.

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:
a first slist
b second slist
Is equivalent to !(a < b)

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

Definition at line 1432 of file slist.inl.

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:
ostream should be a good stream.
container slist to be written as [foo, bar, spam, ham]
complexity: O(N) with N = container.size()

Definition at line 1449 of file slist.inl.

References lass::stde::impl::print_sequence().

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:
istream should be a good stream.
container slist to be read as [foo, bar, spam, ham]
complexity: O(N) with N = number of elements to be read.

Definition at line 1468 of file slist.inl.


Field Documentation

template<typename T , class Alloc = std::allocator<T>>
node_base_t lass::stde::slist< T, Alloc >::head_ [private]


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

Generated on Mon Nov 10 14:22:16 2008 for Library of Assembled Shared Sources by doxygen 1.5.7.1
SourceForge.net Logo