blob: de26a6a14040c59194b3a0d06c8905fdb88c9eb5 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
#ifndef PACKED_INT_ARRAY_H
#define PACKED_INT_ARRAY_H
#include <bu/string.h>
class PackedIntArray
{
public:
typedef uint_fast8_t Unit;
PackedIntArray( Unit iBitWidth );
PackedIntArray( Unit iBitWidth, int iCapacity );
PackedIntArray( const PackedIntArray &rSrc );
virtual ~PackedIntArray();
void clear();
void append( Unit i );
void remove();
Unit operator[]( int idx ) const { return get( idx ); }
Unit get( int idx ) const;
void set( int idx, Unit i );
int getSize() const { return iCount; }
void set( const PackedIntArray &rSrc, int iStart, int iSize );
void set( const PackedIntArray &rSrc );
void trim();
Bu::String toBitString() const;
Bu::String toString() const;
private:
void checkCapacity();
private:
typedef uint_fast32_t Store;
Unit iBitWidth;
Store *aData;
int iCapacity;
int iCount;
int iMaxSpan;
Unit uMask;
};
#endif
|