Home | Documentation | Download | Platforms | Projects | Mailing Lists | Version History

- Main Page
- Classes
- Files
- Related Pages

- Alphabetical List
- Class List
- Class Hierarchy
- Class Members

# symlist< T > Class Template Reference

List which can be reversed in . More...

List of all members.

## Public Member Functions

| symlist ()
| Creates empty symlist.
| symlist (const symlist< T > &li)
| Makes the created list a copy of `li`.
symlist< T > & | operator= (const symlist< T > &li)
| Assignes `li` to this list.
| ~symlist ()
| Destructor.
bool | empty () const
| Checks whether list is empty.
T & | front ()
| First element in list.
T & | back ()
| Last element in list.
iterator | begin ()
| Start iteration through elements of list.
iterator | end ()
| End of iteration through elements of list.
const_iterator | begin () const
| Start iteration through elements of list.
const_iterator | end () const
| End of iteration through elements of list.
iterator | rbegin ()
| Start iteration through element of list in reverse order.
iterator | rend ()
| End of iteration through elements of list in reverse order.
const_iterator | rbegin () const
| Start iteration through element of list in reverse order.
const_iterator | rend () const
| End of iteration through elements of list in reverse order.
iterator | insert (iterator pos, const T &data)
| Inserts `data` before `pos` in list.
void | splice (iterator pos, iterator it)
| Inserts the element `it` points to before `pos` into this list.
void | splice (iterator pos, iterator it, iterator end)
| Inserts the elements `[it,end)` refers to before `pos` into this list.
iterator | erase (iterator pos)
| Deletes element at position `pos` from list.
iterator | erase (iterator it, iterator end)
| Deletes the elements `[it, end)` from list.
void | reverse ()
| Change the direction of list.

## Detailed Description

### template<class T>
class symlist< T >

List which can be reversed in .

The problem with the STL class list - as with most doubly linked lists -- is that isn't possible to turn it in constant time, because each entry in the list contains next and prev pointer and turning the list means to switch these two in each element in the list. Another point is the splice operation in STL lists, which is constant time, but for the same reason as mentioned above it is not possible to splice a list in reverse order into another in constant time.

The problems arise from the fact that each element "knows" what its next and previous elements are. An element in a symlist only knows what its neighbors are, what is next and what previous depends on the direction of iteration. This of course imposes some overhead in iteration (one if-statement) but allows reversion and a splice in reversed order in constant time.

## Constructor & Destructor Documentation

template<class T>

symlist< T >::symlist | ( | const symlist< T > & | li | ) | `[inline]`

Makes the created list a copy of `li`.

Parameters:

  | li | symlist.

## Member Function Documentation

template<class T>

symlist< T > & symlist< T >::operator= | ( | const symlist< T > & | li | ) | `[inline]`

Assignes `li` to this list.

Note:
  All elements in this list will be deleted.

Parameters:

  | li |

Returns:
  this list

template<class T>

bool symlist< T >::empty | ( |  | ) | const`[inline]`

Checks whether list is empty.

Takes constant time.

Return values:

  | true | iff list is empty

template<class T>

T& symlist< T >::front | ( |  | ) | `[inline]`

First element in list.

Assumes that list ins't empty.

Returns:
  first element

template<class T>

T& symlist< T >::back | ( |  | ) | `[inline]`

Last element in list.

Assumes that list ins't empty.

Returns:
  last element

template<class T>

iterator symlist< T >::begin | ( |  | ) | `[inline]`

Start iteration through elements of list.

Returns:
  start iterator

template<class T>

iterator symlist< T >::end | ( |  | ) | `[inline]`

End of iteration through elements of list.

Returns:
  end iterator

template<class T>

const_iterator symlist< T >::begin | ( |  | ) | const`[inline]`

Start iteration through elements of list.

Returns:
  start iterator

template<class T>

const_iterator symlist< T >::end | ( |  | ) | const`[inline]`

End of iteration through elements of list.

Returns:
  end iterator

template<class T>

iterator symlist< T >::rbegin | ( |  | ) | `[inline]`

Start iteration through element of list in reverse order.

Returns:
  start iterator

template<class T>

iterator symlist< T >::rend | ( |  | ) | `[inline]`

End of iteration through elements of list in reverse order.

Returns:
  end iterator

template<class T>

const_iterator symlist< T >::rbegin | ( |  | ) | const`[inline]`

Start iteration through element of list in reverse order.

Returns:
  start iterator

template<class T>

const_iterator symlist< T >::rend | ( |  | ) | const`[inline]`

End of iteration through elements of list in reverse order.

Returns:
  end iterator

template<class T>

iterator symlist< T >::insert | ( | iterator | pos,
|  | const T & | data |
| ) |  |  |

Inserts `data` before `pos` in list.

Parameters:

  | pos | position
  | data | element to be inserted

Returns:
  position of insertion

template<class T>

void symlist< T >::splice | ( | iterator | pos,
|  | iterator | it |
| ) |  |  |

Inserts the element `it` points to before `pos` into this list.

It is assumed that the element `it` refers lies in a different list. All iterators to elements in either of the two lists stay valid. Takes constant time.

Parameters:

  | pos | position
  | it | position of element to be inserted

template<class T>

void symlist< T >::splice | ( | iterator | pos,
|  | iterator | it,
|  | iterator | end |
| ) |  |  |

Inserts the elements `[it,end)` refers to before `pos` into this list.

It is assumed that `[it,end)` lies in a different list. All iterators to elements in either of the two lists stay valid. Takes constant time.

Parameters:

  | pos | position
  | it | position of first element to be inserted
  | end | position of one-past the last element to be inserted

template<class T>

iterator symlist< T >::erase | ( | iterator | pos | ) |

Deletes element at position `pos` from list.

Parameters:

  | pos | position to be deleted

Returns:
  position of next element

template<class T>

iterator symlist< T >::erase | ( | iterator | it,
|  | iterator | end |
| ) |  |  |

Deletes the elements `[it, end)` from list.

Parameters:

  | it | first position to be deleted
  | end | one-past the last position to be deleted

Returns:
  position of next element.

template<class T>

void symlist< T >::reverse | ( |  | ) | `[inline]`

Change the direction of list.

Takes constant time.

University of Passau - FMI - Theoretical Computer Science

Design © 2002, 2003 Marcus Raitner, University of Passau