home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / lifeos2.zip / LIFE-1.02 / SOURCE / LIST.H < prev    next >
C/C++ Source or Header  |  1996-06-04  |  2KB  |  93 lines

  1. /* 
  2.  * Copyright 1991 Digital Equipment Corporation.
  3.  * All Rights Reserved.
  4.  */
  5. /*     $Id: list.h,v 1.2 1994/12/08 23:28:39 duchier Exp $     */
  6.  
  7.  
  8. /*
  9. ** list.h contains the functions to manage double link list
  10. ** with 2 entries (first and last element)
  11. ** Links belongs to each atom
  12. */
  13.  
  14.  
  15. #ifndef NULL
  16. #define NULL 0
  17. #endif
  18. #ifndef TRUE
  19. #define TRUE 1
  20. #endif
  21. #ifndef FALSE
  22. #define FALSE 0
  23. #endif
  24.  
  25. typedef void *            Ref;
  26. typedef struct wl_ListLinks *    RefListLinks;
  27. typedef struct wl_ListHeader *    RefListHeader;
  28. typedef RefListLinks        (*RefListGetLinksProc)    ( );
  29. typedef int            (*RefListEnumProc)    ( );
  30.  
  31.  
  32.  
  33. /*
  34.   "First", "Last" are pointers to the first and last element of the list
  35.   respectively.
  36.   
  37.   "Current" points to the current processed element of the list. Used when
  38.   applying a function to each element of the list.
  39.   
  40.   "GetLinks" is a function to get the list links on the object.
  41.   
  42.   "Lock" is the number of recursive enum calls on the list. Used only in
  43.   debugging mode.
  44.   */
  45.  
  46.  
  47. typedef struct wl_ListHeader
  48. {
  49.   Ref First, Last;
  50.  
  51. #ifdef prlDEBUG
  52.     Int32            Lock;
  53. #endif
  54.  
  55.     RefListGetLinksProc        GetLinks;
  56. } ListHeader;
  57.  
  58.  
  59.  
  60. typedef struct wl_ListLinks
  61. {
  62.     Ref Next, Prev;
  63. } ListLinks;
  64.  
  65.  
  66.  
  67. extern void List_SetLinkProc ( );
  68. extern void List_InsertAhead ( );
  69. extern void List_Append ( );
  70. extern void List_InsertBefore ( );
  71. extern void List_InsertAfter ( );
  72. extern void List_Swap ( );
  73. extern void List_Reverse ( );
  74. extern void List_Remove ( );
  75. extern void List_Concat ( );
  76. extern long List_EnumFrom ( );
  77. extern long List_Enum ( );
  78. extern long List_EnumBackFrom ( );
  79. extern long List_EnumBack ( );
  80. extern long List_Card ( );
  81. extern long List_IsUnlink ( );
  82. extern void List_Cut ( );
  83.  
  84. /*=============================================================================*/
  85. /*            Get functions    (macros)                               */
  86. /*=============================================================================*/
  87.  
  88. #define List_First(header) ((header)->First)
  89. #define List_Last(header) ((header)->Last)
  90. #define List_Next(header,RefAtom) ((*(header)->GetLinks)(RefAtom)->Next)
  91. #define List_Prev(header,RefAtom) ((*(header)->GetLinks)(RefAtom)->Prev)
  92. #define List_IsEmpty(header) (List_First(header)==NULL)
  93.