container::LinkedList::Node Class Reference

LinkedList uses Node objects to form a list of Entity objects. More...

#include <linkedlist.h>

Collaboration diagram for container::LinkedList::Node:

Collaboration graph
[legend]

List of all members.

Public Member Functions

 Node ()
 Node (Entity *e, Node *n)
 Construct a Node for Entity e and insert it into the list before Node n.
 ~Node ()
EntityextractEntity ()

Public Attributes

Nodenext
Nodeprev
Entityentity


Detailed Description

LinkedList uses Node objects to form a list of Entity objects.

Node is doubly linked. It keeps a pointer to its Entity object and expects it to be dynamically allocated. Node takes responsibility for deleting its Entity object during Node destruction.

Todo:
Break node out from LinkedList, or at least provide a .h file. A Node could be used like an iterator. There is some functionality like toNext() and toPrev() that should be encapsulated in Node instead of LinkedList. Node could be re-used as the building block for other linked list type structures.

Constructor & Destructor Documentation

container::LinkedList::Node::Node (  ) 

00209 : next(NULL), prev(NULL), entity(NULL) { }

container::LinkedList::Node::Node ( Entity e,
Node n 
)

Construct a Node for Entity e and insert it into the list before Node n.

Precondition:
n points to a Node that is part of a correctly formed linked list structure

e points to an Entity

Postcondition:
The newly constructed Node is in the linked list structure before Node n
00211                                       : next(n), prev(n->prev), entity(e) {
00212    // Tell the list where this new node belongs
00213    next->prev = this;
00214    prev->next = this;
00215 }

container::LinkedList::Node::~Node (  ) 

00217                       {
00218    // Remove itself from the list
00219    if (prev != NULL) {
00220       prev->next = next;
00221    }
00222 
00223    if (next != NULL) {
00224       next->prev = prev;
00225    }
00226 
00227    // Delete its entity
00228    if (entity != NULL) {
00229       delete entity;
00230    }
00231 }


Member Function Documentation

Entity * container::LinkedList::Node::extractEntity (  ) 

00233                                        {
00234    Entity *e = entity;
00235    entity = NULL;
00236    return e;
00237 }

Here is the caller graph for this function:


Member Data Documentation


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

Generated on Tue Jun 16 23:12:58 2009 by  doxygen 1.5.9