Back to index

lightning-sunbird  0.9+nobinonly
Public Member Functions | Private Attributes
txListIterator Class Reference

An Iterator for the txList Class. More...

#include <txList.h>

Collaboration diagram for txListIterator:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 txListIterator (txList *list)
 Creates a new txListIterator for the given txList.
 ~txListIterator ()
 Destructor, destroys a given instance of a txListIterator.
nsresult addAfter (void *objPtr)
 Adds the Object pointer to the txList pointed to by this txListIterator.
nsresult addBefore (void *objPtr)
 Adds the Object pointer to the txList pointed to by this txListIterator.
MBool hasNext ()
 Returns true if a sucessful call to the next() method can be made.
MBool hasPrevious ()
 Returns true if a sucessful call to the previous() method can be made.
voidnext ()
 Returns the next Object pointer from the list.
voidprevious ()
 Returns the previous Object pointer from the list.
voidcurrent ()
 Returns the current Object.
voidadvance (int i)
 Moves the specified number of steps.
voidremove ()
 Removes the Object last returned by the next() or previous() methods;.
void reset ()
 Resets the current location within the txList to the beginning of the txList.
void resetToEnd ()
 Resets the current location within the txList to the end of the txList.

Private Attributes

txList::ListItemcurrentItem
txListlist
MBool atEndOfList

Detailed Description

An Iterator for the txList Class.

Definition at line 130 of file txList.h.


Constructor & Destructor Documentation

Creates a new txListIterator for the given txList.

Parameters:
list,thetxList to create an Iterator for

Definition at line 243 of file txList.cpp.

                                           {
   this->list   = list;
   currentItem  = 0;
   atEndOfList  = MB_FALSE;
} //-- txListIterator

Destructor, destroys a given instance of a txListIterator.

Definition at line 249 of file txList.cpp.

                                {
  //-- overrides default destructor to do nothing
} //-- ~txListIterator

Member Function Documentation

Adds the Object pointer to the txList pointed to by this txListIterator.

The Object pointer is inserted as the next item in the txList based on the current position within the txList

Parameters:
objPtrthe Object pointer to add to the list

Definition at line 259 of file txList.cpp.

{
    if (currentItem || !atEndOfList)
        return list->insertAfter(objPtr, currentItem);
    return list->insertBefore(objPtr, 0);

} //-- addAfter

Here is the call graph for this function:

Here is the caller graph for this function:

Adds the Object pointer to the txList pointed to by this txListIterator.

The Object pointer is inserted as the previous item in the txList based on the current position within the txList

Parameters:
objPtrthe Object pointer to add to the list

Definition at line 273 of file txList.cpp.

{
    if (currentItem || atEndOfList)
        return list->insertBefore(objPtr, currentItem);
    return list->insertAfter(objPtr, 0);

} //-- addBefore

Here is the call graph for this function:

Here is the caller graph for this function:

Moves the specified number of steps.

Definition at line 364 of file txList.cpp.

                                   {

    void* obj = 0;

    if (i > 0) {
        if (!currentItem && !atEndOfList) {
            currentItem = list->firstItem;
            --i;
        }
        for (; currentItem && i > 0; i--)
            currentItem = currentItem->nextItem;
        
        atEndOfList = currentItem == 0;
    }
    else if (i < 0) {
        if (!currentItem && atEndOfList) {
            currentItem = list->lastItem;
            ++i;
        }
        for (; currentItem && i < 0; i++)
            currentItem = currentItem->prevItem;

        atEndOfList = MB_FALSE;
    }

    if (currentItem)
        obj = currentItem->objPtr;

    return obj;
} //-- advance

Returns the current Object.

Definition at line 353 of file txList.cpp.

                              {

    if (currentItem)
        return currentItem->objPtr;

    return 0;
} //-- current

Here is the caller graph for this function:

Returns true if a sucessful call to the next() method can be made.

Returns:
MB_TRUE if a sucessful call to the next() method can be made, otherwise MB_FALSE

Definition at line 286 of file txList.cpp.

                              {
    MBool hasNext = MB_FALSE;
    if (currentItem)
        hasNext = (currentItem->nextItem != 0);
    else if (!atEndOfList)
        hasNext = (list->firstItem != 0);

    return hasNext;
} //-- hasNext

Here is the caller graph for this function:

Returns true if a sucessful call to the previous() method can be made.

Returns:
MB_TRUE if a sucessful call to the previous() method can be made, otherwise MB_FALSE

Definition at line 301 of file txList.cpp.

                                  {
    MBool hasPrevious = MB_FALSE;
    if (currentItem)
        hasPrevious = (currentItem->prevItem != 0);
    else if (atEndOfList)
        hasPrevious = (list->lastItem != 0);

    return hasPrevious;
} //-- hasPrevious

Returns the next Object pointer from the list.

Returns the next Object pointer in the list.

Definition at line 314 of file txList.cpp.

                           {

    void* obj = 0;
    if (currentItem)
        currentItem = currentItem->nextItem;
    else if (!atEndOfList)
        currentItem = list->firstItem;

    if (currentItem)
        obj = currentItem->objPtr;
    else
        atEndOfList = MB_TRUE;

    return obj;
} //-- next

Here is the caller graph for this function:

Returns the previous Object pointer from the list.

Returns the previous Object in the list.

Definition at line 333 of file txList.cpp.

                               {

    void* obj = 0;

    if (currentItem)
        currentItem = currentItem->prevItem;
    else if (atEndOfList)
        currentItem = list->lastItem;
    
    if (currentItem)
        obj = currentItem->objPtr;

    atEndOfList = MB_FALSE;

    return obj;
} //-- previous

Here is the caller graph for this function:

Removes the Object last returned by the next() or previous() methods;.

Returns:
the removed Object pointer

Definition at line 399 of file txList.cpp.

                             {

    void* obj = 0;
    if (currentItem) {
        obj = currentItem->objPtr;
        txList::ListItem* item = currentItem;
        previous(); //-- make previous item the current item
        list->remove(item);
        delete item;
    }
    return obj;
} //-- remove

Here is the call graph for this function:

Here is the caller graph for this function:

Resets the current location within the txList to the beginning of the txList.

Definition at line 415 of file txList.cpp.

                           {
   atEndOfList = MB_FALSE;
   currentItem = 0;
} //-- reset

Here is the caller graph for this function:

Resets the current location within the txList to the end of the txList.

Move the iterator to right after the last element.

Definition at line 423 of file txList.cpp.

                                {
   atEndOfList = MB_TRUE;
   currentItem = 0;
} //-- moveToEnd

Here is the caller graph for this function:


Member Data Documentation

Definition at line 219 of file txList.h.

Definition at line 213 of file txList.h.

Definition at line 216 of file txList.h.


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