Boost logo

Boost :

Subject: Re: [boost] tuple_vector (was poly_collection)
From: Adam Wulkiewicz (adam.wulkiewicz_at_[hidden])
Date: 2014-08-24 07:29:37


Ion Gaztañaga wrote:
> An interesting addition to Boost.Container? ;-)

Some time ago I tested a container which should also improve the
cacheing, depending on the access pattern.
The key point is to separate the hot and cold data so its purpose is
slightly different than poly_collection but the idea is similar, to
group the same objects together.
The idea is to transform a vector of tuples into a tuple of vectors and
store tuple's components in separated containers, e.g.:

std::vector<std::tuple<T1, T2>> -> std::tuple<std::vector<T1>,
std::vector<T2>>

The usage should be as close to std::vector as possible, so e.g.:

|tuple_vector<std::tuple<T1, T2, T3, ...>> v;
v.resize(count);

for (int i = 0; i < count; ++i)
{
     T1 t = std::get<0>(v[i]);
     std::get<0>(v[i]) = ...;
}|

A thing worth noticing is that the tuple_vector's reference type is a
tuple of references:

std::tuple<T1&, T2&>

The iterator could either store a tuple of iterators of underlying
vectors or a ptr to tuple_vector and index.

If you wanted to check it out: https://github.com/awulkiew/test-tuple_vector
The prototype requires C++11 but such container could be implemented in
C++98 as well.

Regards,
Adam


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk