Update to SGI FreeB 2.0.
[mesa.git] / src / glu / sgi / libtess / dict-list.h
1 /*
2 * SGI FREE SOFTWARE LICENSE B (Version 2.0, Sept. 18, 2008)
3 * Copyright (C) 1991-2000 Silicon Graphics, Inc. All Rights Reserved.
4 *
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:
11 *
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.
16 *
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
23 * SOFTWARE.
24 *
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.
29 */
30 /*
31 ** Author: Eric Veach, July 1994.
32 **
33 ** $Date: 2001/03/17 00:25:41 $ $Revision: 1.1 $
34 ** $Header: /home/krh/git/sync/mesa-cvs-repo/Mesa/src/glu/sgi/libtess/dict-list.h,v 1.1 2001/03/17 00:25:41 brianp Exp $
35 */
36
37 #ifndef __dict_list_h_
38 #define __dict_list_h_
39
40 /* Use #define's so that another heap implementation can use this one */
41
42 #define DictKey DictListKey
43 #define Dict DictList
44 #define DictNode DictListNode
45
46 #define dictNewDict(frame,leq) __gl_dictListNewDict(frame,leq)
47 #define dictDeleteDict(dict) __gl_dictListDeleteDict(dict)
48
49 #define dictSearch(dict,key) __gl_dictListSearch(dict,key)
50 #define dictInsert(dict,key) __gl_dictListInsert(dict,key)
51 #define dictInsertBefore(dict,node,key) __gl_dictListInsertBefore(dict,node,key)
52 #define dictDelete(dict,node) __gl_dictListDelete(dict,node)
53
54 #define dictKey(n) __gl_dictListKey(n)
55 #define dictSucc(n) __gl_dictListSucc(n)
56 #define dictPred(n) __gl_dictListPred(n)
57 #define dictMin(d) __gl_dictListMin(d)
58 #define dictMax(d) __gl_dictListMax(d)
59
60
61
62 typedef void *DictKey;
63 typedef struct Dict Dict;
64 typedef struct DictNode DictNode;
65
66 Dict *dictNewDict(
67 void *frame,
68 int (*leq)(void *frame, DictKey key1, DictKey key2) );
69
70 void dictDeleteDict( Dict *dict );
71
72 /* Search returns the node with the smallest key greater than or equal
73 * to the given key. If there is no such key, returns a node whose
74 * key is NULL. Similarly, Succ(Max(d)) has a NULL key, etc.
75 */
76 DictNode *dictSearch( Dict *dict, DictKey key );
77 DictNode *dictInsertBefore( Dict *dict, DictNode *node, DictKey key );
78 void dictDelete( Dict *dict, DictNode *node );
79
80 #define __gl_dictListKey(n) ((n)->key)
81 #define __gl_dictListSucc(n) ((n)->next)
82 #define __gl_dictListPred(n) ((n)->prev)
83 #define __gl_dictListMin(d) ((d)->head.next)
84 #define __gl_dictListMax(d) ((d)->head.prev)
85 #define __gl_dictListInsert(d,k) (dictInsertBefore((d),&(d)->head,(k)))
86
87
88 /*** Private data structures ***/
89
90 struct DictNode {
91 DictKey key;
92 DictNode *next;
93 DictNode *prev;
94 };
95
96 struct Dict {
97 DictNode head;
98 void *frame;
99 int (*leq)(void *frame, DictKey key1, DictKey key2);
100 };
101
102 #endif