5 Copyright © 1997-98, The AROS Development Team. All rights reserved.
8 Desc: Demo of new OOP system - support defs.
21 struct Node
* ln_Succ
,
23 /* AROS: pointer should be 32bit aligned */
31 struct MinNode
* mln_Succ
,
37 struct Node
* lh_Head
,
46 struct MinNode
* mlh_Head
,
51 # define NEWLIST(l) (((struct List *)l)->lh_TailPred \
52 = (struct Node *)(l), \
53 ((struct List *)l)->lh_Tail = 0, \
54 ((struct List *)l)->lh_Head \
56 &(((struct List *)l)->lh_Tail))
58 # define ADDHEAD(l,n) ((void)(\
59 ((struct Node *)n)->ln_Succ = ((struct List *)l)->lh_Head, \
60 ((struct Node *)n)->ln_Pred = (struct Node *)&((struct List *)l)->lh_Head, \
61 ((struct List *)l)->lh_Head->ln_Pred = ((struct Node *)n), \
62 ((struct List *)l)->lh_Head = ((struct Node *)n)))
64 # define ADDTAIL(l,n) ((void)(\
65 ((struct Node *)n)->ln_Succ = (struct Node *)&((struct List *)l)->lh_Tail, \
66 ((struct Node *)n)->ln_Pred = ((struct List *)l)->lh_TailPred, \
67 ((struct List *)l)->lh_TailPred->ln_Succ = ((struct Node *)n), \
68 ((struct List *)l)->lh_TailPred = ((struct Node *)n) ))
70 # define REMOVE(n) ((void)(\
71 ((struct Node *)n)->ln_Pred->ln_Succ = ((struct Node *)n)->ln_Succ,\
72 ((struct Node *)n)->ln_Succ->ln_Pred = ((struct Node *)n)->ln_Pred ))
74 # define GetHead(l) (void *)(((struct List *)l)->lh_Head->ln_Succ \
75 ? ((struct List *)l)->lh_Head \
77 # define GetTail(l) (void *)(((struct List *)l)->lh_TailPred->ln_Pred \
78 ? ((struct List *)l)->lh_TailPred \
80 # define GetSucc(n) (void *)(((struct Node *)n)->ln_Succ->ln_Succ \
81 ? ((struct Node *)n)->ln_Succ \
83 # define GetPred(n) (void *)(((struct Node *)n)->ln_Pred->ln_Pred \
84 ? ((struct Node *)n)->ln_Pred \
86 # define ForeachNode(l,n) \
87 for (n=(void *)(((struct List *)(l))->lh_Head); \
88 ((struct Node *)(n))->ln_Succ; \
89 n=(void *)(((struct Node *)(n))->ln_Succ))
91 # define ForeachNodeSafe(l,n,n2) \
92 for (n=(void *)(((struct List *)(l))->lh_Head); \
93 (n2=(void *)((struct Node *)(n))->ln_Succ); \
96 # define SetNodeName(node,name) \
97 (((struct Node *)(node))->ln_Name = (char *)(name))
98 # define GetNodeName(node) \
99 (((struct Node *)(node))->ln_Name
101 # define ListLength(list,count) \
105 ForeachNode (list,n) count ++; \
108 #define IsListEmpty(l) \
109 ( (((struct List *)l)->lh_TailPred) == (struct Node *)(l) )
113 VOID
AddTail(struct List
*, struct Node
*);
114 struct Node
*FindName(struct List
*, STRPTR
);
115 VOID
Remove(struct Node
*node
);
116 #endif /* SUPPORT_H */