Example of how to use bm::sparse_vector<> template class to set values
- See also
- bm::sparse_vector<>::import
-
bm::sparse_vector<>::at
-
bm::sparse_vector<>::optimize
-
bm::sparse_vector<>::size
#include <iostream>
using namespace std;
{
try
{
unsigned arr[3] = {1,2,3};
{
}
cout <<
"sv1.size() = " << sv1.
size() << endl;
cout << "sv[]:";
for (
unsigned i = 0; i < sv1.
size(); ++i)
{
cout << sv1.
at(i) <<
",";
}
cout << endl;
unsigned arr2[5] = {10, 20, 30, 40, 50};
cout <<
"sv1.size() = " << sv1.
size() << endl;
cout << "sv[]:";
for (
unsigned i = 0; i < sv1.
size(); ++i)
{
cout << sv1.
at(i) <<
",";
}
cout << endl;
}
catch(std::exception& ex)
{
std::cerr << ex.what() << std::endl;
return 1;
}
return 0;
}
void optimize(bm::word_t *temp_block=0, typename bvector_type::optmode opt_mode=bvector_type::opt_compress, typename sparse_vector< Val, BV >::statistics *stat=0)
run memory optimization for all vector plains
void import(const value_type *arr, size_type arr_size, size_type offset=0, bool set_not_null=true)
Import list of elements from a C-style array.