I wrote a generic in-memory B+Tree implementation in C++ few times ago, and I m thinking about making it persistent on disk (which is why B+Tree have been designed for initially). My first thought was to use mmap (I m under Linux) to be able to manipulate the file as normal memory and just rewrite the new operator of my nodes classes so that it returns pointers in the mapped portion and create a smart pointer which can convert RAM adresses to file offset to link my nodes with others. But I want my implementation to be generic, so the user can store an int, an std::string, or whatever custom class he wants in the B+tree. That s where the problem occurs: for primitive types or aggregated types that do not contain pointers that s all good, but as soon as the object contains a pointer/reference to an heap allocated object, this approach no longer works.
因此,我的问题是:是否有办法克服这一困难? 我对这个专题的亲自搜查最终没有成功,但也许我错了。