Debian Codegraph @

gcc/m2/gm2-libs/Indexing.def

raw
1 (* Indexing.def provides a dynamic indexing mechanism for CARDINAL.
2
3 Copyright (C) 2003-2025 Free Software Foundation, Inc.
4 Contributed by Gaius Mulley <[email protected]>.
5
6 This file is part of GNU Modula-2.
7
8 GNU Modula-2 is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 3, or (at your option)
11 any later version.
12
13 GNU Modula-2 is distributed in the hope that it will be useful, but
14 WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 General Public License for more details.
17
18 Under Section 7 of GPL version 3, you are granted additional
19 permissions described in the GCC Runtime Library Exception, version
20 3.1, as published by the Free Software Foundation.
21
22 You should have received a copy of the GNU General Public License and
23 a copy of the GCC Runtime Library Exception along with this program;
24 see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
25 <http://www.gnu.org/licenses/>. *)
26
27 DEFINITION MODULE Indexing ;
28
29 FROM SYSTEM IMPORT ADDRESS ;
30
31
32 TYPE
33 Index ;
34 IndexProcedure = PROCEDURE (ADDRESS) ;
35
36
37 (*
38 InitIndexTuned - creates a dynamic array with low indice.
39 minsize is the initial number of elements the
40 array is allocated and growfactor determines how
41 it will be resized once it becomes full.
42 *)
43
44 PROCEDURE InitIndexTuned (low, minsize, growfactor: CARDINAL) : Index ;
45
46
47 (*
48 InitIndex - creates and returns an Index.
49 *)
50
51 PROCEDURE InitIndex (low: CARDINAL) : Index ;
52
53
54 (*
55 KillIndex - returns Index to free storage.
56 *)
57
58 PROCEDURE KillIndex (i: Index) : Index ;
59
60
61 (*
62 DebugIndex - turns on debugging within an index.
63 *)
64
65 PROCEDURE DebugIndex (i: Index) : Index ;
66
67
68 (*
69 InBounds - returns TRUE if indice, n, is within the bounds
70 of the dynamic array.
71 *)
72
73 PROCEDURE InBounds (i: Index; n: CARDINAL) : BOOLEAN ;
74
75
76 (*
77 HighIndice - returns the last legally accessible indice of this array.
78 *)
79
80 PROCEDURE HighIndice (i: Index) : CARDINAL ;
81
82
83 (*
84 LowIndice - returns the first legally accessible indice of this array.
85 *)
86
87 PROCEDURE LowIndice (i: Index) : CARDINAL ;
88
89
90 (*
91 PutIndice - places, a, into the dynamic array at position i[n]
92 *)
93
94 PROCEDURE PutIndice (i: Index; n: CARDINAL; a: ADDRESS) ;
95
96
97 (*
98 GetIndice - retrieves, element i[n] from the dynamic array.
99 *)
100
101 PROCEDURE GetIndice (i: Index; n: CARDINAL) : ADDRESS ;
102
103
104 (*
105 IsIndiceInIndex - returns TRUE if, a, is in the index, i.
106 *)
107
108 PROCEDURE IsIndiceInIndex (i: Index; a: ADDRESS) : BOOLEAN ;
109
110
111 (*
112 RemoveIndiceFromIndex - removes, a, from Index, i.
113 *)
114
115 PROCEDURE RemoveIndiceFromIndex (i: Index; a: ADDRESS) ;
116
117
118 (*
119 DeleteIndice - delete i[j] from the array.
120 *)
121
122 PROCEDURE DeleteIndice (i: Index; j: CARDINAL) ;
123
124
125 (*
126 IncludeIndiceIntoIndex - if the indice is not in the index, then
127 add it at the end.
128 *)
129
130 PROCEDURE IncludeIndiceIntoIndex (i: Index; a: ADDRESS) ;
131
132
133 (*
134 ForeachIndiceInIndexDo - for each j indice of i, call procedure p(i[j])
135 *)
136
137 PROCEDURE ForeachIndiceInIndexDo (i: Index; p: IndexProcedure) ;
138
139
140 (*
141 IsEmpty - return TRUE if the array has no entries it.
142 *)
143
144 PROCEDURE IsEmpty (i: Index) : BOOLEAN ;
145
146
147 (*
148 FindIndice - returns the indice containing a.
149 It returns zero if a is not found in array i.
150 *)
151
152 PROCEDURE FindIndice (i: Index; a: ADDRESS) : CARDINAL ;
153
154
155 END Indexing.