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