Kstars

dict.h
1/*
2** Author: Eric Veach, July 1994.
3**
4*/
5
6#ifndef __dict_list_h_
7#define __dict_list_h_
8
9/* Use #define's so that another heap implementation can use this one */
10
11#define DictKey DictListKey
12#define Dict DictList
13#define DictNode DictListNode
14
15#define dictNewDict(frame, leq) __gl_dictListNewDict(frame, leq)
16#define dictDeleteDict(dict) __gl_dictListDeleteDict(dict)
17
18#define dictSearch(dict, key) __gl_dictListSearch(dict, key)
19#define dictInsert(dict, key) __gl_dictListInsert(dict, key)
20#define dictInsertBefore(dict, node, key) __gl_dictListInsertBefore(dict, node, key)
21#define dictDelete(dict, node) __gl_dictListDelete(dict, node)
22
23#define dictKey(n) __gl_dictListKey(n)
24#define dictSucc(n) __gl_dictListSucc(n)
25#define dictPred(n) __gl_dictListPred(n)
26#define dictMin(d) __gl_dictListMin(d)
27#define dictMax(d) __gl_dictListMax(d)
28
29typedef void *DictKey;
30typedef struct Dict Dict;
31typedef struct DictNode DictNode;
32
33Dict *dictNewDict(void *frame, int (*leq)(void *frame, DictKey key1, DictKey key2));
34
35void dictDeleteDict(Dict *dict);
36
37/* Search returns the node with the smallest key greater than or equal
38 * to the given key. If there is no such key, returns a node whose
39 * key is NULL. Similarly, Succ(Max(d)) has a NULL key, etc.
40 */
41DictNode *dictSearch(Dict *dict, DictKey key);
42DictNode *dictInsertBefore(Dict *dict, DictNode *node, DictKey key);
43void dictDelete(Dict *dict, DictNode *node);
44
45#define __gl_dictListKey(n) ((n)->key)
46#define __gl_dictListSucc(n) ((n)->next)
47#define __gl_dictListPred(n) ((n)->prev)
48#define __gl_dictListMin(d) ((d)->head.next)
49#define __gl_dictListMax(d) ((d)->head.prev)
50#define __gl_dictListInsert(d, k) (dictInsertBefore((d), &(d)->head, (k)))
51
52/*** Private data structures ***/
53
54struct DictNode
55{
56 DictKey key;
57 DictNode *next;
58 DictNode *prev;
59};
60
61struct Dict
62{
63 DictNode head;
64 void *frame;
65 int (*leq)(void *frame, DictKey key1, DictKey key2);
66};
67
68#endif
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Nov 29 2024 11:57:48 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.