mirror of
https://github.com/cemu-project/Cemu.git
synced 2025-07-11 01:08:30 +12:00
Add all the files
This commit is contained in:
parent
e3db07a16a
commit
d60742f52b
1445 changed files with 430238 additions and 0 deletions
34
src/util/containers/SmallBitset.h
Normal file
34
src/util/containers/SmallBitset.h
Normal file
|
@ -0,0 +1,34 @@
|
|||
|
||||
// optimized and compact version of std::bitset with no error checking in release mode
|
||||
// uses a single uint32 to store the bitmask, thus allowing up to 32 bool values
|
||||
|
||||
template<size_t N>
|
||||
class SmallBitset
|
||||
{
|
||||
public:
|
||||
SmallBitset() {};
|
||||
static_assert(N <= 32);
|
||||
|
||||
bool test(size_t index) const
|
||||
{
|
||||
cemu_assert_debug(index < N);
|
||||
return ((m_bits >> index) & 1) != 0;
|
||||
}
|
||||
|
||||
void set(size_t index, bool val)
|
||||
{
|
||||
cemu_assert_debug(index < N);
|
||||
m_bits &= ~(1u << index);
|
||||
if (val)
|
||||
m_bits |= (1u << index);
|
||||
}
|
||||
|
||||
void set(size_t index)
|
||||
{
|
||||
cemu_assert_debug(index < N);
|
||||
m_bits |= (1u << index);
|
||||
}
|
||||
|
||||
private:
|
||||
uint32 m_bits{};
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue