[an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] (none) [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] (none) [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive]
 
[an error occurred while processing this directive] [an error occurred while processing this directive]
Skåne Sjælland Linux User Group - http://www.sslug.dk Home   Subscribe   Mail Archive   Forum   Calendar   Search
MhonArc Date: [Date Prev] [Date Index] [Date Next]   Thread: [Date Prev] [Thread Index] [Date Next]   MhonArc
 

Re: [PROGRAMMERING] C++ container stack ved brug af en fil



stxxl er nok nær det, jeg ønsker, men jeg tror, at jeg har et problem. stxxl 
fungerer kun med simple objekter (fast længde), tror jeg nok. I det følgende 
tror jeg ikke, at mine operatorer << og >> bliver brugt af stxxl til at 
skrive objekter af typen Mystruct til den bagved liggende fil,  brugt af 
stxxl

#include <set>
#include <fstream>
#include <stxxl.h>
using namespace std;

struct Mystruct {
   set<int> h;
    int nr;
}

istream & operator >> (istream &in, Mystruct &m)
{
     size_type size;
     in >>size;
     for (int i=0; i<size; i++) {
        int v;
        in >>v;
        m.h.insert(v);
     }
     in >>m.nr;
}

ostream & operator << (ostream &out, Mystruct &m)
{
     out << m.h.size();
     set<int>::iterator i=m.h.begin();
     while(i!=m.h.end()) {
        out << *i;
        i++;
     }
     out << m.nr;
}


hint main(int argc, char *argv[])
{
    stxxl::vector<Mystruct> v;
....
  //Fyld v med random data
....
  return 0;
}


Problemet er at "set" allokerer dynamisk et område i ram og stxxl håndterer 
Mystruct som en klump af binære data, og ignorerer eventuelle pointers 




 
Home   Subscribe   Mail Archive   Index   Calendar   Search

 
 
Questions about the web-pages to <www_admin>. Last modified 2010-01-01, 02:01 CET [an error occurred while processing this directive]
This page is maintained by [an error occurred while processing this directive]MHonArc [an error occurred while processing this directive] # [an error occurred while processing this directive] *