Open
Graph Drawing
Framework

 v.2010.10
 

Public Types | Public Member Functions | Private Attributes

ogdf::SList< E > Class Template Reference

The parameterized class SList<E> represents singly linked lists with content type E. More...

#include <ogdf/basic/SList.h>

Inheritance diagram for ogdf::SList< E >:
ogdf::SListPure< E > ogdf::Queue< E >

List of all members.

Public Types

typedef E value_type
typedef SListElement< E > element_type
typedef SListConstIterator< E > const_iterator
typedef SListIterator< E > iterator

Public Member Functions

 SList ()
 Constructs an empty singly linked list.
 SList (const SList< E > &L)
 Constructs a singly linked list that is a copy of L.
 ~SList ()
bool empty () const
 Returns true iff the list is empty.
int size () const
 Returns the length of the list.
const SListConstIterator< E > begin () const
 Returns an iterator to the first element of the list.
SListIterator< E > begin ()
 Returns an iterator to the first element of the list.
SListConstIterator< E > end () const
 Returns an iterator to one-past-last element of the list.
SListIterator< E > end ()
 Returns an iterator to one-past-last element of the list.
const SListConstIterator< E > rbegin () const
 Returns an iterator to the last element of the list.
SListIterator< E > rbegin ()
 Returns an iterator to the last element of the list.
SListConstIterator< E > get (int pos) const
 Returns an iterator pointing to the element at position pos.
SListIterator< E > get (int pos)
 Returns an iterator pointing to the element at position pos.
int pos (SListConstIterator< E > it) const
 Returns the position (starting with 0) of it in the list.
const E & front () const
 Returns a reference to the first element.
E & front ()
 Returns a reference to the first element.
const E & back () const
 Returns a reference to the last element.
E & back ()
 Returns a reference to the last element.
SListConstIterator< E > cyclicSucc (SListConstIterator< E > it) const
 Returns an iterator to the cyclic successor of it.
SListIterator< E > cyclicSucc (SListIterator< E > it)
 Returns an iterator to the cyclic successor of it.
SList< E > & operator= (const SList< E > &L)
 Assignment operator.
SListIterator< E > pushFront (const E &x)
 Adds element x at the begin of the list.
SListIterator< E > pushBack (const E &x)
 Adds element x at the end of the list.
SListIterator< E > insertAfter (const E &x, SListIterator< E > itBefore)
 Inserts element x after pBefore.
void popFront ()
 Removes the first element from the list.
popFrontRet ()
 Removes the first element from the list and returns it.
void delSucc (SListIterator< E > itBefore)
 Removes the succesor of pBefore.
void moveFrontToFront (SList< E > &L2)
 Moves the first element of this list to the begin of list L2.
void moveFrontToBack (SList< E > &L2)
 Moves the first element of this list to the end of list L2.
void moveFrontToSucc (SList< E > &L2, SListIterator< E > itBefore)
 Moves the first element of this list to list L2 inserted after itBefore.
void clear ()
 Removes all elements from the list.
void conc (SList< E > &L2)
 Appends L2 to this list and makes L2 empty.
void reverse ()
 Reverses the order of the list elements.
const SListPure< E > & getListPure () const
 Conversion to const SListPure.
void quicksort ()
 Sorts the list using Quicksort.
template<class COMPARER >
void quicksort (const COMPARER &comp)
 Sorts the list using Quicksort and comparer comp.
void bucketSort (int l, int h, BucketFunc< E > &f)
 Sorts the list using bucket sort.
void bucketSort (BucketFunc< E > &f)
 Sorts the list using bucket sort.
void permute ()
 Randomly permutes the elements in the list.
void * operator new (size_t nBytes)
void * operator new (size_t, void *p)
void operator delete (void *p, size_t nBytes)

Private Attributes

int m_count
 The length of the list.

Detailed Description

template<class E>
class ogdf::SList< E >

The parameterized class SList<E> represents singly linked lists with content type E.

