Legacy Documentclose button

Important: The information in this document is obsolete and should not be used for new development.

Previous Book Contents Book Index Next

Inside Macintosh: Networking With Open Transport / Part 2 - Open Transport Reference
Chapter 27 - Utilities Reference / Functions
OTLIFO List Utility Functions /


OTReverseList

Reverses the order in which entries are linked in a list.

C INTERFACE
OTLink* OTReverseList (OTLink* link)
C++ INTERFACE
None. C++ applications use the C interface to this function.

PARAMETERS
link
A link that points to the linked list whose elements you want to reverse; typically, this is the return value from the function OTLIFOStealList.
function result
A pointer to the first entry in the list referenced by the link parameter after the list's elements have been reordered.
DISCUSSION
This function does not reverse the list atomically. However, it is intended to be used after using the OTLIFOStealList function, to convert the list produced by that function into a usable FIFO list. A typical usage would be:

OTLink* link;
OTLink* next;
while ( (link = OTLIFOStealList(&myLifo)) != NULL )
{
   link = OTReverseList(link);
   do
   {
      MyObject* temp = OTGetLinkObject(link, MyObject, fMyLink);
      next = link->fNext;
      /* Do some stuff with temp */
   } while ( (link = next) != NULL );
}  
This allows a producing task to be placing elements into a LIFO list, while a consuming task atomically processes them in FIFO order.

If link is nil, OTReverseList returns nil.


Previous Book Contents Book Index Next

© Apple Computer, Inc.
15 JAN 1998