SLikeNet 0.1.3

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- Class List
- Class Index
- Class Hierarchy
- Class Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Classes | Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
DataStructures::CircularLinkedList< CircularLinkedListType > Class Template Reference

(Circular) Linked List ADT (Doubly Linked Pointer to Node Style) - More...

`#include <slikenet/DS_LinkedList.h>`

Inheritance diagram for DataStructures::CircularLinkedList< CircularLinkedListType >:

## Classes

struct | node

## Public Member Functions

| CircularLinkedList ()
| ~CircularLinkedList ()
| CircularLinkedList (const CircularLinkedList &original_copy)
bool | operator= (const CircularLinkedList &original_copy)
CircularLinkedList & | operator++ ()
CircularLinkedList & | operator++ (int)
CircularLinkedList & | operator-- ()
CircularLinkedList & | operator-- (int)
bool | IsIn (const CircularLinkedListType &input)
bool | Find (const CircularLinkedListType &input)
void | Insert (const CircularLinkedListType &input)
CircularLinkedListType & | Add (const CircularLinkedListType &input)
void | Replace (const CircularLinkedListType &input)
void | Del (void)
unsigned int | Size (void)
CircularLinkedListType & | Peek (void)
CircularLinkedListType | Pop (void)
void | Clear (void)
void | Sort (void)
void | Beginning (void)
void | End (void)
void | Concatenate (const CircularLinkedList &L)

## Protected Member Functions

node * | FindPointer (const CircularLinkedListType &input)

## Protected Attributes

unsigned int | list_size
node * | root
node * | position

## Detailed Description

### template<class CircularLinkedListType>
class DataStructures::CircularLinkedList< CircularLinkedListType >

(Circular) Linked List ADT (Doubly Linked Pointer to Node Style) -

Initilize with the following command LinkedList<TYPE> OR CircularLinkedList<Type>

Has the following member functions

- size: returns number of elements in the linked list
- insert(item): inserts item at the current position in the LinkedList.
- add(item): inserts item after the current position in the LinkedList. Does not increment the position
- replace(item): replaces the element at the current position item.
- peek: returns the element at the current position
- pop: returns the element at the current position and deletes it
- del: deletes the current element. Does nothing for an empty list.
- clear: empties the LinkedList and returns storage
- bool IsInitem): Does a linear search for item. Does not set the position to it, only returns true on item found, false otherwise
- bool find(item): Does a linear search for item and sets the current position to point to it if and only if the item is found. Returns true on item found, false otherwise
- sort: Sorts the elements of the list with a mergesort and sets the current pointer to the first element
- concatenate(list L): This appends L to the current list
- ++(prefix): moves the pointer one element up in the list and returns the appropriate copy of the element in the list
- –(prefix): moves the pointer one element back in the list and returns the appropriate copy of the element in the list
- beginning - moves the pointer to the start of the list. For circular linked lists this is first 'position' created. You should call this after the sort function to read the first value.
- end - moves the pointer to the end of the list. For circular linked lists this is one less than the first 'position' created The assignment and copy constructor operators are defined

Note
  1. LinkedList and CircularLinkedList are exactly the same except LinkedList won't let you wrap around the root and lets you jump to two positions relative to the root/
  2. Postfix ++ and – can be used but simply call the prefix versions.

EXAMPLE:

LinkedList<int> A; // Creates a Linked List of integers called A
CircularLinkedList<int> B; // Creates a Circular Linked List of
// integers called B
A.Insert(20); // Adds 20 to A. A: 20 - current is 20
A.Insert(5); // Adds 5 to A. A: 5 20 - current is 5
A.Insert(1); // Adds 1 to A. A: 1 5 20 - current is 1
A.IsIn1); // returns true
A.IsIn200); // returns false
A.Find(5); // returns true and sets current to 5
A.Peek(); // returns 5
A.Find(1); // returns true and sets current to 1
(++A).Peek(); // Returns 5
A.Peek(); // Returns 5
A.Replace(10); // Replaces 5 with 10.
A.Peek(); // Returns 10
A.Beginning(); // Current points to the beginning of the list at 1
(++A).Peek(); // Returns 5
A.Peek(); // Returns 10
A.Del(); // Deletes 10. Current points to the next element, which is 20
A.Peek(); // Returns 20
A.Beginning(); // Current points to the beginning of the list at 1
(++A).Peek(); // Returns 5
A.Peek(); // Returns 20
A.Clear(_FILE_AND_LINE_); // Deletes all nodes in A
A.Insert(5); // A: 5 - current is 5
A.Insert(6); // A: 6 5 - current is 6
A.Insert(7); // A: 7 6 5 - current is 7
A.Clear(_FILE_AND_LINE_);
B.Clear(_FILE_AND_LINE_);
B.Add(10);
B.Add(20);
B.Add(30);
B.Add(5);
B.Add(2);
B.Add(25);
// Sorts the numbers in the list and sets the current pointer to the
// first element
B.sort();
// Postfix ++ just calls the prefix version and has no functional
// difference.
B.Peek(); // Returns 2
B++;
B.Peek(); // Returns 5
B++;
B.Peek(); // Returns 10
B++;
B.Peek(); // Returns 20
B++;
B.Peek(); // Returns 25
B++;
B.Peek(); // Returns 30

