Experimental Code
Code Written To Experiment With Various Techniques And Otherwise Not Very Useful...
Experiment::Iterator< T, List, Node > Class Template Reference

Iterator class that works genericly on a List containing Node elements with data of type T. More...

#include <Iterator.h>

Public Member Functions

 ~Iterator ()
 Destroy iterator. More...
 
 Iterator (List *theList, Node *at)
 Create Iterator for theList at the value of at. More...
 
 Iterator (const Iterator &rhs)
 Create Iterator at the same position of the same list as rhs. More...
 
Iteratoroperator= (const Iterator &rhs)
 Update Iterator to be at the same position of the same list as rhs. More...
 
bool operator== (const Iterator &rhs) const
 
bool operator!= (const Iterator &rhs) const
 
Iteratoroperator++ ()
 Advance this iterator one position and return this iterator. More...
 
Iterator operator++ (int)
 Advance this iterator one position and return a temporary iterator at the original position. More...
 
Iteratoroperator+= (int positions)
 Advance this iterator positions, if possible, and return this iterator. More...
 
Iterator operator+ (int positions)
 
Iteratoroperator-- ()
 Decrement this iterator one position and return this iterator. More...
 
Iterator operator-- (int)
 Decrement this iterator one position and return a temporary iterator at the original position. More...
 
Iteratoroperator-= (int positions)
 Decrement this iterator positions, if possible, and return this iterator. More...
 
Iterator operator- (int positions)
 
void swapWith (Iterator &other)
 Swap the values at this and other iterators. More...
 
void moveBefore (Iterator &other)
 Move the value at this itherator before the value at other. More...
 
T & operator* ()
 
T * operator-> ()
 
void swapOccurred (Node *a, Node *b)
 Update this iterator, if appropriate, that the values at a and b swapped positions. More...
 
void insertedBefore (Node *after, int count)
 Update this iterator, if appropriate, that count positions were added before after. More...
 
void removedBefore (Node *after, int count)
 Update this iterator, if appropriate, that count positions were removed before after. More...
 

Detailed Description

template<class T, class List, class Node>
class Experiment::Iterator< T, List, Node >

Iterator class that works genericly on a List containing Node elements with data of type T.

These are created by the lists themselves.

Template Parameters
Tthe type of data held by the Nodes
Listthe type of list this iterates
Nodethe type of Node in the list
Examples
DoubleLinkedListExample.cpp.

Definition at line 33 of file Iterator.h.

Constructor & Destructor Documentation

◆ ~Iterator()

template<typename T , typename List , typename Node >
Experiment::Iterator< T, List, Node >::~Iterator

Destroy iterator.

Definition at line 25 of file Iterator.cpp.

◆ Iterator() [1/2]

template<typename T , typename List , typename Node >
Experiment::Iterator< T, List, Node >::Iterator ( List *  theList,
Node *  at 
)

Create Iterator for theList at the value of at.

Parameters
theListto iterate
atstart iterating from at

Definition at line 36 of file Iterator.cpp.

◆ Iterator() [2/2]

template<typename T , typename List , typename Node >
Experiment::Iterator< T, List, Node >::Iterator ( const Iterator< T, List, Node > &  rhs)

Create Iterator at the same position of the same list as rhs.

Parameters
rhsto create at the same position of the same list as

Definition at line 47 of file Iterator.cpp.

Member Function Documentation

◆ insertedBefore()

template<typename T , typename List , typename Node >
void Experiment::Iterator< T, List, Node >::insertedBefore ( Node *  after,
int  count 
)

Update this iterator, if appropriate, that count positions were added before after.

Parameters
countof items inserted before after
afternode that has had count items added before it
Todo:
Conceal from public access.

Definition at line 270 of file Iterator.cpp.

◆ moveBefore()

template<typename T , typename List , typename Node >
void Experiment::Iterator< T, List, Node >::moveBefore ( Iterator< T, List, Node > &  other)

Move the value at this itherator before the value at other.

Parameters
otheriterator to move the value of this iterator before

Definition at line 208 of file Iterator.cpp.

◆ operator!=()

template<typename T , typename List , typename Node >
bool Experiment::Iterator< T, List, Node >::operator!= ( const Iterator< T, List, Node > &  rhs) const
Returns
true if this iterator is not at the same position in the same list as rhs, otherwise false
Parameters
rhsto compare position against

Definition at line 86 of file Iterator.cpp.

◆ operator*()

template<typename T , typename List , typename Node >
T & Experiment::Iterator< T, List, Node >::operator*
Returns
the value at this iterator, if any
Exceptions
std::out_of_rangeif this is not at a valid position

