Classes | Public Types | Public Member Functions

KIntrusiveList< T, NodeIndex > Class Template Reference

Search for all occurrences

Detailed Description

template<typename T, int NodeIndex = 0>
class KIntrusiveList< T, NodeIndex >

Definition at line 88 of file kintrusivelist.h.

#include <kintrusivelist.h>

List of all members.

Classes

class   IntrusiveListConstIterator
class   IntrusiveListIterator

Public Types

typedef T  allocator_type
typedef T  value_type
typedef T &  reference
typedef const T &  const_reference
typedef T *  pointer
typedef const T *  const_pointer
typedef KListNode< T >  NodeT
typedef IntrusiveListIterator  iterator
typedef IntrusiveListConstIterator  const_iterator

Public Member Functions

  KIntrusiveList ()
  ~KIntrusiveList ()
bool  Empty () const
void  PushBack (T &pElement)
void  PushFront (T &pElement)
void  PopFront ()
void  PopBack ()
iterator  Begin ()
const_iterator  Begin () const
iterator  End ()
const_iterator  End () const
reference  Front ()
const_reference  Front () const
reference  Back ()
const_reference  Back () const
iterator Erase (iterator &it)

Member Typedef Documentation

typedef T allocator_type

Definition at line 91 of file kintrusivelist.h.

typedef T value_type

Definition at line 92 of file kintrusivelist.h.

typedef T& reference

Definition at line 93 of file kintrusivelist.h.

typedef const T& const_reference

Definition at line 94 of file kintrusivelist.h.

typedef T* pointer

Definition at line 95 of file kintrusivelist.h.

typedef const T* const_pointer

Definition at line 96 of file kintrusivelist.h.

typedef KListNode<T> NodeT

Definition at line 98 of file kintrusivelist.h.

Definition at line 259 of file kintrusivelist.h.

Definition at line 260 of file kintrusivelist.h.


Constructor & Destructor Documentation

KIntrusiveList ( ) [inline]

Definition at line 101 of file kintrusivelist.h.

                    :mHead(0)
    {
        mHead.mNext = mHead.mPrev = &mHead;
    }
~KIntrusiveList ( ) [inline]

Definition at line 105 of file kintrusivelist.h.

    {
        while(!Empty())
            Begin().Get()->Disconnect();  // LINUXNote:  should be Erase(Begin()); but there's an issue with gcc 4.2
    };

Member Function Documentation

bool Empty ( ) const [inline]

Definition at line 112 of file kintrusivelist.h.

    {
        return ((mHead.mNext==&mHead)&&(mHead.mPrev==&mHead));
    }
void PushBack ( T &  pElement ) [inline]

Definition at line 118 of file kintrusivelist.h.

    {
        NodeT* pNode = &pElement.GetListNode(NodeIndex);
        pNode->mData = &pElement;

        if (Empty())
        {
            pNode->mNext = &mHead;
            pNode->mPrev = &mHead;
            mHead.mNext = pNode;
            mHead.mPrev = pNode;
        }
        else
        {
            pNode->mNext = &mHead;
            pNode->mPrev = mHead.mPrev;

            pNode->mPrev->mNext = pNode;
            mHead.mPrev = pNode;
        }
    }
void PushFront ( T &  pElement ) [inline]

Definition at line 140 of file kintrusivelist.h.

    {
        NodeT* pNode = &pElement.GetListNode(NodeIndex);
        pNode->mData = &pElement;

        if (Empty())
        {
            pNode->mNext = &mHead;
            pNode->mPrev = &mHead;
            mHead.mNext = pNode;
            mHead.mPrev = pNode;
        }
        else
        {
            pNode->mNext = mHead.mNext;
            pNode->mPrev = &mHead;

            pNode->mNext->mPrev = pNode;
            mHead.mNext = pNode;
        }
    }
void PopFront ( ) [inline]

Definition at line 162 of file kintrusivelist.h.

    {
        iterator begin = Begin();
        Erase(begin);
    }
void PopBack ( ) [inline]

Definition at line 168 of file kintrusivelist.h.

    {
        Erase(--(End()));
    }
iterator Begin ( ) [inline]

Definition at line 263 of file kintrusivelist.h.

{ return iterator(mHead.mNext); }
const_iterator Begin ( ) const [inline]

Definition at line 264 of file kintrusivelist.h.

{ return const_iterator(mHead.mNext); }
iterator End ( ) [inline]

Definition at line 265 of file kintrusivelist.h.

{ return iterator(&mHead); }
const_iterator End ( ) const [inline]

Definition at line 266 of file kintrusivelist.h.

{ return const_iterator(&mHead); }
reference Front ( ) [inline]

Definition at line 271 of file kintrusivelist.h.

{return (*Begin());}
const_reference Front ( ) const [inline]

Definition at line 272 of file kintrusivelist.h.

{ return (*Begin()); }
reference Back ( ) [inline]

Definition at line 273 of file kintrusivelist.h.

{ return (*(--End())); }
const_reference Back ( ) const [inline]

Definition at line 274 of file kintrusivelist.h.

{ return (*(--End())); }
iterator& Erase ( iterator it ) [inline]

Definition at line 276 of file kintrusivelist.h.

    {
        it.Get()->Disconnect();
        return (++it);
    }

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