Loading...
Searching...
No Matches
ListIterator< T > Class Template Reference

`#include <ftmpl_list.h>`

## Public Member Functions

| ListIterator ()
| ListIterator (const ListIterator< T > &)
| ListIterator (const List< T > &)
| ~ListIterator ()
ListIterator< T > & | operator= (const ListIterator< T > &)
ListIterator< T > & | operator= (const List< T > &)
T & | getItem () const
int | hasItem ()
void | operator++ ()
void | operator-- ()
void | operator++ (int)
void | operator-- (int)
void | firstItem ()
void | lastItem ()
void | insert (const T &)
void | append (const T &)
void | remove (int moveright)

## Private Attributes

List< T > * | theList
ListItem< T > * | current

## Detailed Description

template<class T>
class ListIterator< T >

Definition at line 87 of file ftmpl_list.h.

## Constructor & Destructor Documentation

## ListIterator() [1/3]

template<class T>

ListIterator< T >::ListIterator | ( |  | ) |

Definition at line 382 of file ftmpl_list.cc.

{
theList = 0;
current = 0;
}
ListIterator::theList
List< T > * theList
Definition ftmpl_list.h:89
ListIterator::current
ListItem< T > * current
Definition ftmpl_list.h:90

## ListIterator() [2/3]

template<class T>

ListIterator< T >::ListIterator | ( | const ListIterator< T > & | i | ) |

Definition at line 390 of file ftmpl_list.cc.

{
theList = i.theList;
current = i.current;
}
ListIterator
Definition ftmpl_list.h:87

## ListIterator() [3/3]

template<class T>

ListIterator< T >::ListIterator | ( | const List< T > & | l | ) |

Definition at line 398 of file ftmpl_list.cc.

{
theList = (List<T>*)&l;
current = l.first;
}

## ~ListIterator()

template<class T>

ListIterator< T >::~ListIterator | ( |  | ) |

Definition at line 406 of file ftmpl_list.cc.

{ }

## Member Function Documentation

## append()

template<class T>

void ListIterator< T >::append | ( | const T & | t | ) |

Definition at line 509 of file ftmpl_list.cc.

{
if ( current )
{
if ( ! current->next )
theList->append( t );
else
{
current->next = new ListItem<T>( t, current->next, current );
current->next->next->prev = current->next;
theList->_length++;
}
}
}

## firstItem()

template<class T>

void ListIterator< T >::firstItem | ( |  | ) |

Definition at line 478 of file ftmpl_list.cc.

{
current = theList->first;
}

## getItem()

template<class T>

T & ListIterator< T >::getItem | ( |  | ) | const

Definition at line 431 of file ftmpl_list.cc.

{
ASSERT( current, "ListIterator: no item available" );
return current->getItem();
}
ASSERT
#define ASSERT(expression, message)
Definition cf_assert.h:99

## hasItem()

template<class T>

int ListIterator< T >::hasItem | ( |  | ) |

Definition at line 439 of file ftmpl_list.cc.

{
return current != 0;
}

## insert()

template<class T>

void ListIterator< T >::insert | ( | const T & | t | ) |

Definition at line 492 of file ftmpl_list.cc.

{
if ( current )
{
if ( ! current->prev )
theList->insert( t );
else
{
current->prev = new ListItem<T>( t, current, current->prev );
current->prev->prev->next = current->prev;
theList->_length++;
}
}
}

## lastItem()

template<class T>

void ListIterator< T >::lastItem | ( |  | ) |

Definition at line 485 of file ftmpl_list.cc.

{
current = theList->last;
}

## operator++() [1/2]

template<class T>

void ListIterator< T >::operator++ | ( |  | ) |

Definition at line 446 of file ftmpl_list.cc.

{
if ( current )
current = current->next;
}

## operator++() [2/2]

template<class T>

void ListIterator< T >::operator++ | ( | int |  | ) |

Definition at line 462 of file ftmpl_list.cc.

{
if ( current )
current = current->next;
}

## operator--() [1/2]

template<class T>

void ListIterator< T >::operator-- | ( |  | ) |

Definition at line 454 of file ftmpl_list.cc.

{
if ( current )
current = current->prev;
}

## operator--() [2/2]

template<class T>

void ListIterator< T >::operator-- | ( | int |  | ) |

Definition at line 470 of file ftmpl_list.cc.

{
if ( current )
current = current->prev;
}

## operator=() [1/2]

template<class T>

ListIterator< T > & ListIterator< T >::operator= | ( | const List< T > & | l | ) |

Definition at line 422 of file ftmpl_list.cc.

{
theList = (List<T>*)&l;
current = l.first;
return *this;
}

## operator=() [2/2]

template<class T>

ListIterator< T > & ListIterator< T >::operator= | ( | const ListIterator< T > & | I | ) |

Definition at line 410 of file ftmpl_list.cc.

{
if ( this != &I )
{
theList = I.theList;
current = I.current;
}
return *this;
}

## remove()

template<class T>

void ListIterator< T >::remove | ( | int | moveright | ) |

Definition at line 526 of file ftmpl_list.cc.

{
if ( current )
{
ListItem <T>*dummynext = current->next, *dummyprev = current->prev;
if ( current->prev )
{
current->prev->next = current->next;
if ( current->next )
current->next->prev = current->prev;
else
theList->last = current->prev;
delete current;
current = ( moveright ) ? dummynext : dummyprev;
}
else
{
if ( current->next )
current->next->prev = 0;
theList->first = current->next;
delete current;
current = ( moveright ) ? dummynext : dummyprev;
}
theList->_length--;
}
}

## Field Documentation

## current

template<class T>

ListItem<T>* ListIterator< T >::current

private

Definition at line 90 of file ftmpl_list.h.

## theList

template<class T>

List<T>* ListIterator< T >::theList

private

Definition at line 89 of file ftmpl_list.h.

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

- factory/include/factory/templates/ftmpl_list.h
- factory/templates/ftmpl_list.cc