我有一个C++类,表示一个非常大的分层组织数据树(~Gb,基本上和我在内存中可以消除的一样大).它使用STL列表在每个节点上存储信息,并在其他节点上存储迭代器.每个节点只有一个父节点,但有0-10个子节点.抽象,它看起来像:
struct node {
public:
node_list_iterator parent; // iterator to a single parent node
double node_data_array[X];
map<int,node_list_iterator> children; // iterators to child nodes
};
class strategy {
private:
list<node> tree; // hierarchically linked list of nodes
struct some_other_data;
public:
void build(); // build the tree
void save(); // save the tree from disk
void load(); // load the tree from disk
void use(); // use the tree
};
Run Code Online (Sandbox Code Playgroud)
我想将load()和save()实现到磁盘,它应该相当快,但明显的问题是:
我不提前知道尺寸;
数据包含迭代器,它们是易失性的;
我对C++的无知是惊人的.
请问有人建议使用纯C++解决方案吗?