1 /* do not edit automatically generated by mc from Indexing. */
2 /* Indexing.def provides a dynamic indexing mechanism.
4 Copyright (C) 2015-2025 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 (_Indexing_H)
33 # if !defined (PROC_D)
35 typedef void (*PROC_t
) (void);
36 typedef struct { PROC_t proc
; } PROC
;
41 # if defined (_Indexing_C)
44 # define EXTERN extern
47 #if !defined (Indexing_Index_D)
48 # define Indexing_Index_D
49 typedef void *Indexing_Index
;
52 typedef struct Indexing_IndexProcedure_p Indexing_IndexProcedure
;
54 typedef void (*Indexing_IndexProcedure_t
) (void *);
55 struct Indexing_IndexProcedure_p
{ Indexing_IndexProcedure_t proc
; };
59 InitIndex - creates and returns an Index.
62 EXTERN Indexing_Index
Indexing_InitIndex (unsigned int low
);
65 KillIndex - returns Index to free storage.
68 EXTERN Indexing_Index
Indexing_KillIndex (Indexing_Index i
);
71 DebugIndex - turns on debugging within an index.
74 EXTERN Indexing_Index
Indexing_DebugIndex (Indexing_Index i
);
77 InBounds - returns TRUE if indice, n, is within the bounds
81 EXTERN
bool Indexing_InBounds (Indexing_Index i
, unsigned int n
);
84 HighIndice - returns the last legally accessible indice of this array.
87 EXTERN
unsigned int Indexing_HighIndice (Indexing_Index i
);
90 LowIndice - returns the first legally accessible indice of this array.
93 EXTERN
unsigned int Indexing_LowIndice (Indexing_Index i
);
96 PutIndice - places, a, into the dynamic array at position i[n]
99 EXTERN
void Indexing_PutIndice (Indexing_Index i
, unsigned int n
, void * a
);
102 GetIndice - retrieves, element i[n] from the dynamic array.
105 EXTERN
void * Indexing_GetIndice (Indexing_Index i
, unsigned int n
);
108 IsIndiceInIndex - returns TRUE if, a, is in the index, i.
111 EXTERN
bool Indexing_IsIndiceInIndex (Indexing_Index i
, void * a
);
114 RemoveIndiceFromIndex - removes, a, from Index, i.
117 EXTERN
void Indexing_RemoveIndiceFromIndex (Indexing_Index i
, void * a
);
120 DeleteIndice - delete i[j] from the array.
123 EXTERN
void Indexing_DeleteIndice (Indexing_Index i
, unsigned int j
);
126 IncludeIndiceIntoIndex - if the indice is not in the index, then
130 EXTERN
void Indexing_IncludeIndiceIntoIndex (Indexing_Index i
, void * a
);
133 ForeachIndiceInIndexDo - for each j indice of i, call procedure p(i[j])
136 EXTERN
void Indexing_ForeachIndiceInIndexDo (Indexing_Index i
, Indexing_IndexProcedure p
);