jweinst1
5/15/2016 - 7:34 AM

doubly linked node list js

doubly linked node list js

//doubly linked node

//these nodes will be embedded into the core
var DoubNode = (function(){
	function DoubNode(prev, value){
		this.prev = prev;
		this.value = value || null;
		this.forward = null;
	}
	//extends the forward link by a new value by recursion
	DoubNode.prototype.extend = function(elem){
		if(this.forward === null) this.forward = new DoubNode(this, elem);
		else {
			this.forward.extend(elem);
		}
	};
	DoubNode.prototype.getValue = function(){
		return this.value;
	};
	return DoubNode;
})();

//root center of tree machine
var MachineCore = (function(){
	function MachineCore(){
		this.links = {};
	}
	return MachineCore;
})();