Elements of the list are instances of type SListElement<E>. Use SListConstIterator<E> or SListIterator<E> in order to iterate over the list. In contrast to SListPure<E>, instances of SList<E> store the length of the list and thus allow constant time access to the length.

Definition at line 615 of file SList.h.


Member Typedef Documentation

template<class E>
typedef SListConstIterator<E> ogdf::SList< E >::const_iterator

Reimplemented from ogdf::SListPure< E >.

Definition at line 631 of file SList.h.

template<class E>
typedef SListElement<E> ogdf::SList< E >::element_type

Reimplemented from ogdf::SListPure< E >.

Definition at line 630 of file SList.h.

template<class E>
typedef SListIterator<E> ogdf::SList< E >::iterator

Reimplemented from ogdf::SListPure< E >.

Definition at line 632 of file SList.h.

template<class E>
typedef E ogdf::SList< E >::value_type

Reimplemented from ogdf::SListPure< E >.

Definition at line 629 of file SList.h.


Constructor & Destructor Documentation

template<class E>
ogdf::SList< E >::SList (  )  [inline]

Constructs an empty singly linked list.

Definition at line 621 of file SList.h.

template<class E>
ogdf::SList< E >::SList ( const SList< E > &  L  )  [inline]

Constructs a singly linked list that is a copy of L.

Definition at line 624 of file SList.h.

template<class E>
ogdf::SList< E >::~SList (  )  [inline]

Definition at line 627 of file SList.h.


Member Function Documentation

template<class E>
const E& ogdf::SList< E >::back (  )  const [inline]

Returns a reference to the last element.

Precondition:
The list is not empty!

Reimplemented from ogdf::SListPure< E >.

Definition at line 719 of file SList.h.

template<class E>
E& ogdf::SList< E >::back (  )  [inline]

Returns a reference to the last element.

Precondition:
The list is not empty!

Reimplemented from ogdf::SListPure< E >.

Definition at line 725 of file SList.h.

template<class E>
SListIterator<E> ogdf::SList< E >::begin (  )  [inline]

Returns an iterator to the first element of the list.

If the list is empty, a null pointer iterator is returned.

Reimplemented from ogdf::SListPure< E >.

Definition at line 650 of file SList.h.

template<class E>
const SListConstIterator<E> ogdf::SList< E >::begin (  )  const [inline]

Returns an iterator to the first element of the list.

If the list is empty, a null pointer iterator is returned.

Reimplemented from ogdf::SListPure< E >.

Definition at line 644 of file SList.h.

template<class E>
void ogdf::SList< E >::bucketSort ( int  l,
int  h,
BucketFunc< E > &  f 
) [inline]

Sorts the list using bucket sort.

Parameters:
l is the lowest bucket that will occur.
h is the highest bucket that will occur.
f returns the bucket for each element.
Precondition:
The bucket function f will only return bucket values between l and h for this list.

Reimplemented from ogdf::SListPure< E >.

Definition at line 860 of file SList.h.

template<class E>
void ogdf::SList< E >::bucketSort ( BucketFunc< E > &  f  )  [inline]

Sorts the list using bucket sort.

Reimplemented from ogdf::SListPure< E >.

Definition at line 865 of file SList.h.

template<class E>
void ogdf::SList< E >::clear (  )  [inline]

Removes all elements from the list.

Reimplemented from ogdf::SListPure< E >.

Reimplemented in ogdf::Queue< E >.

Definition at line 821 of file SList.h.

template<class E>
void ogdf::SList< E >::conc ( SList< E > &  L2  )  [inline]

Appends L2 to this list and makes L2 empty.

Definition at line 827 of file SList.h.

template<class E>
SListConstIterator<E> ogdf::SList< E >::cyclicSucc ( SListConstIterator< E >  it  )  const [inline]

Returns an iterator to the cyclic successor of it.

Precondition:
it points to an element in this list!

Reimplemented from ogdf::SListPure< E >.

