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 >
Wrap
C/C++ Source or Header
|
1995-04-13
|
2KB
|
82 lines
/* @(#)list_defs.h 3.9 6/17/94 */
/* Include file for use with lists */
#ifndef list_defs_h
#define list_defs_h
#ifndef DATADEF
#define DATADEF
typedef char *DATA;
#endif
typedef struct list
{
DATA data; /* A pointer to the actual data */
struct list *lst_next, *lst_prev;
} LIST, LISTENTRY;
/* Macros for moving down lists */
#define lst_nextentry(x) ((x)->lst_next)
#define lst_preventry(x) ((x)->lst_prev)
#define lst_firstentry(lst) ((lst)->lst_next)
#define lst_lastentry(lst) ((lst)->lst_prev)
#define lst_first(lst) ((lst)->lst_next->data)
#define lst_last(lst) ((lst)->lst_prev->data)
#define lst_end(lst) (lst)
#define lst_isempty(lst) ((lst) == (lst)->lst_next)
#define lst_forallpairs(type1,x1,lst1,type2,x2,lst2)\
{\
register type1 (x1);\
register type2 (x2);\
register LISTENTRY *lst_cursor1;\
register LISTENTRY *lst_cursor2;\
if((lst1) && (lst2))\
for( lst_cursor1=(lst1)->lst_next,\
lst_cursor2=(lst2)->lst_next;\
(lst_cursor1!=(lst1))&&(lst_cursor2!=(lst2))?\
((x1)=(type1)lst_cursor1->data,\
(x2)=(type2)lst_cursor2->data,TRUE):FALSE;\
lst_cursor1=lst_cursor1->lst_next,\
lst_cursor2=lst_cursor2->lst_next)\
{
#define lst_forall(type,x,lst)\
{\
register type x;\
register LISTENTRY *lst_cursor;\
if(lst)\
for(lst_cursor=(lst)->lst_next; \
(lst_cursor!=(lst))?(x=(type)lst_cursor->data,TRUE):FALSE;\
lst_cursor=lst_cursor->lst_next)\
{
#define lst_forbackwards(type,x,lst) \
{\
register type x;\
register LISTENTRY *lst_cursor;\
if(lst)\
for(lst_cursor=(lst)->lst_prev;\
(lst_cursor!=(lst))?(x=(type)lst_cursor->data,TRUE):FALSE;\
lst_cursor=lst_cursor->lst_prev)\
{
#define lst_forallentries(lst_cursor,lst) \
{\
register LISTENTRY *lst_cursor;\
if(lst)\
for(lst_cursor=(lst)->lst_next;\
(lst_cursor!=(lst));\
lst_cursor=lst_cursor->lst_next)\
{
#define lst_endall }}
/* Macros for simple insert operations */
#define lst_insertstart(dat,lst) lst_insertafter((DATA)(dat),(lst))
#define lst_insertend(dat,lst) lst_insertafter((DATA)(dat),lst_lastentry(lst))
#define lst_insert(dat,lst) lst_insertstart((dat),(lst))
#define lst_push(dat,stack) lst_insertstart((dat), (stack))
#define lst_enqueue(dat, que) lst_insertend((dat), (que))
#endif