|
Revision 13041, 1.2 kB
(checked in by robert, 14 months ago)
|
|
Ran script to remove trailing spaces and tabs
|
-
Property svn:eol-style set to
native
-
Property svn:keywords set to
Author Date Id Revision
|
| Line | |
|---|
| 1 | |
|---|
| 2 | |
|---|
| 3 | |
|---|
| 4 | |
|---|
| 5 | |
|---|
| 6 | |
|---|
| 7 | |
|---|
| 8 | |
|---|
| 9 | #include "memory.h" |
|---|
| 10 | #include "BITSET.h" |
|---|
| 11 | |
|---|
| 12 | #include <cstring> |
|---|
| 13 | |
|---|
| 14 | bool BITSET::Init(int numberOfBits) |
|---|
| 15 | { |
|---|
| 16 | |
|---|
| 17 | m_bits.clear(); |
|---|
| 18 | |
|---|
| 19 | |
|---|
| 20 | m_numBytes=(numberOfBits>>3)+1; |
|---|
| 21 | |
|---|
| 22 | |
|---|
| 23 | m_bits.reserve(m_numBytes); |
|---|
| 24 | m_bits_aux=&m_bits[0]; |
|---|
| 25 | |
|---|
| 26 | ClearAll(); |
|---|
| 27 | |
|---|
| 28 | return true; |
|---|
| 29 | } |
|---|
| 30 | |
|---|
| 31 | void BITSET::ClearAll() |
|---|
| 32 | { |
|---|
| 33 | memset(m_bits_aux, 0, m_numBytes); |
|---|
| 34 | } |
|---|
| 35 | |
|---|
| 36 | void BITSET::SetAll() |
|---|
| 37 | { |
|---|
| 38 | memset(m_bits_aux, 0xFF, m_numBytes); |
|---|
| 39 | } |
|---|
| 40 | |
|---|
| 41 | void BITSET::Clear(int bitNumber) |
|---|
| 42 | { |
|---|
| 43 | m_bits_aux[bitNumber>>3] &= ~(1<<(bitNumber & 7)); |
|---|
| 44 | } |
|---|
| 45 | |
|---|
| 46 | void BITSET::Set(int bitNumber) |
|---|
| 47 | { |
|---|
| 48 | m_bits_aux[bitNumber>>3] |= 1<<(bitNumber&7); |
|---|
| 49 | } |
|---|
| 50 | |
|---|
| 51 | unsigned char BITSET::IsSet(int bitNumber) const |
|---|
| 52 | { |
|---|
| 53 | return static_cast<unsigned char>(m_bits_aux[bitNumber>>3] & 1<<(bitNumber&7)); |
|---|
| 54 | } |
|---|