Is there any interest in a vector-like container for small integers class?

Hi, is there any interest in a vector-like container for small integers class? The idea is to bit pack small integers into (size_t) units of underlying type. -- VH

Václav Just want to understand the use cases and scope of applicability: Is it possible to achieve the same effect using std::vector with custom allocator? What would be the reference type of such a container? Alexander Churanov

Alexander Churanov wrote, On 15.12.2008 12:43:
Václav
Just want to understand the use cases and scope of applicability:
Is it possible to achieve the same effect using std::vector with custom allocator? I have not thought about this much. I guess it is possible.
What would be the reference type of such a container?
A proxy object just like for std::vector<bool> or such.
Alexander Churanov
-- VH

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 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.) Maybe a short synopsis of your class declaration with a few important methods might be useful. Cliff

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 <http://shell.sh.cvut.cz/~wilx/repos/packed_vector/packed_vector.hxx>.
Cliff
-- VH
participants (3)
-
Alexander Churanov
-
Cliff Green
-
Václav Haisman