home *** CD-ROM | disk | FTP | other *** search
/ vis-ftp.cs.umass.edu / vis-ftp.cs.umass.edu.tar / vis-ftp.cs.umass.edu / pub / Software / ASCENDER / ascender.tar.Z / ascender.tar / Triangulate / include / list_defs.h < prev    next >
C/C++ Source or Header  |  1995-04-13  |  2KB  |  82 lines

  1. /* @(#)list_defs.h    3.9  6/17/94 */
  2. /* Include file for use with lists */
  3. #ifndef list_defs_h
  4. #define list_defs_h
  5. #ifndef DATADEF
  6. #define DATADEF
  7. typedef char *DATA;
  8. #endif
  9.  
  10. typedef struct list
  11.      {
  12.     DATA data;    /* A pointer to the actual data */
  13.     struct list *lst_next, *lst_prev;
  14.     } LIST, LISTENTRY;
  15.  
  16. /* Macros for moving down lists */
  17. #define lst_nextentry(x) ((x)->lst_next)
  18. #define lst_preventry(x) ((x)->lst_prev)
  19. #define lst_firstentry(lst) ((lst)->lst_next)
  20. #define lst_lastentry(lst) ((lst)->lst_prev)
  21. #define lst_first(lst) ((lst)->lst_next->data)
  22. #define lst_last(lst) ((lst)->lst_prev->data)
  23. #define lst_end(lst) (lst)
  24. #define lst_isempty(lst) ((lst) == (lst)->lst_next)
  25.  
  26. #define lst_forallpairs(type1,x1,lst1,type2,x2,lst2)\
  27.     {\
  28.     register type1 (x1);\
  29.     register type2 (x2);\
  30.     register LISTENTRY *lst_cursor1;\
  31.     register LISTENTRY *lst_cursor2;\
  32.     if((lst1) && (lst2))\
  33.        for( lst_cursor1=(lst1)->lst_next,\
  34.         lst_cursor2=(lst2)->lst_next;\
  35.         (lst_cursor1!=(lst1))&&(lst_cursor2!=(lst2))?\
  36.             ((x1)=(type1)lst_cursor1->data,\
  37.              (x2)=(type2)lst_cursor2->data,TRUE):FALSE;\
  38.         lst_cursor1=lst_cursor1->lst_next,\
  39.         lst_cursor2=lst_cursor2->lst_next)\
  40.           {
  41.  
  42. #define lst_forall(type,x,lst)\
  43.     {\
  44.     register type x;\
  45.     register LISTENTRY *lst_cursor;\
  46.     if(lst)\
  47.        for(lst_cursor=(lst)->lst_next; \
  48.         (lst_cursor!=(lst))?(x=(type)lst_cursor->data,TRUE):FALSE;\
  49.         lst_cursor=lst_cursor->lst_next)\
  50.           {
  51.  
  52. #define lst_forbackwards(type,x,lst) \
  53.     {\
  54.     register type x;\
  55.     register LISTENTRY *lst_cursor;\
  56.     if(lst)\
  57.        for(lst_cursor=(lst)->lst_prev;\
  58.           (lst_cursor!=(lst))?(x=(type)lst_cursor->data,TRUE):FALSE;\
  59.           lst_cursor=lst_cursor->lst_prev)\
  60.           {
  61.  
  62. #define lst_forallentries(lst_cursor,lst) \
  63.     {\
  64.     register LISTENTRY *lst_cursor;\
  65.     if(lst)\
  66.        for(lst_cursor=(lst)->lst_next;\
  67.           (lst_cursor!=(lst));\
  68.           lst_cursor=lst_cursor->lst_next)\
  69.           {
  70.  
  71. #define lst_endall }}
  72.  
  73. /* Macros for simple insert operations */
  74.  
  75. #define lst_insertstart(dat,lst) lst_insertafter((DATA)(dat),(lst))
  76. #define lst_insertend(dat,lst) lst_insertafter((DATA)(dat),lst_lastentry(lst))
  77. #define lst_insert(dat,lst) lst_insertstart((dat),(lst))
  78. #define lst_push(dat,stack) lst_insertstart((dat), (stack))
  79. #define lst_enqueue(dat, que) lst_insertend((dat), (que))
  80.  
  81. #endif
  82.