#include <assert.h>
#include <stddef.h>
#include "base/intutils.h"
#include "debug/utils.h"
Go to the source code of this file.
Namespaces | |
namespace | base |
Enumerations | |
enum | bit_t { ZERO = 0, ONE = 1 } |
Type to ensure correct arguments. More... | |
Functions | |
static uint32_t | base_high16 (uint32_t x) |
High 16 bits of an int. | |
static uint32_t | base_low16 (uint32_t x) |
Low 16 bits of an int. | |
static uint32_t | base_countBits (uint32_t x) |
Bit counting function. | |
static uint32_t | base_countBitsN (const uint32_t *bitString, size_t n) |
Bit counting function. | |
static uint32_t | base_fmsb32 (uint32_t w) |
Find most significant set bit (32-bit version). | |
static void | base_orBits (uint32_t *bits1, const uint32_t *bits2, size_t n) |
Bitwise or ;. | |
static void | base_andBits (uint32_t *bits1, const uint32_t *bits2, size_t n) |
Bitwise and ;. | |
static void | base_xorBits (uint32_t *bits1, const uint32_t *bits2, size_t n) |
Bitwise xor ;. | |
static void | base_resetBits (uint32_t *bits, size_t n) |
Reset of bits (to 0). | |
static void | base_setBits (uint32_t *bits, size_t n) |
Set bits to 1. | |
static void | base_setBitsWith (uint32_t *bits, size_t n, uint32_t value) |
Set bits to something. | |
static void | base_xorBitsWith (uint32_t *bits, size_t n, uint32_t mask) |
Apply a xor mask to a bitstring. | |
static void | base_negBits (uint32_t *bits, size_t n) |
Negate a bitstring. | |
static void | base_resetBits2 (uint32_t *bits1, uint32_t *bits2, size_t n) |
Reset of 2 strings of bits (to 0). | |
static void | base_setBits2 (uint32_t *bits1, uint32_t *bits2, size_t n) |
Set 2 strings of bits (to 1). | |
static BOOL | base_areBitsReset (const uint32_t *bits, size_t n) |
Equality test to 0. | |
static BOOL | base_areIBitsReset (const int32_t *bits, size_t n) |
Wrapper to base_areBitsResets. | |
static BOOL | base_areBitsEqual (const uint32_t *bits1, const uint32_t *bits2, size_t n) |
Comparison of bits. | |
static void | base_copyBits (uint32_t *bits1, const uint32_t *bits2, size_t n) |
Copy of bits. | |
static void | base_setOneBit (uint32_t *bits, size_t i) |
Set bit to 1 at position i in a table of bits. | |
static void | base_addOneBit (uint32_t *bits, size_t i, bit_t bit) |
Add a bit at position i in a table of bits. | |
static void | base_assignOneBit (uint32_t *bits, size_t i, bit_t bit) |
Assign a bit at position i in a table of bits. | |
static void | base_andWithOneBit (uint32_t *bits, size_t i, bit_t bit) |
"and" operation with a bit at position i in a table of bits. | |
static void | base_resetOneBit (uint32_t *bits, size_t i) |
Reset bit to 0 at position i in a table of bits. | |
static void | base_subOneBit (uint32_t *bits, size_t i, bit_t bit) |
Substract a bit at position i in a table of bits. | |
static void | base_toggleOneBit (uint32_t *bits, size_t i) |
Toggle bit at position i in a table of bits. | |
static void | base_xorOneBit (uint32_t *bits, size_t i, bit_t bit) |
Xor a bit at position i in a table of bits. | |
static bit_t | base_getOneBit (const uint32_t *bits, size_t i) |
Test for a set bit in a bit-string. | |
static uint32_t | base_readOneBit (const uint32_t *bits, size_t i) |
Test for a set bit in a bit-string. | |
size_t | base_bits2indexTable (const uint32_t *bits, size_t n, cindex_t *table) |
Unpack a bit table to an index table. | |
static std::ostream & | operator<< (std::ostream &os, const BitString &bs) |
static std::ostream & | operator<< (std::ostream &os, const Bit &b) |
|
Type to ensure correct arguments.
|
|
Add a bit at position i in a table of bits.
|
|
Bitwise and ;.
|
|
"and" operation with a bit at position i in a table of bits.
|
|
Comparison of bits. Same comment as for resetBits: better to inline this simple code for small arrays, ie, bit arrays. Optimistic implementation.
|
|
Equality test to 0. Optimistic implementation: works best when == 0.
|
|
Wrapper to base_areBitsResets.
|
|
Assign a bit at position i in a table of bits.
|
|
Unpack a bit table to an index table. Useful when loading a DBM and computing initial redirection table. May be used for other things than DBMs, e.g., variables.
|
|
Copy of bits. memcpy could be used but for strings of bits of length 3-4 ints max, it is overkill. Conversely, for larger arrays, don't use this function.
|
|
Bit counting function.
|
|
Bit counting function.
|
|
Find most significant set bit (32-bit version). Function that scans a 32-bit word for the most significant set bit. For x86 this is implemented in assembler while for all other architectures it is implemented by setting all bits below the max significant set bit to 1 and counting the number of set bits.
|
|
Test for a set bit in a bit-string. Can be used in the following way. Instead of: if (base_getOneBit(a,n)) c++; c += base_getOneBit(a,n);
|
|
High 16 bits of an int. Useful in conjunction with hash values to store data.
|
|
Low 16 bits of an int. Useful in conjunction with hash values to store data.
|
|
Negate a bitstring.
|
|
Bitwise or ;.
|
|
Test for a set bit in a bit-string.
This function is not the same as
|
|
Reset of bits (to 0). memset could be used but for strings of bits of length 3-4 ints max, it is overkill. Conversely, for larger arrays, don't use this function.
|
|
Reset of 2 strings of bits (to 0). memset could be used but for strings of bits of length 3-4 ints max, it is overkill. Conversely, for larger arrays, don't use this function.
|
|
Reset bit to 0 at position i in a table of bits.
|
|
Set bits to 1. memset could be used but for strings of bits of length 3-4 ints max, it is overkill. Conversely, for larger arrays, don't use this function.
|
|
Set 2 strings of bits (to 1). memset could be used but for strings of bits of length 3-4 ints max, it is overkill. Conversely, for larger arrays, don't use this function.
|
|
Set bits to something. memset could be used but for strings of bits of length 3-4 ints max, it is overkill. Conversely, for larger arrays, don't use this function.
|
|
Set bit to 1 at position i in a table of bits.
|
|
Substract a bit at position i in a table of bits.
|
|
Toggle bit at position i in a table of bits.
|
|
Bitwise xor ;.
|
|
Apply a xor mask to a bitstring.
|
|
Xor a bit at position i in a table of bits.
|
|
|
|
|