Java: versioned data structures?

Posted by Jason S on Stack Overflow See other posts from Stack Overflow or by Jason S
Published on 2010-06-11T17:08:08Z Indexed on 2010/06/11 17:12 UTC
Read the original article Hit count: 360

Filed under:
|

I have a data structure that is pretty simple (basically a structure containing some arrays and single values), but I need to record the history of the data structure so that I can efficiently get the contents of the data structure at any point in time.

Is there a relatively straightforward way to do this?

The best way I can think of would be to encapsulate the whole data structure with something that handles all the mutating operations by storing data in functional data structures, and then for each mutation operation caching a copy of the data structure in a Map indexed by time-ordering (e.g. a TreeMap with real time as keys, or a HashMap with a counter of mutation operations combined with one or more indexes stored in TreeMaps mapping real time / tick count / etc. to mutation operations)

any suggestions?

© Stack Overflow or respective owner

Related posts about java

Related posts about data-structures