?
=?iso-8859-1?B?Tm9yZGz2dw==?=
Hey there, C++ Coders.
Does anyone know of a C++ (template) (vector) container that packs its
elements based on their relative minimum and maximum value (offset and
span) and (minimum) stride.
Example:
The pointers [ 0x00, 0x04, 0x12, 0x20 ] when packed should be stored
internally in the template<T> container as
T min: 0
T stride: 4
packed values: [ 0, 1, 3, 5 ] (in this case be stored in a
std::vector<uint8_t>)
I think such a container would be especially suitable for storing
"small" arrays of pointers. Especially on a 64-bit architecture where
a pointer takes 8 bytes, this would reduce memory usage by up to 8
times. This example, of course, holds only for the ideal case where
the array has exactly 256 number of elements and these elements are
all aligment on a linear grid with equal spacing (stride).
This template would also work great for elements having integer types.
Many thanks in advance,
Nordlöw
Does anyone know of a C++ (template) (vector) container that packs its
elements based on their relative minimum and maximum value (offset and
span) and (minimum) stride.
Example:
The pointers [ 0x00, 0x04, 0x12, 0x20 ] when packed should be stored
internally in the template<T> container as
T min: 0
T stride: 4
packed values: [ 0, 1, 3, 5 ] (in this case be stored in a
std::vector<uint8_t>)
I think such a container would be especially suitable for storing
"small" arrays of pointers. Especially on a 64-bit architecture where
a pointer takes 8 bytes, this would reduce memory usage by up to 8
times. This example, of course, holds only for the ideal case where
the array has exactly 256 number of elements and these elements are
all aligment on a linear grid with equal spacing (stride).
This template would also work great for elements having integer types.
Many thanks in advance,
Nordlöw