VxWorks Reference Manual : Wind Foundation Classes

VXWList

NAME

VXWList - simple linked list class

METHODS

VXWList::VXWList( ) - initialize a list
VXWList::VXWList( ) - initialize a list as a copy of another
VXWList::~VXWList( ) - free up a list
VXWList::add( ) - add a node to the end of list
VXWList::concat( ) - concatenate two lists
VXWList::count( ) - report the number of nodes in a list
VXWList::extract( ) - extract a sublist from list
VXWList::find( ) - find a node in list
VXWList::first( ) - find first node in list
VXWList::get( ) - delete and return the first node from list
VXWList::insert( ) - insert a node in list after a specified node
VXWList::last( ) - find the last node in list
VXWList::next( ) - find the next node in list
VXWList::nStep( ) - find a list node nStep steps away from a specified node
VXWList::nth( ) - find the Nth node in a list
VXWList::previous( ) - find the previous node in list
VXWList::remove( ) - delete a specified node from list

DESCRIPTION

The VXWList class supports the creation and maintenance of a doubly linked list. The class contains pointers to the first and last nodes in the list, and a count of the number of nodes in the list. The nodes in the list are derived from the structure NODE, which provides two pointers: NODE::next and NODE::previous. Both the forward and backward chains are terminated with a NULL pointer.

The VXWList class simply manipulates the linked-list data structures; no kernel functions are invoked. In particular, linked lists by themselves provide no task synchronization or mutual exclusion. If multiple tasks will access a single linked list, that list must be guarded with some mutual-exclusion mechanism (such as a mutual-exclusion semaphore).

NON-EMPTY LIST

   ---------             --------          --------
   | head--------------->| next----------->| next---------
   |       |             |      |          |      |      |
   |       |       ------- prev |<---------- prev |      |
   |       |       |     |      |          |      |      |
   | tail------    |     | ...  |    ----->| ...  |      |
   |       |  |    v                 |                   v
   |count=2|  |  -----               |                 -----
   ---------  |   ---                |                  ---
              |    -                 |                   -
              |                      |
              ------------------------

EMPTY LIST

        -----------
        |  head------------------
        |         |             |
        |  tail----------       |
        |         |     |       v
        | count=0 |   -----   -----
        -----------    ---     ---
                        -    -

WARNINGS

Use only single inheritance! This class is an interface to the VxWorks library lstLib. More sophisticated alternatives are available in the Tools.h++ class libraries.

EXAMPLE

The following example illustrates how to create a list by deriving elements from NODE and putting them on a VXWList.

class myListNode : public NODE
    {
  public:
    myListNode ()
     {
     }
  private:
    };

VXWList      myList;
myListNode   a, b, c;

NODE       * pEl = &c;

void useList ()
    {
    myList.add (&a);
    myList.insert (pEl, &b);
    }

INCLUDE FILES

vxwLstLib.h

SEE ALSO

VXWList


Wind Foundation Classes : Methods

VXWList::VXWList( )

NAME

VXWList::VXWList( ) - initialize a list

SYNOPSIS

    VXWList ()

DESCRIPTION

This constructor initializes a list as an empty list.

RETURNS

N/A

SEE ALSO

VXWList


Wind Foundation Classes : Methods

VXWList::VXWList( )

NAME

VXWList::VXWList( ) - initialize a list as a copy of another

SYNOPSIS

VXWList
    (
    const VXWList &
    )

DESCRIPTION

This constructor builds a new list as a copy of an existing list.

RETURNS

N/A

SEE ALSO

VXWList


Wind Foundation Classes : Methods

VXWList::~VXWList( )

NAME

VXWList::~VXWList( ) - free up a list

SYNOPSIS

    ~VXWList ()

DESCRIPTION

This destructor frees up memory used for nodes.

RETURNS

N/A

SEE ALSO

VXWList


Wind Foundation Classes : Methods

VXWList::add( )

NAME

VXWList::add( ) - add a node to the end of list

SYNOPSIS

void add
    (
    NODE * pNode
    )

DESCRIPTION

This routine adds a specified node to the end of the list.

RETURNS

N/A

SEE ALSO

VXWList


Wind Foundation Classes : Methods

VXWList::concat( )

NAME

VXWList::concat( ) - concatenate two lists

SYNOPSIS

void concat
    (
    VXWList &aList
    )

DESCRIPTION

This routine concatenates the specified list to the end of the current list. The specified list is left empty. Either list (or both) can be empty at the beginning of the operation.

RETURNS

N/A

SEE ALSO

VXWList


Wind Foundation Classes : Methods

VXWList::count( )

NAME

VXWList::count( ) - report the number of nodes in a list