Definition at line 731 of file SList.h.

template<class E>
SListIterator<E> ogdf::SList< E >::cyclicSucc ( SListIterator< E >  it  )  [inline]

Returns an iterator to the cyclic successor of it.

Precondition:
it points to an element in this list!

Reimplemented from ogdf::SListPure< E >.

Definition at line 739 of file SList.h.

template<class E>
void ogdf::SList< E >::delSucc ( SListIterator< E >  itBefore  )  [inline]

Removes the succesor of pBefore.

Precondition:
pBefore points to an element in this list.

Reimplemented from ogdf::SListPure< E >.

Definition at line 794 of file SList.h.

template<class E>
bool ogdf::SList< E >::empty (  )  const [inline]

Returns true iff the list is empty.

Reimplemented from ogdf::SListPure< E >.

Reimplemented in ogdf::Queue< E >.

Definition at line 635 of file SList.h.

template<class E>
SListConstIterator<E> ogdf::SList< E >::end (  )  const [inline]

Returns an iterator to one-past-last element of the list.

This is always a null pointer iterator.

Reimplemented from ogdf::SListPure< E >.

Definition at line 656 of file SList.h.

template<class E>
SListIterator<E> ogdf::SList< E >::end (  )  [inline]

Returns an iterator to one-past-last element of the list.

This is always a null pointer iterator.

Reimplemented from ogdf::SListPure< E >.

Definition at line 662 of file SList.h.

template<class E>
const E& ogdf::SList< E >::front (  )  const [inline]

Returns a reference to the first element.

Precondition:
The list is not empty!

Reimplemented from ogdf::SListPure< E >.

Definition at line 707 of file SList.h.

template<class E>
E& ogdf::SList< E >::front (  )  [inline]

Returns a reference to the first element.

Precondition:
The list is not empty!

Reimplemented from ogdf::SListPure< E >.

Definition at line 713 of file SList.h.

template<class E>
SListConstIterator<E> ogdf::SList< E >::get ( int  pos  )  const [inline]

Returns an iterator pointing to the element at position pos.

The running time of this method is linear in pos.

Reimplemented from ogdf::SListPure< E >.

Definition at line 681 of file SList.h.

template<class E>
SListIterator<E> ogdf::SList< E >::get ( int  pos  )  [inline]

Returns an iterator pointing to the element at position pos.

The running time of this method is linear in pos.

Reimplemented from ogdf::SListPure< E >.

Definition at line 689 of file SList.h.

template<class E>
const SListPure<E>& ogdf::SList< E >::getListPure (  )  const [inline]

Conversion to const SListPure.

Reimplemented from ogdf::SListPure< E >.

Reimplemented in ogdf::Queue< E >.

Definition at line 839 of file SList.h.

template<class E>
SListIterator<E> ogdf::SList< E >::insertAfter ( const E &  x,
SListIterator< E >  itBefore 
) [inline]

Inserts element x after pBefore.

Precondition:
pBefore points to an element in this list.

Reimplemented from ogdf::SListPure< E >.

Definition at line 766 of file SList.h.

template<class E>
void ogdf::SList< E >::moveFrontToBack ( SList< E > &  L2  )  [inline]

Moves the first element of this list to the end of list L2.

Definition at line 806 of file SList.h.

template<class E>
void ogdf::SList< E >::moveFrontToFront ( SList< E > &  L2  )  [inline]

Moves the first element of this list to the begin of list L2.

Definition at line 800 of file SList.h.

template<class E>
void ogdf::SList< E >::moveFrontToSucc ( SList< E > &  L2,
SListIterator< E >  itBefore 
) [inline]

Moves the first element of this list to list L2 inserted after itBefore.

Precondition:
itBefore points to an element in L2.

Definition at line 815 of file SList.h.

template<class E>
void ogdf::SList< E >::operator delete ( void *  p,
size_t  nBytes 
) [inline]

Reimplemented from ogdf::SListPure< E >.

