ae2f_docs
BitVec.h File Reference
#include "./Cast.h"
#include "./Cmp.h"
#include <stdint.h>

Go to the source code of this file.

Macros

#define ae2f_BitToByteCount(bitc)
 Calculate proper byte size with bit count.
#define _ae2f_BitVecFilled(len, vec_t)
 Generates the vector filled in 1.
#define ae2f_BitVecFilled(len)
 Generates the vector filled in 1.
#define _ae2f_BitVecGetRanged(vector, start, end, vec_t)
 Gets the bits of [vector] between index of [start] and [end].
#define ae2f_BitVecGetRanged(vector, start, end)
 Gets the bits of [vector] between index of [start] and [end].
It will normalise the values of [start] and [end] by switching them.
#define ae2f_BitVecGet(vector, idx)
 Gets a bit of [vector] from index of [idx].
#define _ae2f_BitVecSetRanged(vector, start, end, val, vec_t)
 Sets the bits of [vector] from index of [start] and [end] by [val].
#define ae2f_BitVecSetRanged(vector, start, end, val)
 Sets the bits of [vector] from index of [start] and [end] by [val].
It will normalise the values of [start] and [end] by switching them.
#define ae2f_BitVecSet(vector, idx, val)
 Sets a bit of [vector] from index of [idx] by [val].
#define ae2f_BitVecSizeDefName(t)
 Gets the vec's last index where the flag set to 1.
#define ae2f_BitVecSizeDef(t)
 Gets the vec's last index where the flag set to 1.
#define ae2f_BitVecFndOneDefName(t)
 Gets the vector that vec's first flag set to 1.
#define ae2f_BitVecFndOneDef(t)
 Gets the vector that vec's first flag set to 1.

Typedefs

typedef uint8_t ae2f_BitVecI_t
 The pre-defined index type for Bit vector.

Detailed Description

Author
ae2f
Date
2025-02-01

Definition in file BitVec.h.

Macro Definition Documentation

◆ _ae2f_BitVecFilled

#define _ae2f_BitVecFilled ( len,
vec_t )
Value:
vec_t, \
(sizeof(vec_t) << 3) == (len) \
? ae2f_static_cast(vec_t, -1) \
: (ae2f_static_cast(vec_t, ae2f_static_cast(vec_t, 1) << (len)) - \
1))
#define ae2f_static_cast(t, v)
Definition Cast.h:42

Generates the vector filled in 1.

Parameters
lenThe length of the filled vector.
Template Parameters
vec_tThe integer data type.

Definition at line 30 of file BitVec.h.

◆ _ae2f_BitVecGetRanged

#define _ae2f_BitVecGetRanged ( vector,
start,
end,
vec_t )
Value:
(((vector) >> (start)) & _ae2f_BitVecFilled((end) - (start), vec_t))
#define _ae2f_BitVecFilled(len, vec_t)
Generates the vector filled in 1.
Definition BitVec.h:30

Gets the bits of [vector] between index of [start] and [end].

Parameters
vector{vec_t} The target for operation.
start{ae2f_Macro_BitVecI_t} The starting index.
end{ae2f_Macro_BitVecI_t} The ending index.
Template Parameters
vec_tThe integer data type.
Warning
[start] greater than [end] may cause undefined behaviour.

Definition at line 50 of file BitVec.h.

◆ _ae2f_BitVecSetRanged

#define _ae2f_BitVecSetRanged ( vector,
start,
end,
val,
vec_t )
Value:
((vector) & (~((_ae2f_BitVecFilled((end) - (start), vec_t)) << start)) | \
((val) << start))

Sets the bits of [vector] from index of [start] and [end] by [val].

Parameters
vector{vec_t} The target for operation.
start{ae2f_Macro_BitVecI_t} The starting index.
end{ae2f_Macro_BitVecI_t} The ending index.
val{vec_t} The value to set.
Template Parameters
vec_tThe integer data type.
Warning
[start] greater than [end] may cause undefined behaviour.

Definition at line 80 of file BitVec.h.

◆ ae2f_BitToByteCount

#define ae2f_BitToByteCount ( bitc)
Value:
(((bitc) >> 3) + !!((bitc) & 7))

Calculate proper byte size with bit count.

Definition at line 21 of file BitVec.h.

◆ ae2f_BitVecFilled

#define ae2f_BitVecFilled ( len)
Value:
_ae2f_BitVecFilled(len, size_t)

Generates the vector filled in 1.

Parameters
len{ae2f_Macro_BitVecI_t} The length of the filled vector.

Definition at line 40 of file BitVec.h.

◆ ae2f_BitVecFndOneDef

#define ae2f_BitVecFndOneDef ( t)
Value:
constextendedfun t ae2f_BitVecFndOneDefName(t)(const t vec) noexcept { \
t i = 1; \
for (; i; i <<= 1) { \
if (vec & i) \
break; \
} \
return i; \
}
#define ae2f_BitVecFndOneDefName(t)
Gets the vector that vec's first flag set to 1.
Definition BitVec.h:127
#define constextendedfun
Definition Constexpr.hpp:42

Gets the vector that vec's first flag set to 1.

