ZEDA  1.6.18
zeda_index.h
Go to the documentation of this file.
1 /* ZEDA - Elementary Data and Algorithms
2  * Copyright (C) 1998 Tomomichi Sugihara (Zhidao)
3  */
9 #ifndef __ZEDA_INDEX_H__
10 #define __ZEDA_INDEX_H__
11 
12 #include <stdarg.h>
13 #include <zeda/zeda_array.h>
14 
16 
17 /* ********************************************************** *//* ************************************************** */
20 
21 /* ********************************************************** *//* ******************************************************* */
38 
40 #define zIndexIncSize(i) ( zArraySize(i)++ )
41 
42 #define zIndexDecSize(i) ( zArraySize(i) -= ( zArraySize(i) > 0 ? 1 : 0 ) )
43 
45 #define zIndexPosIsValid(i,n) zArrayPosIsValid( i, n )
46 
47 #define zIndexElemNC(i,n) zArrayBuf(i)[n]
48 #define zIndexElem(i,n) ( zIndexPosIsValid(i,n) ? zIndexElemNC(i,n) : -1 )
49 #define zIndexSetElemNC(i,n,e) ( zIndexElemNC(i,n) = (e) )
50 #define zIndexSetElem(i,n,e) ( zIndexPosIsValid(i,n) ? zIndexSetElemNC(i,n,e) : -1 )
51 
52 #define zIndexHead(idx) ( *zArrayHead(idx) )
53 #define zIndexNeck(idx) ( *zArrayNeck(idx) )
54 #define zIndexTail(idx) ( *zArrayTail(idx) )
55 
64 __EXPORT zIndex zIndexAlloc(int size);
65 
75 __EXPORT zIndex zIndexCreate(int size);
76 
88 #ifndef __KERNEL__
89 zIndex zIndexCreateList(int num, ...);
90 #endif /* __KERNEL__ */
91 
100 #ifndef __KERNEL__
101 zIndex zIndexSetList(zIndex idx, ...);
102 #endif /* __KERNEL__ */
103 
109 __EXPORT void zIndexFree(zIndex idx);
110 
118 
125 __EXPORT zIndex zIndexOrder(zIndex idx, int s);
126 
134 __EXPORT bool zIndexIsEqual(zIndex idx1, zIndex idx2);
135 
144 __EXPORT int zIndexSwap(zIndex idx, int p1, int p2);
145 
156 __EXPORT int zIndexMove(zIndex idx, int from, int to);
157 
158 #ifndef __KERNEL__
159 
175 __EXPORT zIndex zIndexFScan(FILE *fp);
176 #define zIndexScan() zIndexFScan( stdin )
177 
192 __EXPORT void zIndexFPrint(FILE *fp, zIndex idx);
193 #define zIndexPrint(i) zIndexFPrint( stdout, i )
194 
206 __EXPORT void zIndexDataFPrint(FILE *fp, zIndex idx);
207 #define zIndexDataPrint(i) zIndexDataFPrint( stdout, i )
208 #else
209 void zIndexPrint(zIndex idx);
210 #endif /* __KERNEL__ */
211 
212 #include <zeda/zeda_list.h>
213 
216 
220 
221 #endif /* __ZEDA_INDEX_H__ */
Definition: zeda_list.h:413
zIndex zIndexCreate(int size)
create an array of integer values.
int zIndexSwap(zIndex idx, int p1, int p2)
swap two elements of an array of integer values.
#define zArrayClass(array_t, cell_t)
generate array class.
Definition: zeda_array.h:53
zIndex zIndexAlloc(int size)
allocate an array of integer values.
zIndex zIndexSetList(zIndex idx,...)
set elements of an integer vector from argument list.
zIndex zIndexZero(zIndex idx)
zero an array of integer values.
#define __END_DECLS
Definition: zeda_defs.h:30
zIndex zIndexFScan(FILE *fp)
scan an array of integer values from a file.
bool zIndexIsEqual(zIndex idx1, zIndex idx2)
check if two arrays of integer values are equal.
void zIndexDataFPrint(FILE *fp, zIndex idx)
print an array of integer values out to a file.
zIndex zIndexOrder(zIndex idx, int s)
order an array of integer values.
zIndexStruct * zIndex
Definition: zeda_index.h:37
int zIndexMove(zIndex idx, int from, int to)
move an element of an array of integer values.
Definition: zeda_index.h:36
zIndex zIndexCreateFromList(zIntList *list)
create an integer vector from a list of integers.
zIndex zIndexCreateList(int num,...)
create an array of integer according to a specified list of arguments.
#define __BEGIN_DECLS
Definition: zeda_defs.h:26
integer value array class
list operation.
void zIndexFPrint(FILE *fp, zIndex idx)
print an array of integer values to a file.
#define __EXPORT
Definition: zeda_compat.h:32
void zIndexFree(zIndex idx)
free an array of integer values.
array operation.
#define zIndexPrint(i)
Definition: zeda_index.h:193