Definition at line 227 of file Iterator.cpp.

◆ operator+()

template<typename T , typename List , typename Node >
Iterator< T, List, Node > Experiment::Iterator< T, List, Node >::operator+ ( int  positions)
Returns
an Iterator advanced positions from this iterator
Parameters
positionsto advance the returned iterator

Definition at line 138 of file Iterator.cpp.

◆ operator++() [1/2]

template<typename T , typename List , typename Node >
Iterator< T, List, Node > & Experiment::Iterator< T, List, Node >::operator++

Advance this iterator one position and return this iterator.

Returns
this iterator after advancement

Definition at line 95 of file Iterator.cpp.

◆ operator++() [2/2]

template<typename T , typename List , typename Node >
Iterator< T, List, Node > Experiment::Iterator< T, List, Node >::operator++ ( int  )

Advance this iterator one position and return a temporary iterator at the original position.

Returns
the temporary iterator at the original position

Definition at line 106 of file Iterator.cpp.

◆ operator+=()

template<typename T , typename List , typename Node >
Iterator< T, List, Node > & Experiment::Iterator< T, List, Node >::operator+= ( int  positions)

Advance this iterator positions, if possible, and return this iterator.

Parameters
positionsto advance
Returns
this iterator

Definition at line 119 of file Iterator.cpp.

◆ operator-()

template<typename T , typename List , typename Node >
Iterator< T, List, Node > Experiment::Iterator< T, List, Node >::operator- ( int  positions)
Returns
an Iterator decremented positions from this iterator
Parameters
positionsto decrement the returned iterator

Definition at line 183 of file Iterator.cpp.

◆ operator--() [1/2]

template<typename T , typename List , typename Node >
Iterator< T, List, Node > & Experiment::Iterator< T, List, Node >::operator--

Decrement this iterator one position and return this iterator.

Returns
this iterator after decrement

Definition at line 149 of file Iterator.cpp.

◆ operator--() [2/2]

template<typename T , typename List , typename Node >
Iterator< T, List, Node > Experiment::Iterator< T, List, Node >::operator-- ( int  )

Decrement this iterator one position and return a temporary iterator at the original position.

Returns
the temporary iterator at the original position

Definition at line 160 of file Iterator.cpp.

◆ operator-=()

template<typename T , typename List , typename Node >
Iterator< T, List, Node > & Experiment::Iterator< T, List, Node >::operator-= ( int  positions)

Decrement this iterator positions, if possible, and return this iterator.

Parameters
positionsto advance
Returns
this iterator

Definition at line 173 of file Iterator.cpp.

◆ operator->()

template<typename T , typename List , typename Node >
T * Experiment::Iterator< T, List, Node >::operator->
Returns
a pointer to the value at this iterator, if any
Exceptions
std::out_of_rangeif this is not at a valid position

Definition at line 240 of file Iterator.cpp.

◆ operator=()

template<typename T , typename List , typename Node >
Iterator< T, List, Node > & Experiment::Iterator< T, List, Node >::operator= ( const Iterator< T, List, Node > &  rhs)

Update Iterator to be at the same position of the same list as rhs.

Parameters
rhsto update to the the same position of the same list as

Definition at line 58 of file Iterator.cpp.

◆ operator==()

template<typename T , typename List , typename Node >
bool Experiment::Iterator< T, List, Node >::operator== ( const Iterator< T, List, Node > &  rhs) const
Returns
true if this iterator is at the same position in the same list as rhs, otherwise false
Parameters
rhsto compare position against

Definition at line 76 of file Iterator.cpp.

◆ removedBefore()

template<typename T , typename List , typename Node >
void Experiment::Iterator< T, List, Node >::removedBefore ( Node *  after,
int  count 
)

Update this iterator, if appropriate, that count positions were removed before after.

Parameters
countof items removed before after
afternode that has had count items removed before it
Todo:
Conceal from public access.

Definition at line 285 of file Iterator.cpp.

◆ swapOccurred()

template<typename T , typename List , typename Node >
void Experiment::Iterator< T, List, Node >::swapOccurred ( Node *  a,
Node *  b 
)

Update this iterator, if appropriate, that the values at a and b swapped positions.

Parameters
aNode that swapped with b
bNode that swapped with a
Todo:
Conceal from public access.

Definition at line 253 of file Iterator.cpp.

◆ swapWith()

template<typename T , typename List , typename Node >
void Experiment::Iterator< T, List, Node >::swapWith ( Iterator< T, List, Node > &  other)

Swap the values at this and other iterators.

Parameters
otheriterator to swap values with

Definition at line 194 of file Iterator.cpp.


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