2 * SGI FREE SOFTWARE LICENSE B (Version 2.0, Sept. 18, 2008)
3 * Copyright (C) 1991-2000 Silicon Graphics, Inc. All Rights Reserved.
5 * Permission is hereby granted, free of charge, to any person obtaining a
6 * copy of this software and associated documentation files (the "Software"),
7 * to deal in the Software without restriction, including without limitation
8 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
9 * and/or sell copies of the Software, and to permit persons to whom the
10 * Software is furnished to do so, subject to the following conditions:
12 * The above copyright notice including the dates of first publication and
13 * either this permission notice or a reference to
14 * http://oss.sgi.com/projects/FreeB/
15 * shall be included in all copies or substantial portions of the Software.
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
18 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
20 * SILICON GRAPHICS, INC. BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
21 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
22 * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25 * Except as contained in this notice, the name of Silicon Graphics, Inc.
26 * shall not be used in advertising or otherwise to promote the sale, use or
27 * other dealings in this Software without prior written authorization from
28 * Silicon Graphics, Inc.
31 ** Author: Eric Veach, July 1994.
35 #ifndef __dict_list_h_
36 #define __dict_list_h_
38 /* Use #define's so that another heap implementation can use this one */
40 #define DictKey DictListKey
42 #define DictNode DictListNode
44 #define dictNewDict(frame,leq) __gl_dictListNewDict(frame,leq)
45 #define dictDeleteDict(dict) __gl_dictListDeleteDict(dict)
47 #define dictSearch(dict,key) __gl_dictListSearch(dict,key)
48 #define dictInsert(dict,key) __gl_dictListInsert(dict,key)
49 #define dictInsertBefore(dict,node,key) __gl_dictListInsertBefore(dict,node,key)
50 #define dictDelete(dict,node) __gl_dictListDelete(dict,node)
52 #define dictKey(n) __gl_dictListKey(n)
53 #define dictSucc(n) __gl_dictListSucc(n)
54 #define dictPred(n) __gl_dictListPred(n)
55 #define dictMin(d) __gl_dictListMin(d)
56 #define dictMax(d) __gl_dictListMax(d)
60 typedef void *DictKey
;
61 typedef struct Dict Dict
;
62 typedef struct DictNode DictNode
;
66 int (*leq
)(void *frame
, DictKey key1
, DictKey key2
) );
68 void dictDeleteDict( Dict
*dict
);
70 /* Search returns the node with the smallest key greater than or equal
71 * to the given key. If there is no such key, returns a node whose
72 * key is NULL. Similarly, Succ(Max(d)) has a NULL key, etc.
74 DictNode
*dictSearch( Dict
*dict
, DictKey key
);
75 DictNode
*dictInsertBefore( Dict
*dict
, DictNode
*node
, DictKey key
);
76 void dictDelete( Dict
*dict
, DictNode
*node
);
78 #define __gl_dictListKey(n) ((n)->key)
79 #define __gl_dictListSucc(n) ((n)->next)
80 #define __gl_dictListPred(n) ((n)->prev)
81 #define __gl_dictListMin(d) ((d)->head.next)
82 #define __gl_dictListMax(d) ((d)->head.prev)
83 #define __gl_dictListInsert(d,k) (dictInsertBefore((d),&(d)->head,(k)))
86 /*** Private data structures ***/
97 int (*leq
)(void *frame
, DictKey key1
, DictKey key2
);