The format of your files is really up to you. Just make sure that you're able restore your index to its orginal state if you restore from a saved file.
I'll throw out a naive approach of: -Maintain a structure in your index that holds everything that addPage has ever been called with -Save this structure to the file when the save method is called -To restore, simply call addPage with the contents of your file and then call makeIndex.
Please only use this as a last resort. I haven't tried doing it this way, so while it is conceptually easy and probably quite easy to implement, it may or may not cause you to run out of memory (I really don't know) since you'll have that extra data structure to maintain in your index. |