#include <iostream>
#include <vector>
#include "bm.h"
#include "bmsparsevec.h"
#include "bmsparsevec_compr.h"
#include "bmundef.h"
using namespace std;
template<typename SV> void PrintSV(const SV& sv)
{
typename SV::const_iterator it = sv.begin();
typename SV::const_iterator it_end = sv.end();
for (; it != it_end; ++it)
{
if (it.is_null())
cout << "NULL";
else
cout << *it;
cout << ", ";
}
cout << endl;
}
typedef bm::sparse_vector<unsigned, bm::bvector<> > sparse_vector_u32;
typedef bm::rsc_sparse_vector<unsigned, sparse_vector_u32 > rsc_sparse_vector_u32;
int main(void)
{
try
{
rsc_sparse_vector_u32 csv1;
{
auto bit = csv1.get_back_inserter();
bit = 10;
bit = 11;
bit.add_null();
bit = 13;
bit = 14;
bit.add_null(2);
bit = 256;
bit.flush();
}
csv1.sync();
PrintSV(csv1);
{
rsc_sparse_vector_u32::const_iterator it =
csv1.get_const_iterator(2);
if (it.valid()) {
do
{
auto v = it.value();
if (it.is_null())
cout << "NULL";
else
cout << v;
cout << ", ";
} while (it.advance()); cout << endl;
it.go_to(3); cout << it.value() << endl; }
}
}
catch(std::exception& ex)
{
std::cerr << ex.what() << std::endl;
return 1;
}
return 0;
}