예제 #1
0
 public NodeData(TreeNode.Child type, int parentIndex, Interval parentInterval, int height)
 {
     Type           = type;
     ParentIndex    = parentIndex;
     ParentInterval = parentInterval;
     Height         = height;
 }
예제 #2
0
        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;
            }
        }
예제 #3
0
        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);
        }
예제 #4
0
 public int AddNode(byte value, int feature, int parentIndex, TreeNode.Child type)
 {
     return(Add(value, feature, -1, -1, parentIndex, type));
 }
예제 #5
0
 public void AddLeaf(byte value, int feature, int parentIndex, TreeNode.Child type)
 {
     Add(value, feature, 0, 0, parentIndex, type);
 }