Main Page   Class Hierarchy   Alphabetical List   Compound List   Compound Members  

util::LinkedList< content > Class Template Reference

#include <LinkedList.h>

Inheritance diagram for util::LinkedList< content >:

util::Object util::DoublyLinkedList< content > util::SortedLinkedList< content > List of all members.

Detailed Description

template<class content>
class util::LinkedList< content >

LinkedList objects can be used to create linked lists.

Each object represents one node in the list. Each node is created initially unlinked, and deleting a node deletes all nodes following the deleted one.


Public Methods

 LinkedList (void)
 Create an unlinked node with the contents initialized to a default value.

 LinkedList (const content &obj)
 Create an unlinked node with the given contents.

virtual ~LinkedList ()
 Delete this node and all successors.

LinkedList * getNext (void)
 Get a pointer to the next node in sequence.

const LinkedList * getNext (void) const
 Get a const pointer to the next node in sequence.

virtual void setNext (LinkedList *node)
 Set the next node for this node.

virtual void insertAfter (LinkedList *node)
 Insert a linked list after this node.

content getData (void) const
 Get the data stored in this node.

content & data (void)
 Get a reference to the stored data.

const content & data (void) const
 Get a const reference to the stored data.

void setData (const content &obj)
 Set the data stored in this node.

int getLength (void) const
 Get the number of nodes in a sequence.

virtual LinkedList * remove (LinkedList *node)
 Remove a given node from the sequence following this node.

virtual LinkedList * remove (const content &obj)
 Remove a given node from the sequence following this node.

const LinkedList * getLastElement (void) const
 Get the last element in a linked list.

LinkedList * getLastElement (void)
 Get the last element in a linked list.


Protected Attributes

LinkedList * _pNext
 A pointer to the next element in sequence.

content _item
 The data stored in this node.


Constructor & Destructor Documentation

template<class content>
util::LinkedList< content >::LinkedList const content &    obj [inline]
 

Create an unlinked node with the given contents.

Parameters:
obj  the object to be stored in this list node


Member Function Documentation

template<class content>
content util::LinkedList< content >::getData void    const [inline]
 

Get the data stored in this node.

Returns:
the data

template<class content>
LinkedList* util::LinkedList< content >::getLastElement void    [inline]
 

Get the last element in a linked list.

The sequence is seeked until getNext returns NULL.

Returns:
the last element in a sequence

template<class content>
const LinkedList* util::LinkedList< content >::getLastElement void    const [inline]
 

Get the last element in a linked list.

The sequence is seeked until getNext returns NULL.

Returns:
the last element in a sequence

template<class content>
int util::LinkedList< content >::getLength void    const [inline]
 

Get the number of nodes in a sequence.

If this node has no successors, the return value is one.

Returns:
the number of nodes following this one + 1

template<class content>
const LinkedList* util::LinkedList< content >::getNext void    const [inline]
 

Get a const pointer to the next node in sequence.

Returns:
the next node or NULL if this is the last one

template<class content>
LinkedList* util::LinkedList< content >::getNext void    [inline]
 

Get a pointer to the next node in sequence.

Returns:
the next node or NULL if this is the last one

template<class content>
void util::LinkedList< content >::insertAfter LinkedList< content > *    node [virtual]
 

Insert a linked list after this node.

The whole list pointed by node is inserted after this node.

Parameters:
node  the list to be inserted

template<class content>
LinkedList< content > * util::LinkedList< content >::remove const content &    obj [virtual]
 

Remove a given node from the sequence following this node.

The successors of the current node are searched until a node with contents equal to obj is found. The node is then removed from the list but not deleted.

Parameters:
obj  the data whose container is to be removed
Returns:
a pointer to the removed node or NULL if it was not found

template<class content>
LinkedList< content > * util::LinkedList< content >::remove LinkedList< content > *    node [virtual]
 

Remove a given node from the sequence following this node.

The successors of the current node are searched until node is found. The node is then removed from the list but not deleted.

Parameters:
node  the node to be removed
Returns:
a pointer to the removed node or NULL if it was not found

template<class content>
void util::LinkedList< content >::setData const content &    obj [inline]
 

Set the data stored in this node.

Parameters:
obj  the new data

template<class content>
virtual void util::LinkedList< content >::setNext LinkedList< content > *    node [inline, virtual]
 

Set the next node for this node.

Parameters:
node  the next node for this node


The documentation for this class was generated from the following file:
Documentation generated on 11.09.2003 with Doxygen.
The documentation is copyrighted material.
Copyright © Topi Mäenpää 2003. All rights reserved.