#include <iostream>
#include <vector>
#include <cassert>
using namespace std;
static
{
auto prev = *en_n;
if (prev > 0)
prev = 0;
for ( ;en_n.
valid(); ++en_n)
{
auto curr = *en_n;
for (auto i = prev; i < curr; ++i)
cout << i << ": NULL" << endl;
bool v = bv_v.
test(curr);
cout << curr << ": " << (v ? "true" : "false") << endl;
prev = curr + 1;
}
cout << endl;
}
static
{
int v = 0;
for (unsigned i = 0; i < 10; ++i)
{
assert(v == v1); (void) v1;
v += 1;
if (v > 1)
v = -1;
}
}
static
{
{
for (unsigned i = 0; i < 13; i+=3)
{
if (i & 1)
{
iit_v = i;
}
iit_n = i;
}
}
}
static
{
int v = 0;
for (unsigned i = 0; i < 10; ++i)
{
v += 1;
if (v > 1)
v = -1;
}
}
static
{
cout << "Input vector:" << endl;
cout << "Inverted vector:" << endl;
}
static
{
bool b = bv_v_t.
equal(bv_v2);
assert(b);
b = bv_null_t.
equal(bv_null2);
assert(b);
cout << "AND vector:" << endl;
}
static
{
bm::or_kleene(bv_v_t, bv_null_t, bv_v2, bv_null2, bv_v1, bv_null1);
bool b = bv_v_t.
equal(bv_v2);
assert(b);
b = bv_null_t.
equal(bv_null2);
assert(b);
cout << "OR vector:" << endl;
}
{
try
{
cout << endl << "3VL Set values:" << endl << endl;
cout << endl << "3VL Invert vector:" << endl << endl;
cout << endl << "3VL AND:" << endl << endl;
cout << endl << "3VL OR:" << endl << endl;
}
catch(std::exception& ex)
{
std::cerr << ex.what() << std::endl;
}
return 0;
}
Three-valued logic (3VL) operations.
Compressed bit-vector bvector<> container, set algebraic methods, traversal iterators.
#define BM_DECLARE_TEMP_BLOCK(x)
pre-processor un-defines to avoid global space pollution (internal)
static void Set3VL_ValueDemo2()
Faster way to initialize Kleene bit-vectors via bulk_insert_iterator.
static void Set3VL_ORDemo()
Demo for 3-value logic (Kleene) OR.
static void Set3VL_AndDemo()
Demo for 3-value logic (Kleene) AND.
static void Set3VL_ValueDemo()
This demo shows how to use bm::set_value_kleene and bm::get_value_kleene functions to set values into...
static void PrintKleeneVector(const bm::bvector<> &bv_v, const bm::bvector<> &bv_null)
Print 3-value vector.
static void GenerateDemoVector(bm::bvector<> &bv_v, bm::bvector<> &bv_null)
Generate Kleene vector (as two bit-vectors)
static void Set3VL_InvertDemo()
Demo for 3-value logic (Kleene) NOT.
Output iterator iterator designed to set "ON" bits based on input sequence of integers.
Constant iterator designed to enumerate "ON" bits.
bool valid() const BMNOEXCEPT
Checks if iterator is still valid.
Bitvector Bit-vector container with runtime compression of bits.
bool test(size_type n) const BMNOEXCEPT
returns true if bit n is set and false is bit n is 0.
bool equal(const bvector< Alloc > &bvect) const BMNOEXCEPT
Equal comparison with an agr bit-vector.
void optimize(bm::word_t *temp_block=0, optmode opt_mode=opt_compress, statistics *stat=0)
Optimize memory bitvector's memory allocation.
insert_iterator inserter()
enumerator first() const
Returns enumerator pointing on the first non-zero bit.
void invert_kleene(BV &bv_value, const BV &bv_null)
Kleene NEG operation.
void init_kleene(BV &bv_value, const BV &bv_null)
Initialized the value bit-vector so that it always returns 0 (false) for the unknown.
void and_kleene(BV &bv_value1, BV &bv_null1, const BV &bv_value2, const BV &bv_null2)
Kleene AND(vect1, vect2) (vect1 &= vect2) 0 AND Unk = 0 (known)
void set_value_kleene(BV &bv_value, BV &bv_null, typename BV::size_type idx, int val)
Set Kleene logic value based on value and known vectors.
int get_value_kleene(const BV &bv_value, const BV &bv_null, typename BV::size_type idx) BMNOEXCEPT
Return Kleene logic value based on value and known vectors.
void or_kleene(BV &bv_value1, BV &bv_null1, const BV &bv_value2, const BV &bv_null2)
Kleene OR(vect1, vect2) (vect1 |= vect2) 1 OR Unk = 1 (known)