#include <iostream>
#include <string>
#include <vector>
#include "bm.h"
#include "bmstrsparsevec.h"
#include "bmundef.h"
using namespace std;
typedef bm::bvector<> bvector_type;
typedef bm::str_sparse_vector<char, bvector_type, 32> str_sv_type;
int main(void)
{
try
{
str_sv_type str_sv;
const char* s0 = "asz1234";
std::string str1 = "aqw1234";
std::string str3 = "54z";
std::string str00 = "00";
str_sv.set(0, s0); str_sv.push_back(str1);
str_sv.assign(3, str3);
std::cout << "sv size()=" << str_sv.size() << endl;
str_sv.insert(0, str00);
str_sv.erase(0);
{
BM_DECLARE_TEMP_BLOCK(tb)
str_sv.optimize(tb);
}
for (str_sv_type::size_type i = 0; i < str_sv.size(); ++i)
{
const char* s = str_sv[i];
cout << i << ":" << s << endl;
} cout << "----" << endl;
{
str_sv_type::const_iterator it = str_sv.begin();
str_sv_type::const_iterator it_end = str_sv.end();
for (; it != it_end; ++it)
{
cout << *it << endl;
} }
}
catch(std::exception& ex)
{
std::cerr << ex.what() << std::endl;
return 1;
}
return 0;
}