home *** CD-ROM | disk | FTP | other *** search
/ BCI NET 2 / BCI NET 2.iso / archives / programming / source / xdme_1.84_src.lha / XDME / Lib / include / SLL.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-11-25  |  2.6 KB  |  85 lines

  1. /******************************************************************************
  2.  
  3.     MODULE
  4.     SLL.h
  5.  
  6.     DESCRIPTION
  7.     Header File for ``Single Linked Lists''
  8.  
  9.     That module may be used in connection with
  10.     some Intuition structures like Windows, Gadgets
  11.     and Menus, since these use SLLs themselfes ...
  12.  
  13.     HISTORY
  14.     13-11-94 b_noll created
  15.  
  16. ******************************************************************************/
  17.  
  18. #ifndef SLL_H
  19. #define SLL_H 1
  20.  
  21. /**************************************
  22.         Includes
  23. **************************************/
  24.  
  25. #ifndef   EXEC_TYPES_H
  26. #include <exec/types.h>
  27. #endif /* EXEC_TYPES_H */
  28.  
  29. /**************************************
  30.         Defines & Structures
  31. **************************************/
  32.  
  33. struct SNode {
  34.     struct SNode *Succ;
  35. }; /* struct SNode */
  36.  
  37. struct SList {
  38.     struct SNode *Head;
  39. }; /* struct SList */
  40.  
  41. /**************************************
  42.         Prototypes
  43. **************************************/
  44.  
  45. /* ---- Movement */
  46.  
  47. #define SLL_GetHead(l)   (*(void **)(l))
  48. #define SLL_GetSucc(l,n) (*(void **)(n))
  49.  
  50. /* ---- Construction and destruction */
  51.  
  52. extern void  SLL_Init        (struct SList *l);
  53.  
  54. extern BOOL  SLL_Remove     (struct SList *l, struct SNode *n);
  55. extern void  SLL_AddTail    (struct SList *l, struct SNode *n);
  56. extern void  SLL_AddHead    (struct SList *l, struct SNode *n);
  57. extern void  SLL_AddInfront (struct SList *l, struct SNode *n, struct SNode *pos);
  58. extern void  SLL_AddBehind  (struct SList *l, struct SNode *n, struct SNode *pos);
  59.  
  60. extern struct SNode *SLL_RemHead    (struct SList *l);
  61. extern BOOL         SLL_Remove     (struct SList *l, struct SNode *n);
  62.  
  63. /* ---- Searching and scanning    */
  64.  
  65. extern void         SLL_Scan (struct SList *l, void (*scan)(void *, APTR, int), APTR userdata);
  66. extern struct SNode *SLL_Find (struct SList *l, int  (*find)(void *, APTR, int), APTR userdata);
  67.  
  68. /* ---- Indexing */
  69.  
  70. extern int         SLL_Length     (struct SList *l);
  71. extern struct SNode *SLL_NumToNode  (struct SList *l, int num);
  72. extern int         SLL_NodeToNum  (struct SList *l, struct SNode *n);
  73.  
  74. /* ---- BONUS: The following functions are for MenuSupport */
  75.  
  76. extern struct SNode *SLL_Find_or_Append     (struct SList *l, int  (*find)(void *, APTR), void *(Create)(APTR), APTR userdata);
  77. extern void         SLL_Delete         (struct SList *l, void *remove, void (*delete)(void *, APTR), APTR userdata);
  78. extern BOOL         SLL_Find_and_Delete    (struct SList *l, int  (*find)(void *, APTR), void (*delete)(void *, APTR), APTR userdata);
  79.  
  80. #endif /* !SLL_H */
  81.  
  82. /******************************************************************************
  83. *****  END SLL.h
  84. ******************************************************************************/
  85.