public Node(K Key, V Value, VersionHandle Version, FatNode FatNode) { this.Key = Key; this.Value = Value; this.Version = Version; this.FatNode = FatNode; }
public Node(K Key, V Value, VersionHandle Version) { this.Key = Key; this.Value = Value; this.Version = Version; this.FatNode = new FatNode(this); }
/// <summary> /// Inserts an entry not present in the current version. /// </summary> /// <returns>New version with inserted vertex</returns> public Tree <K, V> Insert(K Key, V Value) { var newVersion = Version.GetSuccessor(); // Key must not be present in tree! var n = new Node(Key, Value, newVersion).GetTemporaryAccessorForVersion(newVersion); if (Root is null) { var newRoot = n.GetPermanentAccessor(); Node.RemoveListOfAccessors(); return(new Tree <K, V> { Root = newRoot, Version = newVersion }); } var root = Root.Node.GetTemporaryAccessorForVersion(newVersion); var path = GetPath(Key, root); if (Key.CompareTo(path.Last().Key) < 0) { path.Last().Base.Left = n; } else { path.Last().Base.Right = n; } var top = BalancePath(path).GetPermanentAccessor(); Node.RemoveListOfAccessors(); FatNode.FinishUpdate(); return(new Tree <K, V> { Root = top, Version = newVersion }); }