1 /* do not edit automatically generated by mc from SymbolKey. */
2 /* SymbolKey.def binary tree operations for storing symbols.
4 Copyright (C) 2001-2023 Free Software Foundation, Inc.
5 Contributed by Gaius Mulley <gaius.mulley@southwales.ac.uk>.
7 This file is part of GNU Modula-2.
9 GNU Modula-2 is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 3, or (at your option)
14 GNU Modula-2 is distributed in the hope that it will be useful, but
15 WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 General Public License for more details.
19 You should have received a copy of the GNU General Public License
20 along with GNU Modula-2; see the file COPYING3. If not see
21 <http://www.gnu.org/licenses/>. */
24 #if !defined (_SymbolKey_H)
32 # if !defined (PROC_D)
34 typedef void (*PROC_t
) (void);
35 typedef struct { PROC_t proc
; } PROC
;
39 # include "GNameKey.h"
41 # if defined (_SymbolKey_C)
44 # define EXTERN extern
47 # define SymbolKey_NulKey 0
48 #if !defined (SymbolKey_SymbolTree_D)
49 # define SymbolKey_SymbolTree_D
50 typedef void *SymbolKey_SymbolTree
;
53 typedef struct SymbolKey_IsSymbol_p SymbolKey_IsSymbol
;
55 typedef struct SymbolKey_PerformOperation_p SymbolKey_PerformOperation
;
57 typedef unsigned int (*SymbolKey_IsSymbol_t
) (unsigned int);
58 struct SymbolKey_IsSymbol_p
{ SymbolKey_IsSymbol_t proc
; };
60 typedef void (*SymbolKey_PerformOperation_t
) (unsigned int);
61 struct SymbolKey_PerformOperation_p
{ SymbolKey_PerformOperation_t proc
; };
65 InitTree - Initializes a SymbolTree pointed to by t.
68 EXTERN
void SymbolKey_InitTree (SymbolKey_SymbolTree
*t
);
71 KillTree - Destroys the SymbolTree pointed to by t.
74 EXTERN
void SymbolKey_KillTree (SymbolKey_SymbolTree
*t
);
77 GetSymKey - Searches the SymbolTree t for an entry NameKey. If
78 found then the SymKey is returned. NulKey = not found.
81 EXTERN
unsigned int SymbolKey_GetSymKey (SymbolKey_SymbolTree t
, NameKey_Name NameKey
);
84 PutSymKey - Puts an symbol entry NameKey in the SymbolTree t.
85 SymKey is the value stored with NameKey.
88 EXTERN
void SymbolKey_PutSymKey (SymbolKey_SymbolTree t
, NameKey_Name NameKey
, unsigned int SymKey
);
91 DelSymKey - Deletes a symbol entry NameKey in the SymbolTree t.
94 EXTERN
void SymbolKey_DelSymKey (SymbolKey_SymbolTree t
, NameKey_Name NameKey
);
97 IsEmptyTree - returns true if SymbolTree, t, is empty.
100 EXTERN
unsigned int SymbolKey_IsEmptyTree (SymbolKey_SymbolTree t
);
103 DoesTreeContainAny - returns true if SymbolTree, t, contains any
104 symbols which in turn return true when procedure,
105 P, is called with a symbol as its parameter.
108 EXTERN
unsigned int SymbolKey_DoesTreeContainAny (SymbolKey_SymbolTree t
, SymbolKey_IsSymbol P
);
111 ForeachNodeDo - for each node in SymbolTree, t, a procedure, P,
112 is called with the node symbol as its parameter.
113 It traverse the tree in order.
116 EXTERN
void SymbolKey_ForeachNodeDo (SymbolKey_SymbolTree t
, SymbolKey_PerformOperation P
);
119 ContainsSymKey - return TRUE if tree, t, contains an entry for, NameKey.
122 EXTERN
unsigned int SymbolKey_ContainsSymKey (SymbolKey_SymbolTree t
, NameKey_Name NameKey
);
125 NoOfNodes - returns the number of nodes in the tree t.
128 EXTERN
unsigned int SymbolKey_NoOfNodes (SymbolKey_SymbolTree t
, SymbolKey_IsSymbol condition
);
131 ForeachNodeConditionDo - traverse the tree t and for any node which satisfied
135 EXTERN
void SymbolKey_ForeachNodeConditionDo (SymbolKey_SymbolTree t
, SymbolKey_IsSymbol condition
, SymbolKey_PerformOperation P
);