Changeset ,98
- Timestamp:
- 11/07/2008 04:21:27 PM (2 months ago)
- branch-nick:
- bzr
- Files:
-
- vesper/src/tests (added)
- vesper/src/tests/test_BitArray.cpp (added)
- vesper/src/lib/BitArray.h (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
vesper/src/lib/BitArray.h
r94 r98 8 8 9 9 #include "Types.h" 10 #include "Macros.h" 10 11 11 12 /** 12 An unordered array that holds its contents internally as bits. Therefore, 13 each element can only be of boolean type. 14 15 Unit tested: 24 Jul 07 16 **/ 17 13 * An unordered array that holds its contents internally as bits. Therefore, 14 * each element can only be of boolean type. 15 */ 18 16 class BitArray 19 17 { 20 18 public: 21 inline static uint32_t INDEX_TO_BIT(int a) { return a * (8*4); } 22 inline static uint32_t INDEX_FROM_BIT(int a) { return a / (8*4); } 19 // Array dword position to bit index. 20 inline static uint32_t INDEX_TO_BIT(int a) { return a * (8*4); } 21 // Bit to dword position in array. 22 inline static uint32_t INDEX_FROM_BIT(int a) { return a / (8*4); } 23 // Bit to offset within dword. 23 24 inline static uint32_t OFFSET_FROM_BIT(int a) { return a % (8*4); } 24 25 … … 28 29 BitArray(uint32_t nbits) : N(nbits) 29 30 { 31 ASSERT(N >= 32); 30 32 table = new uint32_t [INDEX_FROM_BIT(N)]; 31 clear All();33 clear_all(); 32 34 } 35 36 ~BitArray() 37 { 38 delete [] table; 39 } 33 40 34 41 /** 35 42 * Clears the value of all bits in the bitmap. 36 43 */ 37 void clear All()44 void clear_all() 38 45 { 39 46 for (uint32_t i = 0; i < INDEX_FROM_BIT(N); i++) … … 80 87 * just looping and calling test(). 81 88 */ 82 uint32_t first Clear()89 uint32_t first_clear() 83 90 { 84 91 for (uint32_t i = 0; i < INDEX_FROM_BIT(N); i++) … … 104 111 * just looping and calling test(). 105 112 */ 106 uint32_t first Set()113 uint32_t first_set() 107 114 { 108 115 for (uint32_t i = 0; i < INDEX_FROM_BIT(N); i++)
