×

[PR]この広告は3ヶ月以上更新がないため表示されています。
ホームページを更新後24時間以内に表示されなくなります。

IntArray.h
 1  #ifndef     __SUCCINCT_INTEGER_ARRAY_H_
 2  #define     __SUCCINCT_INTEGER_ARRAY_H_
 3  
 4  
 5  // Functions return the following codes.
 6  #define     IARY_OK     0       // No error.
 7  #define     IARY_EMEM   ( -1 )  // Memory error.
 8  #define     IARY_EIO    ( -2 )  // I/O error.
 9  
10  
11  #ifdef  __cplusplus
12  extern  "C" {
13  #endif
14  
15  
16  // Integers.
17  typedef     unsigned long   IAryIdx;    // Index.
18  typedef     unsigned long   IAryLen;    // Length.
19  typedef     long            IAryInt;    // Integer.
20  typedef     unsigned long   IAryUInt;   // Unsigned integer.
21  
22  // Compressed integer array.
23  typedef     struct IAry     *hIAry;
24  
25  // Status of scan.
26  typedef     struct IAryScan
27  {
28      hIAry       h;      // Target array.
29      IAryIdx     idx;    // Index of next integer.
30      IAryIdx     pos;    // Position of next integer.
31      int         jump;   // Position is valid (0) or not (1).
32  }   IAryScan, *hIAryScan;
33  
34  
35  // Create integer array.
36  int     IAry_Open( hIAry *h );
37  // Destroy integer array.
38  void    IAry_Close( hIAry h );
39  
40  // Load integer array.
41  int     IAry_Load( hIAry *h, const char *path );
42  // Save integer array.
43  int     IAry_Save( hIAry h, const char *path );
44  
45  // Add integer.
46  int     IAry_AddInt( hIAry h, IAryInt x );
47  // Add unsigned integer.
48  int     IAry_AddUInt( hIAry h, IAryUInt x );
49  
50  // Build index.
51  int     IAry_BuildIndex( hIAry h );
52  
53  // Get integer.
54  IAryInt     IAry_GetInt( hIAry h, IAryIdx idx );
55  // Get unsigned integer.
56  IAryUInt    IAry_GetUInt( hIAry h, IAryIdx idx );
57  
58  // Start scan.
59  void    IAry_Start( hIAry h, hIAryScan scan );
60  // Jump to another integer.
61  void    IAry_Jump( hIAryScan scan, IAryIdx idx );
62  // Get next integer.
63  IAryInt     IAry_NextInt( hIAryScan scan );
64  // Get next unsigned integer.
65  IAryUInt    IAry_NextUInt( hIAryScan scan );
66  
67  // Get size.
68  IAryIdx     IAry_Size( hIAry h );
69  
70  
71  #ifdef  __cplusplus
72  }
73  #endif
74  
75  
76  #endif