My Project
Loading...
Searching...
No Matches
Public Member Functions | Private Attributes
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 > &)
 
TgetItem () 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.

383{
384 theList = 0;
385 current = 0;
386}
List< T > * theList
Definition: ftmpl_list.h:89
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.

391{
392 theList = i.theList;
393 current = i.current;
394}
int i
Definition: cfEzgcd.cc:132

◆ ListIterator() [3/3]

template<class T >
ListIterator< T >::ListIterator ( const List< T > &  l)

Definition at line 398 of file ftmpl_list.cc.

399{
400 theList = (List<T>*)&l;
401 current = l.first;
402}
int l
Definition: cfEzgcd.cc:100

◆ ~ListIterator()

template<class T >
ListIterator< T >::~ListIterator

Definition at line 406 of file ftmpl_list.cc.

406{ }

Member Function Documentation

◆ append()

template<class T >
void ListIterator< T >::append ( const T t)

Definition at line 509 of file ftmpl_list.cc.

510{
511 if ( current )
512 {
513 if ( ! current->next )
514 theList->append( t );
515 else
516 {
517 current->next = new ListItem<T>( t, current->next, current );
518 current->next->next->prev = current->next;
519 theList->_length++;
520 }
521 }
522}

◆ firstItem()

template<class T >
void ListIterator< T >::firstItem

Definition at line 478 of file ftmpl_list.cc.

479{
480 current = theList->first;
481}

◆ getItem()

template<class T >
T & ListIterator< T >::getItem

Definition at line 431 of file ftmpl_list.cc.

432{
433 ASSERT( current, "ListIterator: no item available" );
434 return current->getItem();
435}
#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.

440{
441 return current != 0;
442}

◆ insert()

template<class T >
void ListIterator< T >::insert ( const T t)

Definition at line 492 of file ftmpl_list.cc.

493{
494 if ( current )
495 {
496 if ( ! current->prev )
497 theList->insert( t );
498 else
499 {
500 current->prev = new ListItem<T>( t, current, current->prev );
501 current->prev->prev->next = current->prev;
502 theList->_length++;
503 }
504 }
505}

◆ lastItem()

template<class T >
void ListIterator< T >::lastItem

Definition at line 485 of file ftmpl_list.cc.

486{
487 current = theList->last;
488}

◆ operator++() [1/2]

template<class T >
void ListIterator< T >::operator++

Definition at line 446 of file ftmpl_list.cc.

447{
448 if ( current )
449 current = current->next;
450}

◆ operator++() [2/2]

template<class T >
void ListIterator< T >::operator++ ( int  )

Definition at line 462 of file ftmpl_list.cc.

463{
464 if ( current )
465 current = current->next;
466}

◆ operator--() [1/2]

template<class T >
void ListIterator< T >::operator--

Definition at line 454 of file ftmpl_list.cc.

455{
456 if ( current )
457 current = current->prev;
458}

◆ operator--() [2/2]

template<class T >
void ListIterator< T >::operator-- ( int  )

Definition at line 470 of file ftmpl_list.cc.

471{
472 if ( current )
473 current = current->prev;
474}

◆ operator=() [1/2]

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

Definition at line 422 of file ftmpl_list.cc.

423{
424 theList = (List<T>*)&l;
425 current = l.first;
426 return *this;
427}

◆ operator=() [2/2]

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

Definition at line 410 of file ftmpl_list.cc.

411{
412 if ( this != &I )
413 {
414 theList = I.theList;
415 current = I.current;
416 }
417 return *this;
418}

◆ remove()

template<class T >
void ListIterator< T >::remove ( int  moveright)

Definition at line 526 of file ftmpl_list.cc.

527{
528 if ( current )
529 {
530 ListItem <T>*dummynext = current->next, *dummyprev = current->prev;
531 if ( current->prev )
532 {
533 current->prev->next = current->next;
534 if ( current->next )
535 current->next->prev = current->prev;
536 else
537 theList->last = current->prev;
538 delete current;
539 current = ( moveright ) ? dummynext : dummyprev;
540 }
541 else
542 {
543 if ( current->next )
544 current->next->prev = 0;
545 theList->first = current->next;
546 delete current;
547 current = ( moveright ) ? dummynext : dummyprev;
548 }
549 theList->_length--;
550 }
551}

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: