Main Page | Modules | Namespace List | Class Hierarchy | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

# BasicDataStructures::CircularLinkedList< CircularLinkedListType > Class Template Reference

`#include <LinkedList.h>`

List of all members.

## 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 | is_in (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 long | size (void)
CircularLinkedListType & | peek (void)
const CircularLinkedListType | pop (void)
void | clear (void)
void | sort (void)
void | beginning (void)
void | end (void)
void | concatenate (const CircularLinkedList &L)
## Protected Member Functions
node * | find_pointer (const CircularLinkedListType &input)
## Protected Attributes
unsigned long | list_size
node * | root
node * | position
## Private Member Functions
CircularLinkedList | merge (CircularLinkedList L1, CircularLinkedList L2)
CircularLinkedList | mergesort (const CircularLinkedList &L)
## Classes
struct | node

## Detailed Description

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

(Circular) Linked List ADT (Doubly Linked Pointer to Node Style) - By Kevin Jenkins (http://www.rakkar.org) 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 is_in(item): 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.is_in(1); // returns true
     A.is_in(200); // 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();  // 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();
     B.clear();

     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

## Constructor & Destructor Documentation

template<class CircularLinkedListType>
BasicDataStructures::CircularLinkedList< CircularLinkedListType >::CircularLinkedList | ( |  | ) |

template<class CircularLinkedListType>
BasicDataStructures::CircularLinkedList< CircularLinkedListType >::~CircularLinkedList | ( |  | ) |

template<class CircularLinkedListType>
BasicDataStructures::CircularLinkedList< CircularLinkedListType >::CircularLinkedList | ( | const CircularLinkedList< CircularLinkedListType > & | original_copy | ) |

## Member Function Documentation

template<class CircularLinkedListType>
CircularLinkedListType & BasicDataStructures::CircularLinkedList< CircularLinkedListType >::add | ( | const CircularLinkedListType & | input | ) |

template<class CircularLinkedListType>
void BasicDataStructures::CircularLinkedList< CircularLinkedListType >::beginning | ( | void |  | ) | `[inline]`

template<class CircularLinkedListType>
void BasicDataStructures::CircularLinkedList< CircularLinkedListType >::clear | ( | void |  | ) |

template<class CircularLinkedListType>
void BasicDataStructures::CircularLinkedList< CircularLinkedListType >::concatenate | ( | const CircularLinkedList< CircularLinkedListType > & | L | ) | `[inline]`

template<class CircularLinkedListType>
void BasicDataStructures::CircularLinkedList< CircularLinkedListType >::del | ( | void |  | ) |

template<class CircularLinkedListType>
void BasicDataStructures::CircularLinkedList< CircularLinkedListType >::end | ( | void |  | ) | `[inline]`

template<class CircularLinkedListType>
bool BasicDataStructures::CircularLinkedList< CircularLinkedListType >::find | ( | const CircularLinkedListType & | input | ) |

template<class CircularLinkedListType>
CircularLinkedList< CircularLinkedListType >::node * BasicDataStructures::CircularLinkedList< CircularLinkedListType >::find_pointer | ( | const CircularLinkedListType & | input | ) | `[protected]`

template<class CircularLinkedListType>
void BasicDataStructures::CircularLinkedList< CircularLinkedListType >::insert | ( | const CircularLinkedListType & | input | ) |

template<class CircularLinkedListType>
bool BasicDataStructures::CircularLinkedList< CircularLinkedListType >::is_in | ( | const CircularLinkedListType & | input | ) |

template<class CircularLinkedListType>
CircularLinkedList< CircularLinkedListType > BasicDataStructures::CircularLinkedList< CircularLinkedListType >::merge | ( | CircularLinkedList< CircularLinkedListType > | L1,
|  | CircularLinkedList< CircularLinkedListType > | L2
| ) | `[private]`

template<class CircularLinkedListType>
CircularLinkedList< CircularLinkedListType > BasicDataStructures::CircularLinkedList< CircularLinkedListType >::mergesort | ( | const CircularLinkedList< CircularLinkedListType > & | L | ) | `[private]`

template<class CircularLinkedListType>
CircularLinkedList< CircularLinkedListType > & BasicDataStructures::CircularLinkedList< CircularLinkedListType >::operator++ | ( | int |  | ) |

| Reimplemented in BasicDataStructures::LinkedList< LinkedListType >, BasicDataStructures::LinkedList< InternalPacket * >, and BasicDataStructures::LinkedList< QueueType >.

template<class CircularLinkedListType>
CircularLinkedList< CircularLinkedListType > & BasicDataStructures::CircularLinkedList< CircularLinkedListType >::operator++ | ( |  | ) |

| Reimplemented in BasicDataStructures::LinkedList< LinkedListType >, BasicDataStructures::LinkedList< InternalPacket * >, and BasicDataStructures::LinkedList< QueueType >.

template<class CircularLinkedListType>
CircularLinkedList< CircularLinkedListType > & BasicDataStructures::CircularLinkedList< CircularLinkedListType >::operator-- | ( | int |  | ) |

| Reimplemented in BasicDataStructures::LinkedList< LinkedListType >, BasicDataStructures::LinkedList< InternalPacket * >, and BasicDataStructures::LinkedList< QueueType >.

template<class CircularLinkedListType>
CircularLinkedList< CircularLinkedListType > & BasicDataStructures::CircularLinkedList< CircularLinkedListType >::operator-- | ( |  | ) |

| Reimplemented in BasicDataStructures::LinkedList< LinkedListType >, BasicDataStructures::LinkedList< InternalPacket * >, and BasicDataStructures::LinkedList< QueueType >.

template<class CircularLinkedListType>
bool BasicDataStructures::CircularLinkedList< CircularLinkedListType >::operator= | ( | const CircularLinkedList< CircularLinkedListType > & | original_copy | ) |

template<class CircularLinkedListType>
CircularLinkedListType & BasicDataStructures::CircularLinkedList< CircularLinkedListType >::peek | ( | void |  | ) | `[inline]`

template<class CircularLinkedListType>
const CircularLinkedListType BasicDataStructures::CircularLinkedList< CircularLinkedListType >::pop | ( | void |  | ) |

template<class CircularLinkedListType>
void BasicDataStructures::CircularLinkedList< CircularLinkedListType >::replace | ( | const CircularLinkedListType & | input | ) | `[inline]`

template<class CircularLinkedListType>
unsigned long BasicDataStructures::CircularLinkedList< CircularLinkedListType >::size | ( | void |  | ) | `[inline]`

template<class CircularLinkedListType>
void BasicDataStructures::CircularLinkedList< CircularLinkedListType >::sort | ( | void |  | ) | `[inline]`

## Member Data Documentation

template<class CircularLinkedListType>
unsigned long BasicDataStructures::CircularLinkedList< CircularLinkedListType >::list_size`[protected]`

template<class CircularLinkedListType>
node* BasicDataStructures::CircularLinkedList< CircularLinkedListType >::position`[protected]`

template<class CircularLinkedListType>
node* BasicDataStructures::CircularLinkedList< CircularLinkedListType >::root`[protected]`

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

- Projects/raknet/include/raknet/LinkedList.h