| 1 |
/* do not edit automatically generated by mc from Indexing. */ |
| 2 |
/* Indexing.def provides a dynamic indexing mechanism for CARDINAL. |
| 3 |
|
| 4 |
Copyright (C) 2003-2025 Free Software Foundation, Inc. |
| 5 |
Contributed by Gaius Mulley <[email protected]>. |
| 6 |
|
| 7 |
This file is part of GNU Modula-2. |
| 8 |
|
| 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) |
| 12 |
any later version. |
| 13 |
|
| 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. |
| 18 |
|
| 19 |
Under Section 7 of GPL version 3, you are granted additional |
| 20 |
permissions described in the GCC Runtime Library Exception, version |
| 21 |
3.1, as published by the Free Software Foundation. |
| 22 |
|
| 23 |
You should have received a copy of the GNU General Public License and |
| 24 |
a copy of the GCC Runtime Library Exception along with this program; |
| 25 |
see the files COPYING3 and COPYING.RUNTIME respectively. If not, see |
| 26 |
<http://www.gnu.org/licenses/>. */ |
| 27 |
|
| 28 |
|
| 29 |
#if !defined (_Indexing_H) |
| 30 |
# define _Indexing_H |
| 31 |
|
| 32 |
#include "config.h" |
| 33 |
#include "system.h" |
| 34 |
# ifdef __cplusplus |
| 35 |
extern "C" { |
| 36 |
# endif |
| 37 |
#include <stdbool.h> |
| 38 |
# if !defined (PROC_D) |
| 39 |
# define PROC_D |
| 40 |
typedef void (*PROC_t) (void); |
| 41 |
typedef struct { PROC_t proc; } PROC; |
| 42 |
# endif |
| 43 |
|
| 44 |
# include "GSYSTEM.h" |
| 45 |
|
| 46 |
# if defined (_Indexing_C) |
| 47 |
# define EXTERN |
| 48 |
# else |
| 49 |
# define EXTERN extern |
| 50 |
# endif |
| 51 |
|
| 52 |
#if !defined (Indexing_Index_D) |
| 53 |
# define Indexing_Index_D |
| 54 |
typedef void *Indexing_Index; |
| 55 |
#endif |
| 56 |
|
| 57 |
typedef struct Indexing_IndexProcedure_p Indexing_IndexProcedure; |
| 58 |
|
| 59 |
typedef void (*Indexing_IndexProcedure_t) (void *); |
| 60 |
struct Indexing_IndexProcedure_p { Indexing_IndexProcedure_t proc; }; |
| 61 |
|
| 62 |
|
| 63 |
/* |
| 64 |
InitIndexTuned - creates a dynamic array with low indice. |
| 65 |
minsize is the initial number of elements the |
| 66 |
array is allocated and growfactor determines how |
| 67 |
it will be resized once it becomes full. |
| 68 |
*/ |
| 69 |
|
| 70 |
EXTERN Indexing_Index Indexing_InitIndexTuned (unsigned int low, unsigned int minsize, unsigned int growfactor); |
| 71 |
|
| 72 |
/* |
| 73 |
InitIndex - creates and returns an Index. |
| 74 |
*/ |
| 75 |
|
| 76 |
EXTERN Indexing_Index Indexing_InitIndex (unsigned int low); |
| 77 |
|
| 78 |
/* |
| 79 |
KillIndex - returns Index to free storage. |
| 80 |
*/ |
| 81 |
|
| 82 |
EXTERN Indexing_Index Indexing_KillIndex (Indexing_Index i); |
| 83 |
|
| 84 |
/* |
| 85 |
DebugIndex - turns on debugging within an index. |
| 86 |
*/ |
| 87 |
|
| 88 |
EXTERN Indexing_Index Indexing_DebugIndex (Indexing_Index i); |
| 89 |
|
| 90 |
/* |
| 91 |
InBounds - returns TRUE if indice, n, is within the bounds |
| 92 |
of the dynamic array. |
| 93 |
*/ |
| 94 |
|
| 95 |
EXTERN bool Indexing_InBounds (Indexing_Index i, unsigned int n); |
| 96 |
|
| 97 |
/* |
| 98 |
HighIndice - returns the last legally accessible indice of this array. |
| 99 |
*/ |
| 100 |
|
| 101 |
EXTERN unsigned int Indexing_HighIndice (Indexing_Index i); |
| 102 |
|
| 103 |
/* |
| 104 |
LowIndice - returns the first legally accessible indice of this array. |
| 105 |
*/ |
| 106 |
|
| 107 |
EXTERN unsigned int Indexing_LowIndice (Indexing_Index i); |
| 108 |
|
| 109 |
/* |
| 110 |
PutIndice - places, a, into the dynamic array at position i[n] |
| 111 |
*/ |
| 112 |
|
| 113 |
EXTERN void Indexing_PutIndice (Indexing_Index i, unsigned int n, void * a); |
| 114 |
|
| 115 |
/* |
| 116 |
GetIndice - retrieves, element i[n] from the dynamic array. |
| 117 |
*/ |
| 118 |
|
| 119 |
EXTERN void * Indexing_GetIndice (Indexing_Index i, unsigned int n); |
| 120 |
|
| 121 |
/* |
| 122 |
IsIndiceInIndex - returns TRUE if, a, is in the index, i. |
| 123 |
*/ |
| 124 |
|
| 125 |
EXTERN bool Indexing_IsIndiceInIndex (Indexing_Index i, void * a); |
| 126 |
|
| 127 |
/* |
| 128 |
RemoveIndiceFromIndex - removes, a, from Index, i. |
| 129 |
*/ |
| 130 |
|
| 131 |
EXTERN void Indexing_RemoveIndiceFromIndex (Indexing_Index i, void * a); |
| 132 |
|
| 133 |
/* |
| 134 |
DeleteIndice - delete i[j] from the array. |
| 135 |
*/ |
| 136 |
|
| 137 |
EXTERN void Indexing_DeleteIndice (Indexing_Index i, unsigned int j); |
| 138 |
|
| 139 |
/* |
| 140 |
IncludeIndiceIntoIndex - if the indice is not in the index, then |
| 141 |
add it at the end. |
| 142 |
*/ |
| 143 |
|
| 144 |
EXTERN void Indexing_IncludeIndiceIntoIndex (Indexing_Index i, void * a); |
| 145 |
|
| 146 |
/* |
| 147 |
ForeachIndiceInIndexDo - for each j indice of i, call procedure p(i[j]) |
| 148 |
*/ |
| 149 |
|
| 150 |
EXTERN void Indexing_ForeachIndiceInIndexDo (Indexing_Index i, Indexing_IndexProcedure p); |
| 151 |
|
| 152 |
/* |
| 153 |
IsEmpty - return TRUE if the array has no entries it. |
| 154 |
*/ |
| 155 |
|
| 156 |
EXTERN bool Indexing_IsEmpty (Indexing_Index i); |
| 157 |
|
| 158 |
/* |
| 159 |
FindIndice - returns the indice containing a. |
| 160 |
It returns zero if a is not found in array i. |
| 161 |
*/ |
| 162 |
|
| 163 |
EXTERN unsigned int Indexing_FindIndice (Indexing_Index i, void * a); |
| 164 |
# ifdef __cplusplus |
| 165 |
} |
| 166 |
# endif |
| 167 |
|
| 168 |
# undef EXTERN |
| 169 |
#endif |