1 //------------------------------------------------------------------------- 2 /* 3 Copyright (C) 1997, 2005 - 3D Realms Entertainment 4 5 This file is part of Shadow Warrior version 1.2 6 7 Shadow Warrior is free software; you can redistribute it and/or 8 modify it under the terms of the GNU General Public License 9 as published by the Free Software Foundation; either version 2 10 of the License, or (at your option) any later version. 11 12 This program is distributed in the hope that it will be useful, 13 but WITHOUT ANY WARRANTY; without even the implied warranty of 14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 15 16 See the GNU General Public License for more details. 17 18 You should have received a copy of the GNU General Public License 19 along with this program; if not, write to the Free Software 20 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 21 22 Original Source: 1997 - Frank Maddin and Jim Norwood 23 Prepared for public release: 03/28/2005 - Charlie Wiederhold, 3D Realms 24 */ 25 //------------------------------------------------------------------------- 26 27 #ifndef LISTS_H 28 29 #define LISTS_H 30 31 /********************************************************************/ 32 33 typedef 34 struct List 35 { 36 struct List *Next; 37 struct List *Prev; 38 } LISTHEAD, *LIST; 39 40 #define FIRST(list) (list->Next) 41 #define LAST(list) (list->Prev) 42 43 44 #define INITLIST(list) ( ((LIST) list)->Prev = ((LIST) list)->Next = (LIST) list) 45 46 47 #define INSERT(list, nodep) ( ((LIST) nodep)->Prev = (LIST) list, \ 48 ((LIST) nodep)->Next = ((LIST) list)->Next, \ 49 ((LIST) list)->Next = (LIST) nodep, \ 50 ((LIST) nodep)->Next->Prev = (LIST) nodep) 51 52 #define INSERT_TAIL(list, nodep) ( ((LIST) nodep)->Next = (LIST) list, \ 53 ((LIST) nodep)->Prev = ((LIST) list)->Prev, \ 54 ((LIST) list)->Prev = (LIST) nodep, \ 55 ((LIST) nodep)->Prev->Next = (LIST) nodep) 56 57 #define REMOVE(nodep) ( ((LIST) nodep)->Prev->Next = ((LIST) nodep)->Next, \ 58 ((LIST) nodep)->Next->Prev = ((LIST) nodep)->Prev) 59 60 61 #define TRAVERSE(l, o, n) ASSERT(((LIST)l)->Next && ((LIST)l)->Prev); for (o = (decltype(o))(((LIST)l)->Next); \ 62 n = o->Next, (LIST) o != (LIST) l; \ 63 o = n) 64 65 #define EMPTY(list) (((LIST) list)->Next == (LIST) list) 66 67 #endif 68 69 70