root/OpenSceneGraph/trunk/src/osgPlugins/bsp/BITSET.cpp @ 13041

Revision 13041, 1.2 kB (checked in by robert, 2 years 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//  BITSET.cpp
3//  functions for class for set of bits to represent many true/falses
4//  You may use this code however you wish, but if you do, please credit me and
5//  provide a link to my website in a readme file or similar
6//  Downloaded from: www.paulsprojects.net
7//  Created:  8th August 2002
8//////////////////////////////////////////////////////////////////////////////////////////
9#include "memory.h"
10#include "BITSET.h"
11
12#include <cstring>
13
14bool BITSET::Init(int numberOfBits)
15{
16  //Delete any memory allocated to bits
17  m_bits.clear();
18
19  //Calculate size
20  m_numBytes=(numberOfBits>>3)+1;
21
22  //Create memory
23  m_bits.reserve(m_numBytes);
24  m_bits_aux=&m_bits[0];
25
26  ClearAll();
27
28  return true;
29}
30
31void BITSET::ClearAll()
32{
33  memset(m_bits_aux, 0, m_numBytes);
34}
35
36void BITSET::SetAll()
37{
38  memset(m_bits_aux, 0xFF, m_numBytes);
39}
40
41void BITSET::Clear(int bitNumber)
42{
43  m_bits_aux[bitNumber>>3] &= ~(1<<(bitNumber & 7));
44}
45
46void BITSET::Set(int bitNumber)
47{
48  m_bits_aux[bitNumber>>3] |= 1<<(bitNumber&7);
49}
50
51unsigned char BITSET::IsSet(int bitNumber) const
52{
53  return static_cast<unsigned char>(m_bits_aux[bitNumber>>3] & 1<<(bitNumber&7));
54}
Note: See TracBrowser for help on using the browser.