GenLinkedList.h

Go to the documentation of this file.
00001 
00032 /*
00033         File:           GenLinkedList.h
00034         
00035         Contains:       Linked List utility routines prototypes
00036 
00037         Disclaimer:     IMPORTANT:  This Apple software is supplied to you by Apple Computer, Inc.
00038                                 ("Apple") in consideration of your agreement to the following terms, and your
00039                                 use, installation, modification or redistribution of this Apple software
00040                                 constitutes acceptance of these terms.  If you do not agree with these terms,
00041                                 please do not use, install, modify or redistribute this Apple software.
00042 
00043                                 In consideration of your agreement to abide by the following terms, and subject
00044                                 to these terms, Apple grants you a personal, non-exclusive license, under Apple’s
00045                                 copyrights in this original Apple software (the "Apple Software"), to use,
00046                                 reproduce, modify and redistribute the Apple Software, with or without
00047                                 modifications, in source and/or binary forms; provided that if you redistribute
00048                                 the Apple Software in its entirety and without modifications, you must retain
00049                                 this notice and the following text and disclaimers in all such redistributions of
00050                                 the Apple Software.  Neither the name, trademarks, service marks or logos of
00051                                 Apple Computer, Inc. may be used to endorse or promote products derived from the
00052                                 Apple Software without specific prior written permission from Apple.  Except as
00053                                 expressly stated in this notice, no other rights or licenses, express or implied,
00054                                 are granted by Apple herein, including but not limited to any patent rights that
00055                                 may be infringed by your derivative works or by other works in which the Apple
00056                                 Software may be incorporated.
00057 
00058                                 The Apple Software is provided by Apple on an "AS IS" basis.  APPLE MAKES NO
00059                                 WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION THE IMPLIED
00060                                 WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
00061                                 PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND OPERATION ALONE OR IN
00062                                 COMBINATION WITH YOUR PRODUCTS.
00063 
00064                                 IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL OR
00065                                 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
00066                                 GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
00067                                 ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION
00068                                 OF THE APPLE SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT, TORT
00069                                 (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN
00070                                 ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00071 
00072         Copyright © 2003-2004 Apple Computer, Inc., All Rights Reserved
00073 */
00074 
00075 
00076 #ifndef __GENLINKEDLIST__
00077 #define __GENLINKEDLIST__
00078 
00079 #ifdef __cplusplus
00080 extern "C" {
00081 #endif
00082 
00083 #if TARGET_API_MAC_OSX || defined( __APPLE_CC__ )
00084 #include        <CoreServices/CoreServices.h>
00085 #endif
00086 
00087 /* This is a quick, simple and generic linked list implementation.  I tried             */
00088 /* to setup the code so that you could use any linked list implementation you   */
00089 /* want.  They just     need to support these few functions.                                            */
00090 
00091 typedef void*   GenIteratorPtr;
00092 typedef void*   GenDataPtr;
00093 
00094         /* This is a callback that is called from DestroyList for each node in the      */
00095         /* list.  It gives the caller the oportunity to free any memory they might      */
00096         /* allocated in each node.                                                                                                      */
00097 typedef CALLBACK_API( void , DisposeDataProcPtr ) ( GenDataPtr pData );
00098 
00099 #define CallDisposeDataProc( userRoutine, pData )       (*(userRoutine))((pData))
00100 
00101 struct GenLinkedList
00102 {
00103         GenDataPtr                              pHead;                          /* Pointer to the head of the list                                                      */
00104         GenDataPtr                              pTail;                          /* Pointer to the tail of the list                                                      */
00105         ItemCount                               NumberOfItems;          /* Number of items in the list (mostly for debugging)           */
00106         DisposeDataProcPtr              DisposeProcPtr;         /* rountine called to dispose of caller data, can be NULL       */
00107 };
00108 typedef struct GenLinkedList    GenLinkedList;
00109 
00110 void            InitLinkedList  ( GenLinkedList *pList, DisposeDataProcPtr disposeProcPtr );
00111 ItemCount       GetNumberOfItems( GenLinkedList *pList );
00112 OSErr           AddToTail               ( GenLinkedList *pList, GenDataPtr pData );
00113 void            InsertList              ( GenLinkedList *pDestList, GenLinkedList *pSrcList, GenIteratorPtr pIter );
00114 void            DestroyList             ( GenLinkedList *pList );
00115 
00116 void            InitIterator    ( GenLinkedList *pList, GenIteratorPtr *pIter );
00117 void            Next                    ( GenIteratorPtr *pIter );
00118 GenDataPtr      GetData                 ( GenIteratorPtr pIter );
00119 
00120 #ifdef __cplusplus
00121 }
00122 #endif
00123 
00124 #endif

Generated on Thu Jul 1 06:08:17 2010 for Second Life Viewer by  doxygen 1.4.7