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

PointeredList Class Reference

#include <LinkedList.h>

Inheritance diagram for PointeredList:

ContainingList< PointeredListItem > List of all members.

Detailed Description

A PointeredList contains a variable number of items, that are linked like a chain.

This makes enumeration, enqueueing and dequeueing fast, but looking up items by their position slow.

Note:
PointeredLists contain PointeredListItems, that are a little less performant, but may be added twice to the same list, and be added to two different lists. If do not require this, use the ContainingList and ContainingListItem. To use PointeredLists, store your data in the data field of the PointeredListItem.
See also:
See collections.txt for an overview of the available collection classes.

ContainingList

ContainingListItem

Author:
Thomas Jacob

Definition at line 408 of file LinkedList.h.

Public Member Functions

void Append (PointeredListItem *Item)
 Appends an item to the list.

virtual int Compare (const PointeredListItem *Item1, const PointeredListItem *Item2) const
 Compares two items and returns -1, if the first is less than the second, 0, if both items are equal and 1, if the first is more than the second.

bool Delete (PointeredListItem *Item, int(*compare)(const PointeredListItem *Item1, const PointeredListItem *Item2))
 Deletes an item that is equal to a given item from the list.

bool Delete (PointeredListItem *Item)
 Deletes an item that is equal to a given item from the list.

bool Delete (long nr)
 Deletes an given item from the list.

void DeleteAll ()
 Deletes all items from the list.

void DeleteDirectly (PointeredListItem *Item)
 Deletes a given item from the list without looking it up.

bool DeleteFirst ()
 Deletes the first item from the list.

bool DeleteLast ()
 Deletes the last item from the list.

PointeredListItemGet (const PointeredListItem *SearchItem, int(*compare)(const PointeredListItem *Item1, const PointeredListItem *Item2)) const
 Returns an item that is equal to a given item.

PointeredListItemGet (const PointeredListItem *SearchItem) const
 Returns an item that is equal to a given item.

PointeredListItemGet (long nr) const
 Returns the item at a given position.

long GetCount () const
 Returns the number of items in the list.

PointeredListItemGetFirst () const
 Returns the first item of the list.

PointeredListItemGetLast () const
 Returns the last item of the list.

void Insert (PointeredListItem *Item, long nr)
 Inserts an item before a given position.

bool IsEmpty () const
 Returns, if there are no items in the list.

 PointeredList ()
 Creates a new PointeredList.

void Prepend (PointeredListItem *Item)
 Prepends an item to the list.

void Reverse ()
 Turns around the order of all items in the list.

void Sort (int(*compare)(const PointeredListItem *Item1, const PointeredListItem *Item2))
 Sorts the items in the list according to a given comparison function.

void Sort ()
 Sorts the items in the list according to the Compare method.

PointeredListItemUnlink (PointeredListItem *Item, int(*compare)(const PointeredListItem *Item1, const PointeredListItem *Item2))
 Removes an item that is equal to a given item from the list.

PointeredListItemUnlink (PointeredListItem *Item)
 Removes an item that is equal to a given item from the list.

PointeredListItemUnlink (long nr)
 Removes an item at a given position.

void UnlinkAll ()
 Removes all items from the list without freeing them or returning them.

PointeredListItemUnlinkDirectly (PointeredListItem *Item)
 Removes a given item from the list without looking it up.

PointeredListItemUnlinkFirst ()
 Removes the first item of the list.

PointeredListItemUnlinkLast ()
 Removes the last item of the list.

virtual ~PointeredList ()
 Destroys the PointeredList.


Static Public Member Functions

int CaseInsensitiveStringCompare (const PointeredListItem *Item1, const PointeredListItem *Item2)
 Works as compare function, if the data in the PointeredListItems is a pointer to a string.

int CaseSensitiveStringCompare (const PointeredListItem *Item1, const PointeredListItem *Item2)
 Works as compare function, if the data in the PointeredListItems is a pointer to a string.


