Is there some "standard" container (STL, boost) which can present multiple memory chunks as single continuous one? I need to work with some data with following conditions:
So, after getting all the data, I have a list of memory chunks. And I need to apply some STL algorithms (search, copy, etc.) to data as a whole. There is a solution to write container to hold info about these chunks + forward iterator which is able to "jump" from one chunk to another.
But problem seems rather general, so I hope that there is some well-known answer which I'm missing. Thanks in advance.
The memory is provided to you, you say. That sounds like you don't want to copy it. No problem, the STL philosophy is quite flexible. You don't actually need a container; they're just there for memory management and that's already taken care of.
What you do need is an iterator. There's no standard one; you'll have to write one yourself. There are just too many slight variations to provide a standard solution for this. But don't worry, it's fairly easy. You get the necessary typedefs if you inherit from std::iterator<value_type>
, so you need to only write operator*
(straightforward) and operator++
/operator--
/operator+
/operator-
(which understand the chunks).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With