source: trunk/src/bitfield.h @ 150

Last change on this file since 150 was 150, checked in by sam, 10 years ago

Replace mouse scrolling with a joystick simulated by the e/s/d/f keys.

  • Property svn:keywords set to Id
File size: 770 bytes
Line 
1//
2// Deus Hax (working title)
3// Copyright (c) 2010 Sam Hocevar <sam@hocevar.net>
4//
5
6//
7// The BitField class
8// ------------------
9//
10
11#if !defined __DH_BITFIELD_H__
12#define __DH_BITFIELD_H__
13
14template class BitField<unsigned int COUNT>
15{
16public:
17    BitField()
18    {
19        memset(bits, 0, sizeof(bits));
20    }
21
22    inline unsigned int IsSet(unsigned int index)
23    {
24        return bits[index / 32] & (1 << (index & 31));
25    }
26
27    inline void Set(unsigned int index)
28    {
29        bits[index / 32] |= (1 << (index & 31));
30    }
31
32    inline void Unset(unsigned int index)
33    {
34        bits[index / 32] &= ~(1 << (index & 31));
35    }
36
37
38private:
39    /* FIXME: use uint32_t here instead */
40    unsigned int bits[(COUNT + 31) / 32];
41};
42
43#endif // __DH_BITFIELD_H__
44
Note: See TracBrowser for help on using the repository browser.