예제 #1
0
        public int GetChildIndex(LeafNode searchingFor)
        {
            var childIter = child;
            int index;

            for (index = 0; index < ChildCount; index++)
            {
                if( childIter == null ) return -1;
                if( childIter == searchingFor ) break;

                childIter = childIter.GetRightSibling();
            }

            return index;
        }
예제 #2
0
 protected void SetRightSibling(LeafNode sibling)
 {
     rightSibling = sibling;
 }
예제 #3
0
 private void SetParent(LeafNode newParent)
 {
     parent = newParent;
 }
예제 #4
0
 protected void SetLeftSibling(LeafNode sibling)
 {
     leftSibling = sibling;
 }
예제 #5
0
        private void RemoveChild(LeafNode toBeRemoved)
        {
            if( toBeRemoved == null ) return; 
            
            if( toBeRemoved == GetFirstChild() )
            {
                child = toBeRemoved.GetRightSibling();
                if( child != null )
                {
                    child.SetLeftSibling( null );
                }
            }
            else
            {
                var siblingIter = child;
                while ( siblingIter != null && siblingIter != toBeRemoved ) 
                {
                    siblingIter = siblingIter.GetRightSibling();
                }

                if( siblingIter == toBeRemoved )
                {
                    if( toBeRemoved.HasLeftSibling() ) 
                    {
                        toBeRemoved.GetLeftSibling().SetRightSibling( toBeRemoved.GetRightSibling() );
                    }

                    if( toBeRemoved.HasRightSibling() )
                    {
                        toBeRemoved.GetRightSibling().SetLeftSibling( toBeRemoved.GetLeftSibling() );
                    }
                }
            }

            toBeRemoved.SetParent( null );
            toBeRemoved.SetLeftSibling( null );
            toBeRemoved.SetRightSibling( null );
            ChildCount--;
        }
예제 #6
0
        protected void AddChild(LeafNode newChild)
        {
            if( newChild.HasParent() )
            {
                newChild.GetParent().RemoveChild( newChild ); 
            }

            if( IsLeaf() )
            {
                SetChild( newChild );
                newChild.SetLeftSibling( null );
            }
            else
            {
                var siblingIter = child;
                while ( siblingIter != null && siblingIter.HasRightSibling() )
                {
                    siblingIter = siblingIter.GetRightSibling();
                }

                if( siblingIter != null )
                {
                    siblingIter.SetRightSibling( newChild );
                    newChild.SetLeftSibling( siblingIter );
                }
            }

            newChild.SetParent( this );
            ChildCount++;
        }
예제 #7
0
 protected void SetChild(LeafNode newChild)
 {
     child = newChild;
 }
예제 #8
0
 private LeafNode(LeafNode p,
     LeafNode o,
     LeafNode l,
     LeafNode r,
     int nC,
     int horizontalCoordinate,
     int verticalCoordinate,
     int w,
     int h,
     LeafNode prev,
     float preliminaryLocation,
     float mod)
 {
     parent = p;
     child = o;
     leftSibling = l;
     rightSibling = r;
     ChildCount = nC;
     HorizontalCoordinate = horizontalCoordinate;
     VerticalCoordinate = verticalCoordinate;
     width = w;
     height = h;
     LeftSibling = prev;
     PreliminaryLocation = preliminaryLocation;
     Modifier = mod;
 }