OrderedList Class Template Reference

A data type that defines an ordered doubly linked list. More...

#include <OrderedList.h>

List of all members.

Public Methods

 OrderedList ()
 Empty constructor, which sets up an empty list.

 OrderedList (const OrderedList< T, V > &list)
 Copy constructor.

virtual ~OrderedList ()
 Destructor. More...

OrderedList< T, V > & operator= (const OrderedList< T, V > &list)
 Copy equals.

OrderedListItem< T, V > * find (V &key)
 Find the OrderedListItem with value data in the list. More...

OrderedListItem< T, V > * head () const
 Returns the head of the ordered list.

OrderedListItem< T, V > * tail () const
 Returns the tail of the ordered list.

OrderedListItem< T, V > * next (OrderedListItem< T, V > *item) const
 Returns the next item in the list after item.

T & top ()
 Returns the value of the next item that will be removed.

void add (T &data, V &key)
 Adds a list item.

void add (T &data, V &key, OrderedListItem< T, V > *&item)
 Adds a list item and returns the OrderedListItem object in the item argument.

void remove (T &data, V &key)
 Removes the first item in the ordered list, returning the values data and key.

void remove (OrderedListItem< T, V > *&item)
 Removes item from the list.

void remove (OrderedListItem< T, V > *&item, T &data, V &key)
 Removes item from the list, returning the values data and key.

void update (OrderedListItem< T, V > *item, V &key)
 Changes the key value for item, and repositions it in the list.

int empty () const
 Returns TRUE if the list is empty and FALSE otherwise.

 operator int () const
 Returns TRUE if the list is empty and FALSE otherwise.

int len () const
 Returns the length of the list.


Protected Methods

void extract (OrderedListItem< T, V > *item, T &data, V &key)
 Removes item from the linked list after extracting its data and key.

void extract (OrderedListItem< T, V > *item)
 Removes item from the linked list.

OrderedListItem< T, V > * insert (T &data, V &key)
 Creates an item in the list from data and key, and returns the pointer to the OrderedListItem.

void extract_all ()
 Removes all items from the list.


Protected Attributes

OrderedListItem< T, V > * first
 The first item in the list.

OrderedListItem< T, V > * last
 The last item in the list.

int Len
 The length of the list.


Static Protected Attributes

int counter = 0
 The number of unused OrderedListItem objects.


Detailed Description

template<class T, class V>
class OrderedList< T, V >

A data type that defines an ordered doubly linked list.

List items are inserted after all other items with equal or lower values for their order parameter. Note that OrderedList is not simply a subclass of LinkedList because we need to maintain a seperate pool of unused OrderedListItems


Constructor & Destructor Documentation

template<class T, class V>
OrderedList< T, V >::~OrderedList   [virtual]
 

Destructor.

After deleting the list, the destructor deletes the list of additional unused OrderedListItem objects.


Member Function Documentation

template<class T, class V>
OrderedListItem< T, V > * OrderedList< T, V >::find V &    key
 

Find the OrderedListItem with value data in the list.

If this data value is not found in the list, this method returns NULL.


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