Definition at line 153 of file DS_LinkedList.h.

## Class Documentation

struct DataStructures::CircularLinkedList::node

### template<class CircularLinkedListType>
struct DataStructures::CircularLinkedList< CircularLinkedListType >::node

Definition at line 158 of file DS_LinkedList.h.

Class Members
CircularLinkedListType | item |
node * | next |
node * | previous |

## Constructor & Destructor Documentation

template<class CircularLinkedListType >

DataStructures::CircularLinkedList< CircularLinkedListType >::CircularLinkedList | ( |  | ) |

Definition at line 347 of file DS_LinkedList.h.

template<class CircularLinkedListType >

DataStructures::CircularLinkedList< CircularLinkedListType >::~CircularLinkedList | ( |  | ) |

Definition at line 355 of file DS_LinkedList.h.

template<class CircularLinkedListType >

DataStructures::CircularLinkedList< CircularLinkedListType >::CircularLinkedList | ( | const CircularLinkedList< CircularLinkedListType > & | original_copy | ) |

Definition at line 446 of file DS_LinkedList.h.

References _FILE_AND_LINE_, DataStructures::CircularLinkedList< CircularLinkedListType >::node::item, DataStructures::CircularLinkedList< CircularLinkedListType >::list_size, DataStructures::CircularLinkedList< CircularLinkedListType >::node::next, DataStructures::CircularLinkedList< CircularLinkedListType >::position, DataStructures::CircularLinkedList< CircularLinkedListType >::node::previous, return, and DataStructures::CircularLinkedList< CircularLinkedListType >::root.

## Member Function Documentation

template<class CircularLinkedListType>

CircularLinkedListType & DataStructures::CircularLinkedList< CircularLinkedListType >::Add | ( | const CircularLinkedListType & | input | ) |

Definition at line 695 of file DS_LinkedList.h.

References _FILE_AND_LINE_, DataStructures::CircularLinkedList< CircularLinkedListType >::node::item, DataStructures::CircularLinkedList< CircularLinkedListType >::node::next, and DataStructures::CircularLinkedList< CircularLinkedListType >::node::previous.

template<class CircularLinkedListType >

void DataStructures::CircularLinkedList< CircularLinkedListType >::Beginning | ( | void |  | ) |

inline

Definition at line 242 of file DS_LinkedList.h.

template<class CircularLinkedListType >

void DataStructures::CircularLinkedList< CircularLinkedListType >::Clear | ( | void |  | ) |

Definition at line 953 of file DS_LinkedList.h.

References _FILE_AND_LINE_, DataStructures::CircularLinkedList< CircularLinkedListType >::node::next, SLNet::OP_DELETE(), and return.

template<class CircularLinkedListType >

void DataStructures::CircularLinkedList< CircularLinkedListType >::Concatenate | ( | const CircularLinkedList< CircularLinkedListType > & | L | ) |

inline

Definition at line 987 of file DS_LinkedList.h.

References DataStructures::CircularLinkedList< CircularLinkedListType >::node::item, DataStructures::CircularLinkedList< CircularLinkedListType >::list_size, DataStructures::CircularLinkedList< CircularLinkedListType >::node::next, return, and DataStructures::CircularLinkedList< CircularLinkedListType >::root.

template<class CircularLinkedListType >

void DataStructures::CircularLinkedList< CircularLinkedListType >::Del | ( | void |  | ) |

Definition at line 779 of file DS_LinkedList.h.

References _FILE_AND_LINE_, DataStructures::CircularLinkedList< CircularLinkedListType >::node::next, SLNet::OP_DELETE(), and return.

template<class CircularLinkedListType >

void DataStructures::CircularLinkedList< CircularLinkedListType >::End | ( | void |  | ) |

inline

Definition at line 249 of file DS_LinkedList.h.

template<class CircularLinkedListType>

bool DataStructures::CircularLinkedList< CircularLinkedListType >::Find | ( | const CircularLinkedListType & | input | ) |

Definition at line 830 of file DS_LinkedList.h.

template<class CircularLinkedListType>

CircularLinkedList< CircularLinkedListType >::node * DataStructures::CircularLinkedList< CircularLinkedListType >::FindPointer | ( | const CircularLinkedListType & | input | ) |

protected

Definition at line 847 of file DS_LinkedList.h.

References DataStructures::CircularLinkedList< CircularLinkedListType >::node::item, and DataStructures::CircularLinkedList< CircularLinkedListType >::node::next.

template<class CircularLinkedListType>

void DataStructures::CircularLinkedList< CircularLinkedListType >::Insert | ( | const CircularLinkedListType & | input | ) |

