diff options
Diffstat (limited to 'src/packedintarray.h')
-rw-r--r-- | src/packedintarray.h | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/src/packedintarray.h b/src/packedintarray.h new file mode 100644 index 0000000..953492b --- /dev/null +++ b/src/packedintarray.h | |||
@@ -0,0 +1,36 @@ | |||
1 | #ifndef PACKED_INT_ARRAY_H | ||
2 | #define PACKED_INT_ARRAY_H | ||
3 | |||
4 | #include <bu/string.h> | ||
5 | |||
6 | class PackedIntArray | ||
7 | { | ||
8 | public: | ||
9 | typedef uint_fast8_t Unit; | ||
10 | PackedIntArray( Unit iBitWidth ); | ||
11 | PackedIntArray( Unit iBitWidth, int iCapacity ); | ||
12 | virtual ~PackedIntArray(); | ||
13 | |||
14 | void append( Unit i ); | ||
15 | Unit operator[]( int idx ) const { return get( idx ); } | ||
16 | Unit get( int idx ) const; | ||
17 | Unit set( int idx, Unit i ); | ||
18 | int getSize() const { return iCount; } | ||
19 | |||
20 | Bu::String toBitString() const; | ||
21 | Bu::String toString() const; | ||
22 | |||
23 | private: | ||
24 | void checkCapacity(); | ||
25 | |||
26 | private: | ||
27 | typedef uint_fast32_t Store; | ||
28 | Unit iBitWidth; | ||
29 | Store *aData; | ||
30 | int iCapacity; | ||
31 | int iCount; | ||
32 | int iMaxSpan; | ||
33 | Unit uMask; | ||
34 | }; | ||
35 | |||
36 | #endif | ||