SYNOPSIS

    int count ()

DESCRIPTION

This routine returns the number of nodes in a specified list.

RETURNS

The number of nodes in the list.

SEE ALSO

VXWList


Wind Foundation Classes : Methods

VXWList::extract( )

NAME

VXWList::extract( ) - extract a sublist from list

SYNOPSIS

LIST extract
    (
    NODE * pStart,
    NODE * pEnd
    )

DESCRIPTION

This routine extracts the sublist that starts with pStart and ends with pEnd. It returns the extracted list.

RETURNS

The extracted sublist.

SEE ALSO

VXWList


Wind Foundation Classes : Methods

VXWList::find( )

NAME

VXWList::find( ) - find a node in list

SYNOPSIS

int find
    (
    NODE * pNode
    ) const

DESCRIPTION

This routine returns the node number of a specified node (the first node is 1).

RETURNS

The node number, or ERROR if the node is not found.

SEE ALSO

VXWList


Wind Foundation Classes : Methods

VXWList::first( )

NAME

VXWList::first( ) - find first node in list

SYNOPSIS

    NODE * first ()

DESCRIPTION

This routine finds the first node in its list.

RETURNS

A pointer to the first node in the list, or NULL if the list is empty.

SEE ALSO

VXWList


Wind Foundation Classes : Methods

VXWList::get( )

NAME

VXWList::get( ) - delete and return the first node from list

SYNOPSIS

    NODE * get ()

DESCRIPTION

This routine gets the first node from its list, deletes the node from the list, and returns a pointer to the node gotten.

RETURNS

A pointer to the node gotten, or NULL if the list is empty.

SEE ALSO

VXWList


Wind Foundation Classes : Methods

VXWList::insert( )

NAME

VXWList::insert( ) - insert a node in list after a specified node

SYNOPSIS

void insert
    (
    NODE * pPrev,
    NODE * pNode
    )

DESCRIPTION

This routine inserts a specified node into the list. The new node is placed following the list node pPrev. If pPrev is NULL, the node is inserted at the head of the list.

RETURNS

N/A

SEE ALSO

VXWList


Wind Foundation Classes : Methods

VXWList::last( )

NAME

VXWList::last( ) - find the last node in list

SYNOPSIS

    NODE * last ()

DESCRIPTION

This routine finds the last node in its list.

RETURNS

A pointer to the last node in the list, or NULL if the list is empty.

SEE ALSO

VXWList


Wind Foundation Classes : Methods

VXWList::next( )

NAME

VXWList::next( ) - find the next node in list

SYNOPSIS

NODE * next
    (
    NODE * pNode
    ) const

DESCRIPTION

This routine locates the node immediately following a specified node.

RETURNS

A pointer to the next node in the list, or NULL if there is no next node.

SEE ALSO

VXWList


Wind Foundation Classes : Methods

VXWList::nStep( )

NAME

VXWList::nStep( ) - find a list node nStep steps away from a specified node

SYNOPSIS

NODE * nStep
    (
    NODE * pNode,
    int    nStep
    ) const

DESCRIPTION

This routine locates the node nStep steps away in either direction from a specified node. If nStep is positive, it steps toward the tail. If nStep is negative, it steps toward the head. If the number of steps is out of range, NULL is returned.

RETURNS

A pointer to the node nStep steps away, or NULL if the node is out of range.

SEE ALSO

VXWList


Wind Foundation Classes : Methods

VXWList::nth( )

NAME

VXWList::nth( ) - find the Nth node in a list

SYNOPSIS

NODE * nth
    (
    int nodeNum
    ) const

DESCRIPTION

This routine returns a pointer to the node specified by a number nodeNum where the first node in the list is numbered 1. Note that the search is optimized by searching forward from the beginning if the node is closer to the head, and searching back from the end if it is closer to the tail.

RETURNS

A pointer to the Nth node, or NULL if there is no Nth node.

SEE ALSO

VXWList


Wind Foundation Classes : Methods

VXWList::previous( )

NAME

VXWList::previous( ) - find the previous node in list

SYNOPSIS

NODE * previous
    (
    NODE * pNode
    ) const

DESCRIPTION

This routine locates the node immediately preceding the node pointed to by pNode.

RETURNS

A pointer to the previous node in the list, or NULL if there is no previous node.

SEE ALSO

VXWList


Wind Foundation Classes : Methods

VXWList::remove( )

NAME

VXWList::remove( ) - delete a specified node from list

SYNOPSIS

void remove
    (
    NODE * pNode
    )

DESCRIPTION

This routine deletes a specified node from its list.

RETURNS

N/A

SEE ALSO

VXWList