Reimplemented in ogdf::Queue< E >.

Definition at line 874 of file SList.h.

template<class E>
void* ogdf::SList< E >::operator new ( size_t  nBytes  )  [inline]

Reimplemented from ogdf::SListPure< E >.

Reimplemented in ogdf::Queue< E >.

Definition at line 874 of file SList.h.

template<class E>
void* ogdf::SList< E >::operator new ( size_t  ,
void *  p 
) [inline]

Reimplemented from ogdf::SListPure< E >.

Reimplemented in ogdf::Queue< E >.

Definition at line 874 of file SList.h.

template<class E>
SList<E>& ogdf::SList< E >::operator= ( const SList< E > &  L  )  [inline]

Assignment operator.

Definition at line 744 of file SList.h.

template<class E>
void ogdf::SList< E >::permute (  )  [inline]

Randomly permutes the elements in the list.

Reimplemented from ogdf::SListPure< E >.

Definition at line 870 of file SList.h.

template<class E>
void ogdf::SList< E >::popFront (  )  [inline]

Removes the first element from the list.

Precondition:
The list is not empty!

Reimplemented from ogdf::SListPure< E >.

Definition at line 775 of file SList.h.

template<class E>
E ogdf::SList< E >::popFrontRet (  )  [inline]

Removes the first element from the list and returns it.

Precondition:
The list is not empty!

Reimplemented from ogdf::SListPure< E >.

Definition at line 784 of file SList.h.

template<class E>
int ogdf::SList< E >::pos ( SListConstIterator< E >  it  )  const [inline]

Returns the position (starting with 0) of it in the list.

Positions are numbered 0,1,...

Precondition:
it is an iterator pointing to an element in this list.

Reimplemented from ogdf::SListPure< E >.

Definition at line 698 of file SList.h.

template<class E>
SListIterator<E> ogdf::SList< E >::pushBack ( const E &  x  )  [inline]

Adds element x at the end of the list.

Reimplemented from ogdf::SListPure< E >.

Definition at line 757 of file SList.h.

template<class E>
SListIterator<E> ogdf::SList< E >::pushFront ( const E &  x  )  [inline]

Adds element x at the begin of the list.

Reimplemented from ogdf::SListPure< E >.

Definition at line 751 of file SList.h.

template<class E>
void ogdf::SList< E >::quicksort (  )  [inline]

Sorts the list using Quicksort.

Reimplemented from ogdf::SListPure< E >.

Definition at line 842 of file SList.h.

template<class E>
template<class COMPARER >
void ogdf::SList< E >::quicksort ( const COMPARER &  comp  )  [inline]

Sorts the list using Quicksort and comparer comp.

Reimplemented from ogdf::SListPure< E >.

Definition at line 848 of file SList.h.

template<class E>
const SListConstIterator<E> ogdf::SList< E >::rbegin (  )  const [inline]

Returns an iterator to the last element of the list.

If the list is empty, a null pointer iterator is returned.

Reimplemented from ogdf::SListPure< E >.

Definition at line 668 of file SList.h.

template<class E>
SListIterator<E> ogdf::SList< E >::rbegin (  )  [inline]

Returns an iterator to the last element of the list.

If the list is empty, a null pointer iterator is returned.

Reimplemented from ogdf::SListPure< E >.

Definition at line 674 of file SList.h.

template<class E>
void ogdf::SList< E >::reverse (  )  [inline]

Reverses the order of the list elements.

Reimplemented from ogdf::SListPure< E >.

Definition at line 834 of file SList.h.

template<class E>
int ogdf::SList< E >::size (  )  const [inline]

Returns the length of the list.

Reimplemented from ogdf::SListPure< E >.

Reimplemented in ogdf::Queue< E >.

Definition at line 638 of file SList.h.


Member Data Documentation

template<class E>
int ogdf::SList< E >::m_count [private]

The length of the list.

Definition at line 617 of file SList.h.


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