1 /* 2 * lists.c -- Includefile of lists.c 3 * 4 * Copyright 1995, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016 Free 5 * Software Foundation, Inc. 6 * 7 * Enhancements Copyright 2005 Alessandro Scotti 8 * 9 * ------------------------------------------------------------------------ 10 * 11 * GNU XBoard is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU General Public License as published by 13 * the Free Software Foundation, either version 3 of the License, or (at 14 * your option) any later version. 15 * 16 * GNU XBoard is distributed in the hope that it will be useful, but 17 * WITHOUT ANY WARRANTY; without even the implied warranty of 18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 19 * General Public License for more details. 20 * 21 * You should have received a copy of the GNU General Public License 22 * along with this program. If not, see http://www.gnu.org/licenses/. * 23 * 24 *------------------------------------------------------------------------ 25 ** See the file ChangeLog for a revision history. */ 26 27 /* 28 * This file could well be a part of backend.c, but I prefer it this 29 * way. 30 */ 31 32 #ifndef XB_LISTS 33 #define XB_LISTS 34 35 36 /* Type definition: Node of a double linked list. 37 */ 38 typedef struct XB_ListNode { 39 struct XB_ListNode *succ; 40 struct XB_ListNode *pred; 41 } ListNode; 42 43 44 /* Type definition: Double linked list. 45 * 46 * The list structure consists of two ListNode's: The pred entry of 47 * the head being the succ entry of the tail. Thus a list is empty 48 * if and only if it consists of 2 nodes. :-) 49 */ 50 typedef struct { 51 struct XB_ListNode *head; /* The list structure consists of two */ 52 struct XB_ListNode *tail; /* ListNode's: The pred entry of the */ 53 struct XB_ListNode *tailPred; /* head being the succ entry of the */ 54 } List; /* tail. */ 55 56 57 58 /* Function prototypes 59 */ 60 extern int ListEmpty P((List *)); 61 void ListNew P((List *)); 62 void ListRemove P((ListNode *)); 63 void ListNodeFree P((ListNode *)); 64 ListNode *ListNodeCreate P((size_t)); 65 void ListInsert P((ListNode *, ListNode *)); 66 void ListAddHead P((List *, ListNode *)); 67 void ListAddTail P((List *, ListNode *)); 68 ListNode *ListElem P((List *, int)); 69 70 71 #endif 72