#include <iostream>
#include <vector>
using namespace std;
template<class SV>
{
std::cout << sv.size() << ": ";
for (unsigned i = 0; i < sv.size(); ++i)
{
if (show_nulls)
{
if (sv.is_null(i))
std::cout << "NULL, ";
else
{
typename SV::value_type v = sv.get(i);
std::cout << v << ", ";
}
}
else
{
typename SV::value_type v = sv.get(i);
std::cout << v << ", ";
}
}
std::cout << std::endl;
}
template<class SV>
{
using value_type = typename SV::value_type;
value_type v;
std::cout << sv.size() << ": ";
for (unsigned i = 0; i < sv.size(); ++i)
{
if (show_nulls)
{
if (!sv.try_get(i, v))
std::cout << "NULL, ";
else
std::cout << v << ", ";
}
else
{
v = sv.get(i);
std::cout << v << ", ";
}
}
std::cout << std::endl;
}
{
try
{
for (unsigned i = 0; i < 15; i+=3)
{
sv1[i] = i;
}
const unsigned char* buf = sv_lay.
buf();
size_t buf_size = sv_lay.
size();
vector<unsigned char> tmp_buf(buf_size);
::memcpy(&tmp_buf[0], buf, buf_size);
if (res != 0)
{
std::cerr << "De-Serialization error!" << std::endl;
return 1;
}
{
cerr << "Error! Please report a bug to BitMagic project support." << endl;
return 1;
}
if (!sv3.equal(sv1) )
{
std::cerr << "Error! Please report a bug to BitMagic project support." << std::endl;
return 1;
}
}
catch(std::exception& ex)
{
std::cerr << ex.what() << std::endl;
return 1;
}
return 0;
}
Compressed bit-vector bvector<> container, set algebraic methods, traversal iterators.
#define BM_DECLARE_TEMP_BLOCK(x)
Sparse constainer sparse_vector<> for integer types using bit-transposition transform.
Compressed sparse container rsc_sparse_vector<> for integer types.
Serialization for sparse_vector<>
pre-processor un-defines to avoid global space pollution (internal)
void load_from(const sparse_vector_type &sv_src)
Load compressed vector from a sparse vector (with NULLs)
void load_to(sparse_vector_type &sv) const
Exort compressed vector to a sparse vector (with NULLs)
void optimize(bm::word_t *temp_block=0, typename bvector_type::optmode opt_mode=bvector_type::opt_compress, statistics *stat=0)
run memory optimization for all vector slices
bool equal(const rsc_sparse_vector< Val, SV > &csv) const BMNOEXCEPT
check if another vector has the same content
succinct sparse vector with runtime compression using bit-slicing / transposition method
@ use_null
support "non-assigned" or "NULL" logic
void sparse_vector_serialize(const SV &sv, sparse_vector_serial_layout< SV > &sv_layout, bm::word_t *temp_block=0)
Serialize sparse vector into a memory buffer(s) structure.
int sparse_vector_deserialize(SV &sv, const unsigned char *buf, bm::word_t *temp_block=0)
Deserialize sparse vector.
void print_svector2(const SV &sv, bool show_nulls=false)
Prints succinct vector using try_get() random access method.
void print_svector(const SV &sv, bool show_nulls=false)
Prints the vector using is_null() and get() Please note, that random access is not the fastest,...
bm::sparse_vector< unsigned, bm::bvector<> > sparse_vector_u32
bm::rsc_sparse_vector< unsigned, sparse_vector_u32 > rsc_sparse_vector_u32
layout class for serialization buffer structure
size_t size() const BMNOEXCEPT
return current serialized size
const unsigned char * buf() const BMNOEXCEPT
Return serialization buffer pointer.