Boost logo

Boost :

Subject: Re: [boost] Is there any interest in a vector-like container for small integers class?
From: Václav Haisman (v.haisman_at_[hidden])
Date: 2008-12-16 02:04:53

Cliff Green wrote, On 15.12.2008 18:41:
> Another query to your query - there's already dynamic_bitset, which
> allows bit packing to a dynamically sized buffer. What would be the main
> differences in your interface that would make it simpler / better than
> dynamic_bitset? (I can think of some immediately, but it would be good
Dynamic_bitset works with bits as boolean values. The idea of packed vector
is to store small integers like the range [-1;1] into 3 bits. The interface
would that of the std::vector. But it would certainly be possible to provide
bit fiddling operators too.

> to see your ideas.) Would there be any reason not to use dynamic_bitset
> as an implementation detail of your container? (I.e. your proposed
> container is mainly a wrapper for db.)
This is interesting idea. I have not thought about it before. It seems to me
that splitting of values bits to store them into dynamic_bitset so that they
can be recombined there again could harm performance unnecessarily.

> Maybe a short synopsis of your class declaration with a few important
> methods might be useful.
template <typename T, size_t Bits, typename StorageUnitType = size_t,
          typename Allocator = std::allocator<StorageUnitType> >
class packed_vector;

The public interface of the class is really that of the std::vector. I have
complete implementation of the idea at

> Cliff


Boost list run by bdawes at, gregod at, cpdaniel at, john at