Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
132 views
in Technique[技术] by (71.8m points)

c++ - Bitmagic: Where are the use-cases of bm::sparse_vector?

Just starting to use BitMagic and understand the intricacies of it.

When i run,

bm::bvector<> bv;
bm::sparse_vector<unsigned, bm::bvector<> > sv1 (bm::use_null);

bv.set_new_blocks_strat(bm::BM_GAP);  //  set DGAP compression mode ON

for (unsigned i = 0; i < 10000; i+= 533)
{
    bv.set_bit(i);
    sv1[i] = true;
}

cout << bv.calc_stat().memory_used << ", " << sv1.calc_stat().memory_used;

Returns

It seems that sparse vector occupies more space than the bvector. I want to store an integer list in this sparse vector basically and I don't understand why the sparse_vector takes more space than the bvector.

Any help on this will be appreciated. Thanks.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...