Template Parameters
tMust be an integer type
Parameters
vec{t}

Definition at line 133 of file BitVec.h.

◆ ae2f_BitVecFndOneDefName

#define ae2f_BitVecFndOneDefName ( t)
Value:
ae2f_BitVecFndOne_##t##_func

Gets the vector that vec's first flag set to 1.

Template Parameters
tMust be an integer type
Parameters
vec{t}

Definition at line 127 of file BitVec.h.

◆ ae2f_BitVecGet

#define ae2f_BitVecGet ( vector,
idx )
Value:
ae2f_BitVecGetRanged(vector, idx, (idx) + 1)
#define ae2f_BitVecGetRanged(vector, start, end)
Gets the bits of [vector] between index of [start] and [end]. It will normalise the values of [start...
Definition BitVec.h:60
VkPipelineLayoutCreateInfo ae2f_err_t ae2fVK_AnnSlp *const const ae2fVK_eAnnSlpPipeLayouts idx

Gets a bit of [vector] from index of [idx].

Parameters
vector{size_t} The target for operation.
idx{ae2f_Macro_BitVecI_t} The wanted index for searching.
See also
ae2f_Macro_BitVec_GetRanged

Definition at line 69 of file BitVec.h.

◆ ae2f_BitVecGetRanged

#define ae2f_BitVecGetRanged ( vector,
start,
end )
Value:
_ae2f_BitVecGetRanged(vector, ae2f_CmpGetLs(start, end), \
ae2f_CmpGetGt(start, end), size_t)
#define _ae2f_BitVecGetRanged(vector, start, end, vec_t)
Gets the bits of [vector] between index of [start] and [end].
Definition BitVec.h:50
#define ae2f_CmpGetGt(a, b)
Definition Cmp.h:20
#define ae2f_CmpGetLs(a, b)
Definition Cmp.h:26

Gets the bits of [vector] between index of [start] and [end].
It will normalise the values of [start] and [end] by switching them.

Parameters
vector{size_t} The target for operation.
start{ae2f_Macro_BitVecI_t} The starting index.
end{ae2f_Macro_BitVecI_t} The ending index.
See also
_ae2f_Macro_BitVec_GetRanged

Definition at line 60 of file BitVec.h.

◆ ae2f_BitVecSet

#define ae2f_BitVecSet ( vector,
idx,
val )
Value:
ae2f_BitVecSetRanged(vector, idx, (idx) + 1, val)
#define ae2f_BitVecSetRanged(vector, start, end, val)
Sets the bits of [vector] from index of [start] and [end] by [val]. It will normalise the values of ...
Definition BitVec.h:91

Sets a bit of [vector] from index of [idx] by [val].

Parameters
vector{size_t} The target for operation.
idx{bool} The wanted index for searching.
See also
ae2f_Macro_BitVec_GetRanged

Definition at line 101 of file BitVec.h.

◆ ae2f_BitVecSetRanged

#define ae2f_BitVecSetRanged ( vector,
start,
end,
val )
Value:
vector, ae2f_CmpGetLs(start, end), ae2f_CmpGetGt(start, end), \
(val) & ae2f_BitVecFilled(ae2f_CmpDiff(start, end)), size_t)
#define ae2f_BitVecFilled(len)
Generates the vector filled in 1.
Definition BitVec.h:40
#define _ae2f_BitVecSetRanged(vector, start, end, val, vec_t)
Sets the bits of [vector] from index of [start] and [end] by [val].
Definition BitVec.h:80
#define ae2f_CmpDiff(a, b)
Definition Cmp.h:30

Sets the bits of [vector] from index of [start] and [end] by [val].
It will normalise the values of [start] and [end] by switching them.

Parameters
vector{vec_t} The target for operation.
start{ae2f_Macro_BitVecI_t} The starting index.
end{ae2f_Macro_BitVecI_t} The ending index.
val{size_t} The value to set.

Definition at line 91 of file BitVec.h.

◆ ae2f_BitVecSizeDef

#define ae2f_BitVecSizeDef ( t)
Value:
for (i = (sizeof(t) << 3); i; i--) \
if (ae2f_BitVecGet(vec, i - 1)) \
break; \
return i == (sizeof(t) << 3) ? 0 : i; \
}
#define ae2f_BitVecGet(vector, idx)
Gets a bit of [vector] from index of [idx].
Definition BitVec.h:69
#define ae2f_BitVecSizeDefName(t)
Gets the vec's last index where the flag set to 1.
Definition BitVec.h:108
#define uint8_t

Gets the vec's last index where the flag set to 1.

Template Parameters
tMust be an integer type
Parameters
vec{t}

Definition at line 114 of file BitVec.h.

◆ ae2f_BitVecSizeDefName

#define ae2f_BitVecSizeDefName ( t)
Value:
ae2f_BitVecSize_##t##_func

Gets the vec's last index where the flag set to 1.

Template Parameters
tMust be an integer type
Parameters
vec{t}

Definition at line 108 of file BitVec.h.

Typedef Documentation

◆ ae2f_BitVecI_t

The pre-defined index type for Bit vector.

Definition at line 25 of file BitVec.h.