Definition at line 618 of file DS_LinkedList.h.

References _FILE_AND_LINE_, DataStructures::CircularLinkedList< CircularLinkedListType >::node::item, DataStructures::CircularLinkedList< CircularLinkedListType >::node::next, and DataStructures::CircularLinkedList< CircularLinkedListType >::node::previous.

template<class CircularLinkedListType>

bool DataStructures::CircularLinkedList< CircularLinkedListType >::IsIn | ( | const CircularLinkedListType & | input | ) |

Definition at line 814 of file DS_LinkedList.h.

template<class CircularLinkedListType >

CircularLinkedList< CircularLinkedListType > & DataStructures::CircularLinkedList< CircularLinkedListType >::operator++ | ( |  | ) |

Definition at line 898 of file DS_LinkedList.h.

template<class CircularLinkedListType >

CircularLinkedList< CircularLinkedListType > & DataStructures::CircularLinkedList< CircularLinkedListType >::operator++ | ( | int |  | ) |

Definition at line 919 of file DS_LinkedList.h.

template<class CircularLinkedListType >

CircularLinkedList< CircularLinkedListType > & DataStructures::CircularLinkedList< CircularLinkedListType >::operator-- | ( |  | ) |

Definition at line 926 of file DS_LinkedList.h.

template<class CircularLinkedListType >

CircularLinkedList< CircularLinkedListType > & DataStructures::CircularLinkedList< CircularLinkedListType >::operator-- | ( | int |  | ) |

Definition at line 947 of file DS_LinkedList.h.

template<class CircularLinkedListType >

bool DataStructures::CircularLinkedList< CircularLinkedListType >::operator= | ( | const CircularLinkedList< CircularLinkedListType > & | original_copy | ) |

Definition at line 529 of file DS_LinkedList.h.

References _FILE_AND_LINE_, DataStructures::CircularLinkedList< CircularLinkedListType >::node::item, DataStructures::CircularLinkedList< CircularLinkedListType >::list_size, DataStructures::CircularLinkedList< CircularLinkedListType >::node::next, DataStructures::CircularLinkedList< CircularLinkedListType >::position, DataStructures::CircularLinkedList< CircularLinkedListType >::node::previous, and DataStructures::CircularLinkedList< CircularLinkedListType >::root.

template<class CircularLinkedListType >

CircularLinkedListType & DataStructures::CircularLinkedList< CircularLinkedListType >::Peek | ( | void |  | ) |

inline

Definition at line 881 of file DS_LinkedList.h.

template<class CircularLinkedListType >

CircularLinkedListType DataStructures::CircularLinkedList< CircularLinkedListType >::Pop | ( | void |  | ) |

Definition at line 888 of file DS_LinkedList.h.

template<class CircularLinkedListType>

void DataStructures::CircularLinkedList< CircularLinkedListType >::Replace | ( | const CircularLinkedListType & | input | ) |

inline

Definition at line 771 of file DS_LinkedList.h.

template<class CircularLinkedListType >

unsigned int DataStructures::CircularLinkedList< CircularLinkedListType >::Size | ( | void |  | ) |

inline

Definition at line 875 of file DS_LinkedList.h.

template<class CircularLinkedListType >

void DataStructures::CircularLinkedList< CircularLinkedListType >::Sort | ( | void |  | ) |

inline

Definition at line 1018 of file DS_LinkedList.h.

References return.

## Member Data Documentation

template<class CircularLinkedListType>

unsigned int DataStructures::CircularLinkedList< CircularLinkedListType >::list_size

protected

Definition at line 203 of file DS_LinkedList.h.

Referenced by DataStructures::CircularLinkedList< CircularLinkedListType >::CircularLinkedList(), DataStructures::CircularLinkedList< CircularLinkedListType >::Concatenate(), DataStructures::LinkedList< LinkedListType >::LinkedList(), and DataStructures::CircularLinkedList< CircularLinkedListType >::operator=().

template<class CircularLinkedListType>

node* DataStructures::CircularLinkedList< CircularLinkedListType >::position

protected

Definition at line 207 of file DS_LinkedList.h.

Referenced by DataStructures::CircularLinkedList< CircularLinkedListType >::CircularLinkedList(), DataStructures::LinkedList< LinkedListType >::LinkedList(), and DataStructures::CircularLinkedList< CircularLinkedListType >::operator=().

template<class CircularLinkedListType>

node* DataStructures::CircularLinkedList< CircularLinkedListType >::root

protected

Definition at line 205 of file DS_LinkedList.h.

Referenced by DataStructures::CircularLinkedList< CircularLinkedListType >::CircularLinkedList(), DataStructures::CircularLinkedList< CircularLinkedListType >::Concatenate(), DataStructures::LinkedList< LinkedListType >::LinkedList(), and DataStructures::CircularLinkedList< CircularLinkedListType >::operator=().

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

- Source/include/slikenet/DS_LinkedList.h