version-tree
A data structure for maintaining a tree of versions. This can be useful when implementing fully persistent data structures using the DTSS method. Works in both node.js and browserify. All operations use amortized O(1) space and time.
Example
var createVersionTree = //Create a new treevar root = //Create two subversionsvar a = rootvar b = root //Compare root to childrenconsole// Prints out:// true true false false //Make a child version of avar c = aconsole//Prints out:// true true false
Install
npm install version-tree
API
var createVersionTree =
var tree = createVersionTree()
Creates a new version tree with one root version
tree.fork()
Creates a new subversion of tree
.
Returns A new version which inherits from tree
tree.subversion(other)
Tests if other
is a subversion of tree
.
Returns true
if other
is an ancestor of tree
, false
otherwise
Credits
(c) 2013 Mikola Lysenko. MIT License