33#include <NDEVR/ObjectAllocator.h>
34#include <NDEVR/BitReference.h>
35#include <NDEVR/BitIterator.h>
38 #define bitset_wrd(pos) ((pos) >> 3)
39 #define bitset_idx(pos) ((pos) & 7)
40 #define bitmaskt(nbits,type) ((nbits) ? ~(type)0 >> (sizeof(type)*8-(nbits)): (type)0)
41 #define bitmask(nbits) cast<uint01>(bitmaskt(nbits,uint32_t))
42 template<
class t_index_type>
57 std::swap(allocator.m_buffer,
m_buffer);
66 template<
bool t_managed>
72 template<
bool t_managed>
113 void swap(t_index_type index_a, t_index_type index_b)
131 bool get(t_index_type index)
const
181 void setAll(
const bool&
object, t_index_type offset, t_index_type size)
187 t_index_type last_word =
bitset_wrd(offset + size - 1);
189 t_index_type loffset =
bitset_idx(offset + size - 1);
191 if (first_word == last_word)
206 memset(
m_buffer + first_word + 1,
object ? 0xFF : 0, last_word - (first_word + 1));
214 for (
uint04 i = 0; i < size; i++)
218 template<
bool is_primitive>
219 void setAll(
const bool* src, t_index_type offset, t_index_type size)
221 for (t_index_type i = 0; i < size; i++)
223 get(i + offset) = src[i];
227 template<
bool is_primitive>
234 t_index_type new_other_offset =
bitset_wrd(other_offset);
235 memmove(
m_buffer + new_offset, allocator.
m_buffer + new_other_offset, new_size);
236 for (t_index_type i = 8 * new_size; i < size; i++)
238 get(i + offset) = allocator.
get(i + other_offset);
241 for (t_index_type i = 0; i < size; i++)
243 get(i + offset) = allocator.
get(i + other_offset);
246 template<
class t_other_allocator>
247 void setAllFromSource(
const t_other_allocator& allocator, t_index_type offset, t_index_type other_offset, t_index_type size)
249 for (t_index_type i = 0; i < size; i++)
250 get(i + offset) = allocator.get(i + other_offset);
252 template<
bool t_managed>
282 t_index_type
count(
const bool& value)
const
296 std::swap(value.m_buffer,
m_buffer);
304 t_index_type byte_size = new_size == 0 ? 0 :
bitset_wrd(new_size - 1) + 1;
325 static const t_index_type BitsSetTable256[256] =
327 # define NDV_B2(n) n, n+1, n+1, n+2
328 # define NDV_B4(n) NDV_B2(n), NDV_B2(n+1), NDV_B2(n+1), NDV_B2(n+2)
329 # define NDV_B6(n) NDV_B4(n), NDV_B4(n+1), NDV_B4(n+1), NDV_B4(n+2)
333 t_index_type num_set = 0;
335 flag_size = flag_size ^ ((flag_size ^
filledSize()) & *mask);
337 for (t_index_type i = 0; i < flag_size; i++)
339 num_set += BitsSetTable256[
m_buffer[i]];
344 for (t_index_type i = 0; i < size_mod_8; i++)
346 num_set +=
m_buffer[flag_size][i] ? 1 : 0;
361 for (t_index_type i = 0; i < size; i++)
370 for (t_index_type i = size - 1; !
isNaN(i); i--)
372 *(dst + i) = *(src + i);
376 void setFlag(
const t_index_type index,
const bool value)
384 const t_index_type byte_size =
memSize();
385 for (t_index_type i = 0; i < byte_size; i++)
393 const t_index_type byte_size =
memSize();
394 for (t_index_type i = 0; i < byte_size; i++)
400 const t_index_type byte_size =
memSize();
401 for (t_index_type i = 0; i < byte_size; i++)
407 const t_index_type byte_size =
memSize();
408 for (t_index_type i = 0; i < byte_size; i++)
414 const t_index_type byte_size =
memSize();
415 for (t_index_type i = 0; i < byte_size; i++)
#define bitset_idx(pos)
Definition BoolBuffer.hpp:39
#define bitmask(nbits)
Definition BoolBuffer.hpp:41
#define bitset_wrd(pos)
Definition BoolBuffer.hpp:38
#define lib_assert(expression, message)
Asserts some logic in the code. Disabled in non debug mode by default. Can be re-enabled in release u...
Definition LibAssert.h:70
A bitset that stores 8 bits (elements with only two possible values: 0 or 1, true or false,...
Definition BitFlag.hpp:68
Definition BitIterator.hpp:40
Definition BitReference.hpp:38
void createSpace(t_index_type location, t_index_type size)
Definition BoolBuffer.hpp:73
void inverseAndEquals(const BufferAllocator< bool, t_index_type > &buffer)
Definition BoolBuffer.hpp:390
sint04 compare(const BufferAllocator &allocator, t_index_type start, t_index_type end) const
Definition BoolBuffer.hpp:108
void setAllFromSource(const t_other_allocator &allocator, t_index_type offset, t_index_type other_offset, t_index_type size)
Definition BoolBuffer.hpp:247
void createSpace(t_index_type size)
Definition BoolBuffer.hpp:67
BitIterator begin()
Definition BoolBuffer.hpp:136
t_index_type m_filled_size
Definition BoolBuffer.hpp:420
void addIndex(t_index_type location)
Definition BoolBuffer.hpp:90
ConstBitIterator end() const
Definition BoolBuffer.hpp:157
sint04 compare(const BufferAllocator &allocator) const
Definition BoolBuffer.hpp:102
t_index_type numSet() const
Definition BoolBuffer.hpp:323
static void bitmove(BitIterator dst, BitIterator src, t_index_type size)
Definition BoolBuffer.hpp:353
t_index_type capacity() const
Definition BoolBuffer.hpp:149
BitIterator end()
Definition BoolBuffer.hpp:153
void allocationSizeCheck()
Definition BoolBuffer.hpp:253
void removeAllIndex(t_index_type start, t_index_type end)
Definition BoolBuffer.hpp:265
const ConstBitIterator begin() const
Definition BoolBuffer.hpp:140
void operator|=(const BufferAllocator< bool, t_index_type > &buffer)
Definition BoolBuffer.hpp:404
BufferAllocator()
Definition BoolBuffer.hpp:46
void setAll(const bool *src, t_index_type offset, t_index_type size)
Definition BoolBuffer.hpp:219
t_index_type filledSize() const
Definition BoolBuffer.hpp:278
BitReference get(t_index_type index)
Definition BoolBuffer.hpp:126
void swap(t_index_type index_a, t_index_type index_b)
Definition BoolBuffer.hpp:113
BufferAllocator(BufferAllocator &&allocator) noexcept
Definition BoolBuffer.hpp:52
void operator^=(const BufferAllocator< bool, t_index_type > &buffer)
Definition BoolBuffer.hpp:397
BufferAllocator & operator=(BufferAllocator &&value) noexcept
Definition BoolBuffer.hpp:294
void invert()
Definition BoolBuffer.hpp:382
BitIterator end(t_index_type index)
Definition BoolBuffer.hpp:161
void removeIndex(t_index_type location)
Definition BoolBuffer.hpp:96
void setFlag(const t_index_type index, const bool value)
Definition BoolBuffer.hpp:376
t_index_type m_allocated_size
Definition BoolBuffer.hpp:421
BitFlag * ptr()
Definition BoolBuffer.hpp:166
void addLast()
Definition BoolBuffer.hpp:78
bool get(t_index_type index) const
Definition BoolBuffer.hpp:131
t_index_type memSize() const
Definition BoolBuffer.hpp:175
t_index_type count(const bool &value) const
Definition BoolBuffer.hpp:282
void clear()
Definition BoolBuffer.hpp:117
BitIterator begin(t_index_type index) const
Definition BoolBuffer.hpp:144
~BufferAllocator()
Definition BoolBuffer.hpp:61
void resizeSpace(t_index_type new_size)
Definition BoolBuffer.hpp:302
BitFlag * m_buffer
Definition BoolBuffer.hpp:419
void setAll(const bool &object, t_index_type offset, t_index_type size)
Definition BoolBuffer.hpp:181
void setAll(const BufferAllocator &allocator, t_index_type offset, t_index_type other_offset, t_index_type size)
Definition BoolBuffer.hpp:228
void operator&=(const BufferAllocator< bool, t_index_type > &buffer)
Definition BoolBuffer.hpp:411
const BitFlag * ptr() const
Definition BoolBuffer.hpp:171
void setSize(t_index_type size)
Definition BoolBuffer.hpp:121
void removeLast()
Definition BoolBuffer.hpp:82
void addIndex()
Definition BoolBuffer.hpp:86
Definition Pointer.hpp:297
void createSpace(t_index_type size)
Definition MemoryManager.h:461
t_index_type m_filled_size
Definition MemoryManager.h:1294
t_type * end()
Definition MemoryManager.h:855
void allocationSizeCheck()
Definition MemoryManager.h:1120
constexpr t_index_type filledSize() const
Definition MemoryManager.h:1261
t_type & get(t_index_type index)
Definition MemoryManager.h:723
t_index_type m_allocated_size
Definition MemoryManager.h:1296
t_index_type memSize() const
Definition MemoryManager.h:758
t_type * begin()
Definition MemoryManager.h:775
void resizeSpace(t_index_type new_size)
Definition MemoryManager.h:914
t_type * m_buffer
Definition MemoryManager.h:1293
t_index_type count(const t_type &value) const
Definition MemoryManager.h:534
Definition BitIterator.hpp:173
int32_t sint04
-Defines an alias representing a 4 byte, signed integer. -Can represent exact integer values -2147483...
Definition BaseValues.hpp:76
uint8_t uint01
-Defines an alias representing a 1 byte, unsigned integer -Can represent exact integer values 0 throu...
Definition BaseValues.hpp:98
uint32_t uint04
-Defines an alias representing a 4 byte, unsigned integer -Can represent exact integer values 0 throu...
Definition BaseValues.hpp:120
constexpr t_to cast(const Angle< t_from > &value)
Definition Angle.h:514
constexpr bool isNaN(const t_type &value)
Query if 'value' is valid or invalid.
Definition BaseFunctions.hpp:200
constexpr t_type getMin(const t_type &left, const t_type &right)
Finds the minimum of the given arguments based on the < operator.
Definition BaseFunctions.hpp:67
Definition BaseValues.hpp:272