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

DoubleLinkedList which can be iterated via DoubleLinkedList::iterator. More...

#include <DoubleLinkedList.h>

Public Types

typedef T value_type
 Convenience typedef of the type of values in this list. More...
 
typedef Experiment::Iterator< value_type, DoubleLinkedList< value_type >, Nodeiterator
 Convenience typedef of iterators of this list. More...
 

Public Member Functions

 ~DoubleLinkedList ()
 Destroy a list. More...
 
 DoubleLinkedList ()
 Create a new list. More...
 
 DoubleLinkedList (const DoubleLinkedList &rhs)
 Copy data from another list. More...
 
void clear ()
 Remove all data from this list. More...
 
bool isEmpty () const
 
iterator begin ()
 
iterator end ()
 
void push_front (const value_type &value)
 Insert value as the first item in this list and udpate iterators to remain at same position. More...
 
void push_back (const value_type &value)
 Insert value as the last item in this list. More...
 
void addIterator (iterator *iter)
 Record that iter has been created as an iterator of this list. More...
 
void removeIterator (iterator *iter)
 Record that iter that is being destroyed as an iterator of this list. More...
 
void notifyItersSwapOccurred (Node *a, Node *b) const
 Notify all iterators that a swap occurred of nodes a and b so that they can update themselves to keep the same position. More...
 
void notifyItersInsertedBefore (int count, Node *firstAfter) const
 Notify all iterators that count Nodes were inserted before firstAfter. More...
 
void notifyItersRemovedBefore (int count, Node *firstAfter) const
 Notify all iterators that count Nodes were removed before firstAfter. More...
 

Detailed Description

template<class T>
class Experiment::DoubleLinkedList< T >

DoubleLinkedList which can be iterated via DoubleLinkedList::iterator.

Template Parameters
Tthe type of Data this DoubleLinkedList will hold
Examples
DoubleLinkedListExample.cpp, and ListMergeSortExample.cpp.

Definition at line 36 of file DoubleLinkedList.h.

Member Typedef Documentation

◆ iterator

Convenience typedef of iterators of this list.

Definition at line 48 of file DoubleLinkedList.h.

◆ value_type

template<class T >
typedef T Experiment::DoubleLinkedList< T >::value_type

Convenience typedef of the type of values in this list.

Definition at line 45 of file DoubleLinkedList.h.

Constructor & Destructor Documentation

◆ ~DoubleLinkedList()

template<typename T >
Experiment::DoubleLinkedList< T >::~DoubleLinkedList

Destroy a list.

Note
If the value_type is a pointer, the pointers will not be deleted.

Definition at line 31 of file DoubleLinkedList.cpp.

◆ DoubleLinkedList() [1/2]

template<typename T >
Experiment::DoubleLinkedList< T >::DoubleLinkedList

Create a new list.

Definition at line 46 of file DoubleLinkedList.cpp.

◆ DoubleLinkedList() [2/2]

template<typename T >
Experiment::DoubleLinkedList< T >::DoubleLinkedList ( const DoubleLinkedList< T > &  rhs)

Copy data from another list.

Parameters
rhsto copy from

Definition at line 62 of file DoubleLinkedList.cpp.

Member Function Documentation

◆ addIterator()

template<typename T >
void Experiment::DoubleLinkedList< T >::addIterator ( iterator iter)

Record that iter has been created as an iterator of this list.

Todo:
add erase method
Todo:
add insert method
Parameters
iterto add
Todo:
Conceal this from public access

Definition at line 154 of file DoubleLinkedList.cpp.

◆ begin()

template<typename T >
DoubleLinkedList< T >::iterator Experiment::DoubleLinkedList< T >::begin
Returns
an iterator pointing to the first element of this list
Note
isEmpty() returns true if begin() == end()
Examples
DoubleLinkedListExample.cpp.

Definition at line 110 of file DoubleLinkedList.cpp.

◆ clear()

template<typename T >
void Experiment::DoubleLinkedList< T >::clear

Remove all data from this list.

Note
If the value_type is a pointer, the pointers will not be deleted.

Definition at line 84 of file DoubleLinkedList.cpp.

◆ end()

template<typename T >
DoubleLinkedList< T >::iterator Experiment::DoubleLinkedList< T >::end
Returns
an iterator pointing beyond the last element of this list
Note
isEmpty() returns true if begin() == end()
Examples
DoubleLinkedListExample.cpp.

Definition at line 119 of file DoubleLinkedList.cpp.

◆ isEmpty()

template<typename T >
bool Experiment::DoubleLinkedList< T >::isEmpty
Returns
true if this list has not data, otherwise false

Definition at line 101 of file DoubleLinkedList.cpp.

◆ notifyItersInsertedBefore()

template<typename T >
void Experiment::DoubleLinkedList< T >::notifyItersInsertedBefore ( int  count,
Node firstAfter 
) const

Notify all iterators that count Nodes were inserted before firstAfter.

Notifies each iterator that each node from firstAfter that has been moved count times.

Parameters
countnumber of nodes added
firstAfterfirst node after the added nodes to update from
Note
This comes from iter rather than Node because Node doesn't know about list
Todo:
Conceal this from public access

Definition at line 214 of file DoubleLinkedList.cpp.

◆ notifyItersRemovedBefore()

template<typename T >
void Experiment::DoubleLinkedList< T >::notifyItersRemovedBefore ( int  count,
Node firstAfter 
) const

Notify all iterators that count Nodes were removed before firstAfter.

Notifies each iterator that each node from firstAfter to move count times.

Parameters
countnumber of nodes removed
firstAfterfirst node after the removed nodes to update from
Note
This comes from iter rather than Node because Node doesn't know about list
Todo:
Conceal this from public access

Definition at line 234 of file DoubleLinkedList.cpp.

◆ notifyItersSwapOccurred()

template<typename T >
void Experiment::DoubleLinkedList< T >::notifyItersSwapOccurred ( Node a,
Node b 
) const

Notify all iterators that a swap occurred of nodes a and b so that they can update themselves to keep the same position.

Since only a and b are altered, we note this so all other iterators can disregard.

Parameters
athat swapped position with b
bthat swapped position with a
Note
This comes from iter rather than Node because Node doesn't know about list
Todo:
Conceal this from public access

Definition at line 196 of file DoubleLinkedList.cpp.

◆ push_back()

template<typename T >
void Experiment::DoubleLinkedList< T >::push_back ( const value_type value)

Insert value as the last item in this list.

Examples
DoubleLinkedListExample.cpp, and ListMergeSortExample.cpp.

Definition at line 139 of file DoubleLinkedList.cpp.

◆ push_front()

template<typename T >
void Experiment::DoubleLinkedList< T >::push_front ( const value_type value)

Insert value as the first item in this list and udpate iterators to remain at same position.

Parameters
valueto insert at the start of the list

Definition at line 129 of file DoubleLinkedList.cpp.

◆ removeIterator()

template<typename T >
void Experiment::DoubleLinkedList< T >::removeIterator ( iterator iter)

Record that iter that is being destroyed as an iterator of this list.

Parameters
iterto remove
Todo:
Conceal this from public access

Definition at line 169 of file DoubleLinkedList.cpp.


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