Constructor & Destructor Documentation

PointeredList  ) 
 

Creates a new PointeredList.

virtual ~PointeredList  )  [virtual]
 

Destroys the PointeredList.

When deleting the list, all contained items are also freed. Since the data is only pointered to and not held in the items, this has no effect to the data in the items.


Member Function Documentation

void Append PointeredListItem Item  )  [inherited]
 

Appends an item to the list.

Parameters:
Item The item to be appended.

int CaseInsensitiveStringCompare const PointeredListItem Item1,
const PointeredListItem Item2
[static]
 

Works as compare function, if the data in the PointeredListItems is a pointer to a string.

This method compared case insensitive.

Parameters:
Item1 The first PointeredListItem to compare.
Item2 The second PointeredListItem to compare.
Returns:
-1, 0 or 1, if Item1<Item2, Item1==Item2 or Item1>Item2.

int CaseSensitiveStringCompare const PointeredListItem Item1,
const PointeredListItem Item2
[static]
 

Works as compare function, if the data in the PointeredListItems is a pointer to a string.

This method compared case sensitive.

Parameters:
Item1 The first PointeredListItem to compare.
Item2 The second PointeredListItem to compare.
Returns:
-1, 0 or 1, if Item1<Item2, Item1==Item2 or Item1>Item2.

virtual int Compare const PointeredListItem Item1,
const PointeredListItem Item2
const [virtual, inherited]
 

Compares two items and returns -1, if the first is less than the second, 0, if both items are equal and 1, if the first is more than the second.

This method is used for comparison method like Delete and Get, if you specify an item to look up. Override this method to provide your own comparison.

Parameters:
Item1 The first item to be compared.
Item2 The second item to be compared.
Returns:
-1, 0 or 1, if Item1<Item2, Item1==Item2 or Item1>Item2.

bool Delete PointeredListItem Item,
int(*  compare)(const PointeredListItem *Item1, const PointeredListItem *Item2)
[inherited]
 

Deletes an item that is equal to a given item from the list.

The item is searched, removed from the list and freed.

Parameters:
Item The item to be deleted.
compare A functions that compares two items and returns -1, if the first is less than the second, 0, if both items are equal and 1, if the first is more than the second.
Returns:
If the deletion was successful.

bool Delete PointeredListItem Item  )  [inherited]
 

Deletes an item that is equal to a given item from the list.

The item is searched using the class's compare method, so override it to set your own comparison. After that, the item is removed from the list and freed.

Parameters:
Item The item to be deleted.
Returns:
If the deletion was successful.

bool Delete long  nr  )  [inherited]
 

Deletes an given item from the list.

The item is removed from the list and freed.

Parameters:
nr The position of the item.
Returns:
If the deletion was successful.

void DeleteAll  )  [inherited]
 

Deletes all items from the list.

All items are removed from the list and freed.

void DeleteDirectly PointeredListItem Item  )  [inline, inherited]
 

Deletes a given item from the list without looking it up.

Use this method to increase performance, but only, if you are sure that the item is in the list. If not, that list will remain inconsistent. The item is removed from the list an freed.

Parameters:
Item The item to be deleted.

bool DeleteFirst  )  [inherited]
 

Deletes the first item from the list.

The item is removed from the list and freed.

Returns:
If the deletion was successful.

bool DeleteLast  )  [inherited]
 

Deletes the last item from the list.

The item is removed from the list and freed.

Returns:
If the deletion was successful.

PointeredListItem * Get const PointeredListItem SearchItem,
int(*  compare)(const PointeredListItem *Item1, const PointeredListItem *Item2)
const [inherited]
 

Returns an item that is equal to a given item.

Parameters:
SearchItem The item to be compared to.
compare A functions that compares two items and returns -1, if the first is less than the second, 0, if both items are equal and 1, if the first is more than the second.
Returns:
The found item or NULL, if the item wasn't found.

