Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > getting a giant bitmap into a container

Reply
Thread Tools

getting a giant bitmap into a container

 
 
440gtx@email.com
Guest
Posts: n/a
 
      02-13-2010
I would like to represent used/free clusters on a disk drive in a
standard container. Pardon platform specifics, but the cluster data
comes from a POD header followed by the cluster bitmap as defined by
FSCTL_GET_VOLUME_BITMAP. One choice is to create an empty vector
<bool> and manually copy the bits. Since there can be billions of
clusters, this is very inefficient in terms of needing double the
memory and then the time to copy billions of bits:

vector <bool> bitmap;
VOLUME_BITMAP_BUFFER *out = (VOLUME_BITMAP_BUFFER *)malloc(out_len);

…call ioctl…

bitmap.resize(out->BitmapSize.QuadPart);

for (vector <bool>::size_type i = 0; i < bitmap.size(); ++i)
bitmap[i] = (out->Buffer[i/8] >> (i % ) & 1;

Are there more appropriate ways?
 
Reply With Quote
 
 
 
 
Öö Tiib
Guest
Posts: n/a
 
      02-13-2010
On Feb 13, 4:17*am, (E-Mail Removed) wrote:
> I would like to represent used/free clusters on a disk drive in a
> standard container. Pardon platform specifics, but the cluster data
> comes from a POD header followed by the cluster bitmap as defined by
> FSCTL_GET_VOLUME_BITMAP. One choice is to create an empty vector
> <bool> and manually copy the bits. Since there can be billions of
> clusters, this is very inefficient in terms of needing double the
> memory and then the time to copy billions of bits:


You need double memory each time when you copy something to something
else so if this is concern then do not copy and do not convert. When
unsure then measure.
>
> vector <bool> bitmap;
> VOLUME_BITMAP_BUFFER *out * = (VOLUME_BITMAP_BUFFER *)malloc(out_len);
>
> …call ioctl…
>
> bitmap.resize(out->BitmapSize.QuadPart);
>
> for (vector <bool>::size_type i = 0; i < bitmap.size(); ++i)
> * * bitmap[i] = (out->Buffer[i/8] >> (i % ) & 1;
>
> Are there more appropriate ways?


boost::dynamic_bitset or vector of std::bitset are perhaps better
containers for bits than std::vector<bool>.
 
Reply With Quote
 
 
 
 
440gtx@email.com
Guest
Posts: n/a
 
      02-14-2010
> boost::dynamic_bitset or vector of std::bitset are perhaps
> better containers for bits than std::vector<bool>.


Better in what way? Do they solve the performance and memory usage
issue of needing to copy a billion bits one by one from one memory
region to another?
 
Reply With Quote
 
Öö Tiib
Guest
Posts: n/a
 
      02-14-2010
On Feb 14, 5:39*am, (E-Mail Removed) wrote:
> > boost::dynamic_bitset or vector of std::bitset are perhaps
> > better containers for bits than std::vector<bool>.

>
> Better in what way? Do they solve the performance and memory usage
> issue of needing to copy a billion bits one by one from one memory
> region to another?


Better since bitset constructor takes at least value (unsigned long)
in, so your copying code does not look like ">(>%)8&":

unsigned char original;
std::bitset<8> copied( original );
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Help! How can I draw a bitmap only with BITMAP information! xqggz C++ 1 06-19-2007 03:07 PM
std::transform container => std::abs(container) Steven T. Hatton C++ 4 12-05-2004 07:10 AM
STL: container's values setup by another container Maitre Bart C++ 2 02-11-2004 12:11 AM
std::container::iterator vs std::container::pointer Vivi Orunitia C++ 11 02-04-2004 08:09 AM
Masked bitmap from bitmap Gandalf Python 0 01-29-2004 09:41 PM



Advertisments