1

I am developing an external memory data structure, and I need to put the data into a vector structure that automatically make swapping (maybe using LRU strategy) in order to keep a fixed RAM memory. I have tried the stxxl vector structure, but the problem is that it cannot store dynamic structures like std::vector. This doesn't work:

stxxl::vector< std::vector<T> >

Is there any library of external memory structure that could deal with these kind of elements?

osgx
  • 90,338
  • 53
  • 357
  • 513
darkloz
  • 11
  • 4

1 Answers1

6

Template parameter of stxxl::vector is the type of contained items, but std::vector is not a type, its missing it's template argument.

Try e.g. stxxl::vector<std::vector<int> >, or create an enclosing template class around stxxl::vector if you want to parametrize the itemtype of std::vector.

UPDATE: After some research, I found this on the Stxxl: FAQ's first page http://algo2.iti.kit.edu/stxxl/trunk/FAQ.html

Parameterizing STXXL Containers

STXXL container types like stxxl::vector can be parameterized only with a value type that is a POD (i. e. no virtual functions, no user-defined copy assignment/destructor, etc.) and does not contain references (including pointers) to internal memory. Usually, "complex" data types do not satisfy this requirements.

This is why stxxl::vector<std::vector<T> > and stxxl::vector<stxxl::vector<T> > are invalid. If appropriate, use std::vector<stxxl::vector<T> >, or emulate a two-dimensional array by doing index calculation.

ch0kee
  • 736
  • 4
  • 12
  • 1
    would have if it was tagged and if mentioned explicitly in your answer – Arunmu Dec 03 '11 at 05:14
  • it looks irrelevant, but ok, I'm replacing it for backward compatibility – ch0kee Dec 03 '11 at 05:24
  • Sorry for arguing , but its completely relevant to answer as per the tags. +1. for the edited answer :) – Arunmu Dec 03 '11 at 05:43
  • I forgot to put the template parameter on the post, my problem is that the implementation of the stxxl::vector can't hold consistent values of dynamic structures – darkloz Dec 03 '11 at 05:46
  • I mean, it compile but in running time I get some segmentation faults – darkloz Dec 03 '11 at 05:49
  • That's right, that's why I'm asking if somebody knows an external memory vector library that support dynamic structures as elements. – darkloz Dec 03 '11 at 05:52