10 #ifndef K_API_BIT_ARRAY_H
11 #define K_API_BIT_ARRAY_H
14 #include <kApi/Data/kBitArray.x.h>
53 return xkBitArray_Reallocate(array, length,
kFALSE);
68 return xkBitArray_Reallocate(array, length,
kTRUE);
92 kSize wordCount = xkBitArray_WordCount(array);
95 for (
kSize i = 0; i < wordCount; ++i)
97 obj->buffer[i] = wordValue;
118 kSize wordIndex = index >> kBIT_ARRAY_WORD_WIDTH_SHIFT;
119 kSize bitOffset = index & kBIT_ARRAY_BIT_OFFSET_MASK;
121 if (value) obj->buffer[wordIndex] |= (1llu << bitOffset);
122 else obj->buffer[wordIndex] &= ~(1llu << bitOffset);
207 kAssert(index < obj->bitLength);
209 kSize wordIndex = index >> kBIT_ARRAY_WORD_WIDTH_SHIFT;
210 kSize bitOffset = index & kBIT_ARRAY_BIT_OFFSET_MASK;
212 return (obj->buffer[wordIndex] >> bitOffset) & 0x1;
226 return obj->bitLength;
kStatus kBitArray_Item(kBitArray array, kSize index, kBool *value)
Gets the value of an item.
Definition: kBitArray.h:136
Represents a 64-bit unsigned integer.
k64u kBitArray_FalseCount(kBitArray array)
Counts the number of bits in the array that are set to kFALSE.
Definition: kBitArray.h:245
Represents an unsigned integer that can store a pointer address.
Abstract base class for memory allocator types.
#define kInlineFx(TYPE)
Inline method declaration helper.
Definition: kApiDef.h:26
kBool kBitArray_At(kBitArray array, kSize index)
Returns the specified item in the array.
Definition: kBitArray.h:203
kStatus kBitArray_Xor(kBitArray array, kBitArray other)
Performs bitwise-xor over all bits from the specified arrays.
kStatus kBitArray_Assign(kBitArray array, kBitArray source)
Copies the source array.
#define kTRUE
Boolean true.
Definition: kApiDef.h:356
kStatus kBitArray_Or(kBitArray array, kBitArray other)
Performs bitwise-or over all bits from the specified arrays.
Represents a 1D array of bits.
#define kObj(TypeName_T, T_object)
Declares a local "obj" (this-pointer) variable and initializes it from a type-checked object handle...
Definition: kApiDef.h:3383
kStatus kBitArray_SetAll(kBitArray array, kBool value)
Sets all array elements to the specified value.
Definition: kBitArray.h:89
kStatus kBitArray_Allocate(kBitArray array, kSize length)
Reallocates the array item buffer.
Definition: kBitArray.h:51
Core Zen type declarations.
kSize kBitArray_Length(kBitArray array)
Returns the array length, in bits.
Definition: kBitArray.h:222
#define kCheckArgs(EXPRESSION)
Executes a return statement if the given expression is not kTRUE.
Definition: kApiDef.h:584
kStatus kBitArray_Resize(kBitArray array, kSize length)
Resizes the internal array item buffer.
Definition: kBitArray.h:66
kStatus kBitArray_Construct(kBitArray *array, kSize length, kAlloc allocator)
Constructs a kBitArray object.
#define kAssert(EXPRESSION)
Aborts execution if EXPRESSION is kFALSE.
Definition: kApiDef.h:751
kStatus kBitArray_And(kBitArray array, kBitArray other)
Performs bitwise-and over all bits from the specified arrays.
#define kOK
Operation successful.
Definition: kApiDef.h:515
Represents an error code.
#define k64U_MAX
k64u maximum value.
Definition: kApiDef.h:91
k64u kBitArray_TrueCount(kBitArray array)
Counts the number of bits in the array that are set to kTRUE.
kStatus kBitArray_SetItem(kBitArray array, kSize index, kBool value)
Sets the value of the specified item.
Definition: kBitArray.h:112
Represents a boolean value.
#define kFALSE
Boolean false.
Definition: kApiDef.h:355
kStatus kBitArray_Not(kBitArray array)
Inverts all bits.