PointeredListItem * Get const PointeredListItem SearchItem  )  const [inline, inherited]
 

Returns an item that is equal to a given item.

The item is searched using the class's compare method, so override it to set your own comparison. After that, the item is removed from the list and freed.

Parameters:
SearchItem The item to be compared to.
Returns:
The found item or NULL, if the item wasn't found.

PointeredListItem * Get long  nr  )  const [inherited]
 

Returns the item at a given position.

Parameters:
nr The position of the item.
Returns:
The item at the position.

long GetCount  )  const [inline, inherited]
 

Returns the number of items in the list.

Returns:
The number of items in the list.

PointeredListItem * GetFirst  )  const [inline, inherited]
 

Returns the first item of the list.

Returns:
The first item of the list.

PointeredListItem * GetLast  )  const [inline, inherited]
 

Returns the last item of the list.

Returns:
The last item of the list.

void Insert PointeredListItem Item,
long  nr
[inherited]
 

Inserts an item before a given position.

Parameters:
Item The item to be inserted.
nr The position to insert before.

bool IsEmpty  )  const [inline, inherited]
 

Returns, if there are no items in the list.

void Prepend PointeredListItem Item  )  [inline, inherited]
 

Prepends an item to the list.

Parameters:
Item The item to be prepended.

void Reverse  )  [inherited]
 

Turns around the order of all items in the list.

The whole list has the reverse order afterwards, but is not harmed at all in any other way. All items remain the same.

void Sort int(*  compare)(const PointeredListItem *Item1, const PointeredListItem *Item2)  )  [inherited]
 

Sorts the items in the list according to a given comparison function.

The whole list has a sorted order afterwards, but is not harmed at all in any other way. All items remain the same.

Parameters:
compare A functions that compares two items and returns -1, if the first is less than the second, 0, if both items are equal and 1, if the first is more than the second.

void Sort  )  [inline, inherited]
 

Sorts the items in the list according to the Compare method.

The whole list has a sorted order afterwards, but is not harmed at all in any other way. All items remain the same.

PointeredListItem * Unlink PointeredListItem Item,
int(*  compare)(const PointeredListItem *Item1, const PointeredListItem *Item2)
[inherited]
 

Removes an item that is equal to a given item from the list.

The item is not freed, but returned.

Parameters:
Item The item to be compared.
compare A functions that compares two items and returns -1, if the first is less than the second, 0, if both items are equal and 1, if the first is more than the second.
Returns:
The item.

PointeredListItem * Unlink PointeredListItem Item  )  [inherited]
 

Removes an item that is equal to a given item from the list.

The item is searched using the class's compare method, so override it to set your own comparison. Afterwards, the item is not freed, but returned.

Parameters:
Item The item to be compared.
Returns:
The item.

PointeredListItem * Unlink long  nr  )  [inherited]
 

Removes an item at a given position.

The item is not freed, but returned.

Parameters:
nr The position of the item.
Returns:
The item.

void UnlinkAll  )  [inherited]
 

Removes all items from the list without freeing them or returning them.

Warning:
No item is freed, so you have to have a pointer to the objects, or the memory is lost.

PointeredListItem * UnlinkDirectly PointeredListItem Item  )  [inherited]
 

Removes a given item from the list without looking it up.

Use this method to increase performance, but only, if you are sure that the item is in the list. If not, that list will become inconsistent. Afterwards, the item is not freed, but returned.

Parameters:
nr The position of the item.
Returns:
The item.

PointeredListItem * UnlinkFirst  )  [inline, inherited]
 

Removes the first item of the list.

The item is not freed, but returned.

Returns:
The item.

PointeredListItem * UnlinkLast  )  [inherited]
 

Removes the last item of the list.

The item is not freed, but returned.

Returns:
The item.


The documentation for this class was generated from the following file:
Generated on Tue Oct 3 00:23:40 2006 for ToolBox by doxygen 1.3.6