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))
47 template<
class t_index_type>
62 std::swap(allocator.m_buffer,
m_buffer);
71 template<
bool t_managed>
77 template<
bool t_managed>
118 void swap(t_index_type index_a, t_index_type index_b)
136 bool get(t_index_type index)
const
186 void setAll(
const bool&
object, t_index_type offset, t_index_type size)
192 t_index_type last_word =
bitset_wrd(offset + size - 1);
194 t_index_type loffset =
bitset_idx(offset + size - 1);
196 if (first_word == last_word)
211 memset(
m_buffer + first_word + 1,
object ? 0xFF : 0, last_word - (first_word + 1));
219 for (
uint04 i = 0; i < size; i++)
223 template<
bool is_primitive>
224 void setAll(
const bool* src, t_index_type offset, t_index_type size)
226 for (t_index_type i = 0; i < size; i++)
228 get(i + offset) = src[i];
232 template<
bool is_primitive>
239 t_index_type new_other_offset =
bitset_wrd(other_offset);
240 memmove(
m_buffer + new_offset, allocator.
m_buffer + new_other_offset, new_size);
241 for (t_index_type i = 8 * new_size; i < size; i++)
243 get(i + offset) = allocator.
get(i + other_offset);
246 for (t_index_type i = 0; i < size; i++)
248 get(i + offset) = allocator.
get(i + other_offset);
251 template<
class t_other_allocator>
252 void setAllFromSource(
const t_other_allocator& allocator, t_index_type offset, t_index_type other_offset, t_index_type size)
254 for (t_index_type i = 0; i < size; i++)
255 get(i + offset) = allocator.get(i + other_offset);
257 template<
bool t_managed>
287 t_index_type
count(
const bool& value)
const
301 std::swap(value.m_buffer,
m_buffer);
309 t_index_type byte_size = new_size == 0 ? 0 :
bitset_wrd(new_size - 1) + 1;
330 static const t_index_type BitsSetTable256[256] =
332 # define NDV_B2(n) n, n+1, n+1, n+2
333 # define NDV_B4(n) NDV_B2(n), NDV_B2(n+1), NDV_B2(n+1), NDV_B2(n+2)
334 # define NDV_B6(n) NDV_B4(n), NDV_B4(n+1), NDV_B4(n+1), NDV_B4(n+2)
338 t_index_type num_set = 0;
340 flag_size = flag_size ^ ((flag_size ^
filledSize()) & *mask);
342 for (t_index_type i = 0; i < flag_size; i++)
344 num_set += BitsSetTable256[
m_buffer[i]];
349 for (t_index_type i = 0; i < size_mod_8; i++)
351 num_set +=
m_buffer[flag_size][i] ? 1 : 0;
366 for (t_index_type i = 0; i < size; i++)
375 for (t_index_type i = size - 1; !
IsInvalid(i); i--)
377 *(dst + i) = *(src + i);
381 void setFlag(
const t_index_type index,
const bool value)
389 const t_index_type byte_size =
memSize();
390 for (t_index_type i = 0; i < byte_size; i++)
398 const t_index_type byte_size =
memSize();
399 for (t_index_type i = 0; i < byte_size; i++)
405 const t_index_type byte_size =
memSize();
406 for (t_index_type i = 0; i < byte_size; i++)
412 const t_index_type byte_size =
memSize();
413 for (t_index_type i = 0; i < byte_size; i++)
419 const t_index_type byte_size =
memSize();
420 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)
Definition LibAssert.h:61
A bitset that stores 8 bits (elements with only two possible values: 0 or 1, true or false,...
Definition BitFlag.hpp:55
Simple bit iterator, typically used for parsing Buffer of bools in loops.
Definition BitIterator.hpp:45
A convenience class used with Buffers or Vectors of bools for referencing or acting on a single bit.
Definition BitReference.hpp:42
void createSpace(t_index_type location, t_index_type size)
Definition BoolBuffer.hpp:78
void inverseAndEquals(const BufferAllocator< bool, t_index_type > &buffer)
Definition BoolBuffer.hpp:395
sint04 compare(const BufferAllocator &allocator, t_index_type start, t_index_type end) const
Definition BoolBuffer.hpp:113
void setAllFromSource(const t_other_allocator &allocator, t_index_type offset, t_index_type other_offset, t_index_type size)
Definition BoolBuffer.hpp:252
void createSpace(t_index_type size)
Definition BoolBuffer.hpp:72
BitIterator begin()
Definition BoolBuffer.hpp:141
t_index_type m_filled_size
Definition BoolBuffer.hpp:425
void addIndex(t_index_type location)
Definition BoolBuffer.hpp:95
ConstBitIterator end() const
Definition BoolBuffer.hpp:162
sint04 compare(const BufferAllocator &allocator) const
Definition BoolBuffer.hpp:107
t_index_type numSet() const
Definition BoolBuffer.hpp:328
static void bitmove(BitIterator dst, BitIterator src, t_index_type size)
Definition BoolBuffer.hpp:358
t_index_type capacity() const
Definition BoolBuffer.hpp:154
BitIterator end()
Definition BoolBuffer.hpp:158
void allocationSizeCheck()
Definition BoolBuffer.hpp:258
void removeAllIndex(t_index_type start, t_index_type end)
Definition BoolBuffer.hpp:270
const ConstBitIterator begin() const
Definition BoolBuffer.hpp:145
void operator|=(const BufferAllocator< bool, t_index_type > &buffer)
Definition BoolBuffer.hpp:409
BufferAllocator()
Definition BoolBuffer.hpp:51
void setAll(const bool *src, t_index_type offset, t_index_type size)
Definition BoolBuffer.hpp:224
t_index_type filledSize() const
Definition BoolBuffer.hpp:283
BitReference get(t_index_type index)
Definition BoolBuffer.hpp:131
void swap(t_index_type index_a, t_index_type index_b)
Definition BoolBuffer.hpp:118
BufferAllocator(BufferAllocator &&allocator) noexcept
Definition BoolBuffer.hpp:57
void operator^=(const BufferAllocator< bool, t_index_type > &buffer)
Definition BoolBuffer.hpp:402
BufferAllocator & operator=(BufferAllocator &&value) noexcept
Definition BoolBuffer.hpp:299
void invert()
Definition BoolBuffer.hpp:387
BitIterator end(t_index_type index)
Definition BoolBuffer.hpp:166
void removeIndex(t_index_type location)
Definition BoolBuffer.hpp:101
void setFlag(const t_index_type index, const bool value)
Definition BoolBuffer.hpp:381
t_index_type m_allocated_size
Definition BoolBuffer.hpp:426
BitFlag * ptr()
Definition BoolBuffer.hpp:171
void addLast()
Definition BoolBuffer.hpp:83
bool get(t_index_type index) const
Definition BoolBuffer.hpp:136
t_index_type memSize() const
Definition BoolBuffer.hpp:180
t_index_type count(const bool &value) const
Definition BoolBuffer.hpp:287
void clear()
Definition BoolBuffer.hpp:122
BitIterator begin(t_index_type index) const
Definition BoolBuffer.hpp:149
~BufferAllocator()
Definition BoolBuffer.hpp:66
void resizeSpace(t_index_type new_size)
Definition BoolBuffer.hpp:307
BitFlag * m_buffer
Definition BoolBuffer.hpp:424
void setAll(const bool &object, t_index_type offset, t_index_type size)
Definition BoolBuffer.hpp:186
void setAll(const BufferAllocator &allocator, t_index_type offset, t_index_type other_offset, t_index_type size)
Definition BoolBuffer.hpp:233
void operator&=(const BufferAllocator< bool, t_index_type > &buffer)
Definition BoolBuffer.hpp:416
const BitFlag * ptr() const
Definition BoolBuffer.hpp:176
void setSize(t_index_type size)
Definition BoolBuffer.hpp:126
void removeLast()
Definition BoolBuffer.hpp:87
void addIndex()
Definition BoolBuffer.hpp:91
Specific logic for reserving memory for a Buffer. When managed, and more memory is needed memory is r...
Definition Pointer.hpp:311
void createSpace(t_index_type size)
Definition MemoryManager.h:400
t_index_type m_filled_size
Definition MemoryManager.h:1122
t_type * end()
Definition MemoryManager.h:713
void allocationSizeCheck()
Definition MemoryManager.h:958
constexpr t_index_type filledSize() const
Definition MemoryManager.h:1091
t_type & get(t_index_type index)
Definition MemoryManager.h:593
t_index_type m_allocated_size
Definition MemoryManager.h:1124
t_index_type memSize() const
Definition MemoryManager.h:626
t_type * begin()
Definition MemoryManager.h:641
void resizeSpace(t_index_type new_size)
Definition MemoryManager.h:766
t_type * m_buffer
Definition MemoryManager.h:1121
t_index_type count(const t_type &value) const
Definition MemoryManager.h:422
Simple bit iterator, typically used for parsing Buffer of bools in loops.
Definition BitIterator.hpp:181
int32_t sint04
-Defines an alias representing a 4 byte, signed integer. -Can represent exact integer values -2147483...
Definition BaseValues.hpp:64
constexpr bool IsInvalid(const t_type &value)
Query if 'value' is valid or invalid. Invalid values should return invalid if used for calculations o...
Definition BaseFunctions.hpp:170
uint8_t uint01
-Defines an alias representing a 1 byte, unsigned integer -Can represent exact integer values 0 throu...
Definition BaseValues.hpp:80
uint32_t uint04
-Defines an alias representing a 4 byte, unsigned integer -Can represent exact integer values 0 throu...
Definition BaseValues.hpp:96
constexpr t_to cast(const Angle< t_from > &value)
Definition Angle.h:375
constexpr t_type getMin(const t_type &left, const t_type &right)
Finds the minimum of the given arguments based on the < operator Author: Tyler Parke Date: 2017-11-05...
Definition BaseFunctions.hpp:56
Defines for a given type (such as sint04, fltp08, UUID, etc) a maximum, minimum, and reserved 'invali...
Definition BaseValues.hpp:233