User Manual, Developers Guide and API Documentation

wns::container::FastList< T > Class Template Reference

List supporting removing and inserting elements with O(1). More...

#include <container/FastList.hpp>

Inheritance diagram for wns::container::FastList< T >:

Inheritance graph
[legend]
Collaboration diagram for wns::container::FastList< T >:

Collaboration graph
[legend]

List of all members.

Public Member Functions

iterator begin () const
 Iterator to the begin of the list.
void clear ()
 Remove alle element from the list.
bool contains (const T &x)
 Does the list contain value x?
bool empty () const
 Is list empty?
iterator end () const
 Iterator to the end of the list.
void erase (const iterator &i)
 Erase element at iterator's position.
 FastList (const FastList &f)
 Copy Constructor.
 FastList ()
 Default Constructor.
T & front () const
 Get a reference to the first element.
void operator= (const FastList &f)
 Assignment operator.
void pop_front ()
void push_back (T *x)
 Add value x at the end of the list.
void push_back (const T &x)
 Add value x at the end of the list.
void push_front (T *x)
 Add value x at the front of the list.
void push_front (const T &x)
 Add value x at the front of the list.
void remove (T *x)
 Remove element with value x.
void remove (const T &x)
 Remove element with value x.
int size () const
 Returns the size of the list.
 ~FastList ()
 Destructor - removes all element from the list.

Private Member Functions

void copy (const FastList &f)
 Special copy for lists.

Private Attributes

FastListNode< T > b
 Sentinel.
int s
 Size of the list.

Classes

class  iterator
 An STL-sytle iterator for the FastList. More...


Detailed Description

template<typename T>
class wns::container::FastList< T >

Author:
Marc Schinnenburg <marc@schinnenburg.com>
Enable a class to be used by FastLists:
// Note how FLTest is enabled to
// support FastLists by deriving from FastListEnabler
class FLTest :
    public FastListEnabler<FLTest*>
{
public:
    explicit
    FLTest(int id) :
        FastListEnabler<FLTest*>(),
        Id(id)
    {
    }

    int
    getId() const
    {
        return Id;
    }

private:
    int Id;
};

Define a FastList:

FastList<FLTest*> f;

Push some elements to the front of the list:

flt1 = new FLTest(1);
f.push_front(flt1);

Todo:
Marc Schinnenburg: If the element T is derived from SingleFastListEnabler, it would be nice to generate a compile-time error, since copying the list is not allowed in this case.

Definition at line 58 of file FastList.hpp.


Constructor & Destructor Documentation

template<typename T>
wns::container::FastList< T >::FastList (  )  [inline]

Definition at line 173 of file FastList.hpp.

template<typename T>
wns::container::FastList< T >::~FastList (  )  [inline]

Definition at line 181 of file FastList.hpp.

template<typename T>
wns::container::FastList< T >::FastList ( const FastList< T > &  f  )  [inline]

Definition at line 189 of file FastList.hpp.


Member Function Documentation

template<typename T>
iterator wns::container::FastList< T >::begin (  )  const [inline]

Definition at line 208 of file FastList.hpp.

template<typename T>
void wns::container::FastList< T >::clear (  )  [inline]

Definition at line 250 of file FastList.hpp.

template<typename T>
bool wns::container::FastList< T >::contains ( const T &  x  )  [inline]

Definition at line 352 of file FastList.hpp.

template<typename T>
void wns::container::FastList< T >::copy ( const FastList< T > &  f  )  [inline, private]

Definition at line 361 of file FastList.hpp.

template<typename T>
bool wns::container::FastList< T >::empty (  )  const [inline]

Definition at line 234 of file FastList.hpp.

template<typename T>
iterator wns::container::FastList< T >::end (  )  const [inline]

Note:
This iterator is never valid. Never dereference it!

Definition at line 218 of file FastList.hpp.

template<typename T>
void wns::container::FastList< T >::erase ( const iterator i  )  [inline]

Definition at line 265 of file FastList.hpp.

template<typename T>
T& wns::container::FastList< T >::front (  )  const [inline]

Definition at line 226 of file FastList.hpp.

template<typename T>
void wns::container::FastList< T >::operator= ( const FastList< T > &  f  )  [inline]

Definition at line 199 of file FastList.hpp.

template<typename T>
void wns::container::FastList< T >::pop_front (  )  [inline]

Definition at line 344 of file FastList.hpp.

template<typename T>
void wns::container::FastList< T >::push_back ( T *  x  )  [inline]

Definition at line 339 of file FastList.hpp.

template<typename T>
void wns::container::FastList< T >::push_back ( const T &  x  )  [inline]

Definition at line 326 of file FastList.hpp.

template<typename T>
void wns::container::FastList< T >::push_front ( T *  x  )  [inline]

Definition at line 318 of file FastList.hpp.

template<typename T>
void wns::container::FastList< T >::push_front ( const T &  x  )  [inline]

Definition at line 305 of file FastList.hpp.

template<typename T>
void wns::container::FastList< T >::remove ( T *  x  )  [inline]

Definition at line 292 of file FastList.hpp.

template<typename T>
void wns::container::FastList< T >::remove ( const T &  x  )  [inline]

Definition at line 279 of file FastList.hpp.

template<typename T>
int wns::container::FastList< T >::size (  )  const [inline]

Definition at line 242 of file FastList.hpp.


Member Data Documentation

template<typename T>
FastListNode<T> wns::container::FastList< T >::b [mutable, private]

Definition at line 373 of file FastList.hpp.

template<typename T>
int wns::container::FastList< T >::s [private]

Definition at line 378 of file FastList.hpp.


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

Generated on Sat May 26 03:32:51 2012 for openWNS by  doxygen 1.5.5