Main Page   Class Hierarchy   Alphabetical List   Compound List   Compound Members  

util::SortedLinkedList< content > Class Template Reference

#include <LinkedList.h>

Inheritance diagram for util::SortedLinkedList< content >:

util::LinkedList< content > util::Object List of all members.

Detailed Description

template<class content>
class util::SortedLinkedList< content >

A linked list that maintains its elements in sorted order.


Public Methods

 SortedLinkedList ()
 Create an empty sorted linked list.

 SortedLinkedList (const content &data)
 Create an unlinked node with the given contents.

SortedLinkedList * addNode (SortedLinkedList *node)
 Add a node to this linked list, maintaining sort order.


Member Function Documentation

template<class content>
SortedLinkedList< content > * util::SortedLinkedList< content >::addNode SortedLinkedList< content > *    node
 

Add a node to this linked list, maintaining sort order.

The list is seeked until a node with a content item not smaller than the provided one is found. The cardinality is checked using the < operator. The new node is inserted just before the found node, or to the end of the list if no applicable node cannot be found.

Using this method ensures that nodes are always sorted according to their contents. If you add nodes in any other way, the order cannot be guaranteed.

Parameters:
node  the node to be inserted to this list
Returns:
the node after which the new node was inserted. If the return value is NULL, then the node was inserted to the beginning of the list. In this case you must ensure that your pointer to the beginning to the list is updated.


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.