I need to implement a B-tree. I know how to do this.
But I want to restore my data structure(B-tree) if my application will crash. So I want to store my B-tree not only in memory but also on the hard disk. How to do this?
I need to implement a B-tree. I know how to do this.
But I want to restore my data structure(B-tree) if my application will crash. So I want to store my B-tree not only in memory but also on the hard disk. How to do this?
What you need is Serialization. This gives you a representation of the data structure that can be stored on disk, either in a binary format or, for instance, XML. De-serialization will restore the data structure. Note that all items in the tree need to be Serializable as well.
Data structures in the .Net Framework often support serialization out of the box, but there seems to be no public B-tree implementation.
You could go an look for an implementation in Code project. Alternatively, BPlusTree could be what you are looking for:
BPlusTree is a implementation of the generic IDictionary interface backed by a disk-based B+Tree.
But I haven't used it.