Back to index

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

#include <nsWindow.h>

Collaboration diagram for nsList:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 nsList ()
 ~nsList ()
nsListItemgetHead ()
void add (void *aData)
void remove (void *aData)
void reset ()

Private Attributes

nsListItemhead
nsListItemtail

Detailed Description

Definition at line 68 of file nsWindow.h.


Constructor & Destructor Documentation

Definition at line 74 of file nsWindow.cpp.

{
  head = nsnull;
  tail = nsnull;
}

Definition at line 80 of file nsWindow.cpp.

{
  reset();
}

Here is the call graph for this function:


Member Function Documentation

void nsList::add ( void aData)

Definition at line 85 of file nsWindow.cpp.

{
  if (head == nsnull) {           // We have an empty list, create the head
    head = new nsListItem(aData, nsnull);
    tail = head;
  } else {                        // Append to the end of the list
    tail->setNext(new nsListItem(aData, tail));
    tail = tail->getNext();       // Reset the tail
    tail->setNext(nsnull);
  }
}

Here is the call graph for this function:

nsListItem* nsList::getHead ( ) [inline]

Definition at line 72 of file nsWindow.h.

{ return head; }

Here is the caller graph for this function:

void nsList::remove ( void aData)

Definition at line 97 of file nsWindow.cpp.

{
  if (head == nsnull) {           // Removing from a null list
    return;
  } else {                        // find the data
    nsListItem *aItem = head;
    while ((aItem != nsnull) && (aItem->getData() != aData)) {
      aItem = aItem->getNext();
    }
    if (aItem == nsnull) {        // we didn't find it
      return;
    } else
    if (aItem == head) {          // we have to remove the head
      head = aItem->getNext();
      delete aItem;
      if (head == nsnull)         // we have emptied the list
        tail = nsnull;
      else
        head->setPrev(nsnull);
    } else
    if (aItem == tail) {          // we have to remove the tail
      tail = aItem->getPrev();
      delete aItem;
      if (tail == nsnull)         // we have emptied the list
        head = nsnull;
      else
        tail->setNext(nsnull);
    } else {                      // we remove from the middle
      nsListItem *prev = aItem->getPrev();
      nsListItem *next = aItem->getNext();
      delete aItem;
      prev->setNext(next);
      next->setPrev(prev);
    }
  }
}

Here is the call graph for this function:

Definition at line 134 of file nsWindow.cpp.

{
  while (head != nsnull) {
    void *aData = head->getData();
    remove(aData);
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

Definition at line 78 of file nsWindow.h.

Definition at line 79 of file nsWindow.h.


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