Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

/ray/src/lib/tl/linkedlist.h File Reference

Linked list template. More...

#include <lib/sconfig.h>

Include dependency graph for linkedlist.h:

Include dependency graph

This graph shows which files directly or indirectly include this file:

Included by dependency graph

Go to the source code of this file.

Classes

class  LinkedList
 List class holding a list of objects derived from LinkedListBase (not thread-safe). More...

struct  LinkedListBase
 Base class for linked list item nodes. More...


Defines

#define _TemplateLibrary_LinkedList_H_   1
#define _LLB   LinkedListBase<T>


Detailed Description

Linked list template.

Author:
Wolfgang Wieser ] wwieser (a) gmx <*> de [
In real life one often has the "problem" to put manage several items using a linked list and these items are not meant to be part of more than one list at a time.
Hence, using standard list templates where one node entry is allocated for every list entry is too inefficient and over-engineered for this type of access: One could easily put the prev and next pointers directly into the item (only these two poiners are needed since the item is only in one list at a time -- or in no list at all).

This is just what these classes implement:

    // Item types to be queued: 
    struct ServerDesc : LinkedListBase<ServerDesc>
    {
        InetAdr address;
      int port;
        
        ServerDesc(const char *str);
        int connect();
    };

And somewhere else, we have the list:

    LinkedList<ServerDesc> slist;
    ServerDesc *sd=new ServerDesc("localhost:22");
  slist.append(sd);

It is easy to traverse the list first-to-last or last-to-first using e.g. (first-to-last here):

    for(ServerDesc *i=slist.first(); i; i=i->next)
        i->connect();

(Note that you do not need all the iterator object fuzz.)

Definition in file linkedlist.h.


Define Documentation

#define _LLB   LinkedListBase<T>
 

Definition at line 118 of file linkedlist.h.

#define _TemplateLibrary_LinkedList_H_   1
 

Definition at line 19 of file linkedlist.h.


Generated on Sat Feb 19 22:34:50 2005 for Ray by doxygen 1.3.5