public NodeData(TreeNode.Child type, int parentIndex, Interval parentInterval, int height) { Type = type; ParentIndex = parentIndex; ParentInterval = parentInterval; Height = height; }
private void UpdateParent(int parentIndex, TreeNode.Child type, int newIndex) { TreeNode parent = _tree[parentIndex]; switch (type) { case TreeNode.Child.LEFT: _tree[parentIndex] = new TreeNode(parent.Value, parent.Feature, newIndex, parent.RightChild); break; case TreeNode.Child.RIGHT: _tree[parentIndex] = new TreeNode(parent.Value, parent.Feature, parent.LeftChild, newIndex); break; } }
private int Add(byte value, int feature, int left, int right, int parentIndex, TreeNode.Child type) { int currentInd = _tree.Count; _tree.Add(new TreeNode(value, feature, left, right)); UpdateParent(parentIndex, type, currentInd); return(currentInd); }
public int AddNode(byte value, int feature, int parentIndex, TreeNode.Child type) { return(Add(value, feature, -1, -1, parentIndex, type)); }
public void AddLeaf(byte value, int feature, int parentIndex, TreeNode.Child type) { Add(value, feature, 0, 0, parentIndex, type); }