tListItemBase Class Reference

#include <tLinkedList.h>

Inheritance diagram for tListItemBase:

Inheritance graph
[legend]
Collaboration diagram for tListItemBase:

Collaboration graph
[legend]

List of all members.

Public Member Functions

typedef int() Comparator (const tListItemBase *a, const tListItemBase *b)
void Remove ()
void Insert (tListItemBase *&a)
 tListItemBase ()
 tListItemBase (tListItemBase *&a)
virtual ~tListItemBase ()
tListItemBaseNext ()
int Len ()
void Sort (Comparator *comparator)

Protected Attributes

tListItemBasenext
tListItemBase ** anchor


Detailed Description

Definition at line 35 of file tLinkedList.h.


Constructor & Destructor Documentation

tListItemBase::tListItemBase (  )  [inline]

Definition at line 46 of file tLinkedList.h.

00046 :next(NULL),anchor(NULL)                 {}

tListItemBase::tListItemBase ( tListItemBase *&  a  )  [inline]

Definition at line 47 of file tLinkedList.h.

References Insert().

00047 :next(NULL),anchor(NULL){Insert(a);}

Here is the call graph for this function:

virtual tListItemBase::~tListItemBase (  )  [inline, virtual]

Definition at line 48 of file tLinkedList.h.

References Remove().

00048 {Remove();}

Here is the call graph for this function:


Member Function Documentation

typedef int() tListItemBase::Comparator ( const tListItemBase a,
const tListItemBase b 
)

void tListItemBase::Remove (  ) 

Definition at line 30 of file tLinkedList.cpp.

References anchor, next, and NULL.

Referenced by eCamera::Act(), nServerInfo::GetMasters(), nServerInfo::GetRandomMaster(), Insert(), gCycleWallsDisplayListManager::RenderAll(), gNetPlayerWall::RenderNormal(), Sort(), nServerInfo::Sort(), and ~tListItemBase().

00030                           {
00031     if (anchor){
00032         *anchor      = next;
00033         if (next)
00034             next->anchor = anchor;
00035         anchor       = NULL;
00036         next         = NULL;
00037     }
00038 }

Here is the caller graph for this function:

void tListItemBase::Insert ( tListItemBase *&  a  ) 

Reimplemented in tListItem< T >, tListItem< tLocaleSubItem >, tListItem< tCallbackString >, tListItem< tDecoratorBase >, tListItem< uAction >, tListItem< eWavData >, tListItem< tCallbackAnd >, tListItem< tCommandLineAnalyzer >, tListItem< gSimpleAIFactory >, tListItem< uActionGlobalFunc >, tListItem< gNetPlayerWall >, tListItem< eGlanceRequest >, tListItem< nServerInfo >, tListItem< test3 >, tListItem< tOutputItemBase >, tListItem< tCallbackOr >, tListItem< tLanguage >, tListItem< nDescriptor >, tListItem< tCallback >, tListItem< nMachineDecorator >, tListItem< rDisplayList >, and tListItem< tConsoleFilter >.

Definition at line 40 of file tLinkedList.cpp.

References anchor, next, and Remove().

Referenced by tListItem< tConsoleFilter >::Insert(), Sort(), and tListItemBase().

00040                                             {
00041     if (anchor)
00042         Remove();
00043     anchor = &a;
00044     next   =  a;
00045     a      =  this;
00046     if (next)
00047         next->anchor = &next;
00048 }

Here is the call graph for this function:

Here is the caller graph for this function:

tListItemBase* tListItemBase::Next (  )  [inline]

Reimplemented in tListItem< T >, gServerInfo, tListItem< tLocaleSubItem >, tListItem< tCallbackString >, tListItem< tDecoratorBase >, tListItem< uAction >, tListItem< eWavData >, tListItem< tCallbackAnd >, tListItem< tCommandLineAnalyzer >, tListItem< gSimpleAIFactory >, tListItem< uActionGlobalFunc >, tListItem< gNetPlayerWall >, tListItem< eGlanceRequest >, tListItem< nServerInfo >, tListItem< test3 >, tListItem< tOutputItemBase >, tListItem< tCallbackOr >, tListItem< tLanguage >, tListItem< nDescriptor >, tListItem< tCallback >, tListItem< nMachineDecorator >, tListItem< rDisplayList >, and tListItem< tConsoleFilter >.

Definition at line 50 of file tLinkedList.h.

References next.

00050 {return next;}

int tListItemBase::Len (  ) 

Definition at line 50 of file tLinkedList.cpp.

References next, and x.

Referenced by BestIQ(), eVoter::RemoveFromGame(), s_InputConfigGeneric(), and eVoter::VotingPossible().

00050                        {
00051     int ret=0;
00052     tListItemBase* x=this;
00053     while (x){
00054         ret++;
00055         x = x->next;
00056     }
00057     return ret;
00058 }

Here is the caller graph for this function:

void tListItemBase::Sort ( Comparator *  comparator  ) 

Definition at line 60 of file tLinkedList.cpp.

References anchor, Insert(), next, NULL, Remove(), and Sort().

Referenced by tListItem< tConsoleFilter >::Sort(), and Sort().

00061 {
00062     // early return statements: empty list or single element in list
00063     if ( !this || !next )
00064     {
00065         return;
00066     }
00067 
00068     tListItemBase* middle = this;
00069     {
00070         // locate the middle of the list
00071         tListItemBase* run = *anchor;
00072         while ( run )
00073         {
00074             middle = middle->next;
00075             run          = run->next;
00076             if ( run )
00077             {
00078                 run = run->next;
00079             }
00080         }
00081     }
00082 
00083     // split the list in the middle
00084     *middle->anchor = NULL;
00085     middle->anchor = &middle;
00086 
00087     // retrieve the anchor of the first half list
00088     tListItemBase*& first = *anchor;
00089 
00090     // sort the two half lists
00091     first->Sort( compare );
00092     middle->Sort( compare );
00093 
00094     // merge the lists
00095     {
00096         tListItemBase** run = &first;
00097         while ( middle )
00098         {
00099             // find the correct place for middle
00100             while ( *run && compare( *run, middle ) > 0 )
00101                 run = &(*run)->next;
00102 
00103             // remove middle from the second list; care needs to be taken because middle->remove() would modify middle.
00104             tListItemBase* insert = middle;
00105             insert->Remove();
00106 
00107             // insert it into the first list
00108             insert->Insert( *run );
00109             run = &insert->next;
00110         }
00111     }
00112 
00113     // done!
00114 }

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

tListItemBase* tListItemBase::next [protected]

Definition at line 37 of file tLinkedList.h.

Referenced by nServerInfo::DoQueryAll(), nServerInfo::GetFromMaster(), Insert(), Len(), tListItem< tConsoleFilter >::Next(), Next(), nServerInfo::Prev(), Remove(), Sort(), and nServerInfo::Sort().

tListItemBase** tListItemBase::anchor [protected]

Reimplemented in eCallbackGreeting.

Definition at line 38 of file tLinkedList.h.

Referenced by Insert(), nServerInfo::Prev(), Remove(), and Sort().


The documentation for this class was generated from the following files:
Generated on Sat Mar 15 23:57:24 2008 for Armagetron Advanced by  doxygen 1.5.4