Exemplo n.º 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;
        }
Exemplo n.º 2
0
 protected void SetRightSibling(LeafNode sibling)
 {
     rightSibling = sibling;
 }
Exemplo n.º 3
0
 private void SetParent(LeafNode newParent)
 {
     parent = newParent;
 }
Exemplo n.º 4
0
 protected void SetLeftSibling(LeafNode sibling)
 {
     leftSibling = sibling;
 }
Exemplo n.º 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--;
        }
Exemplo n.º 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++;
        }
Exemplo n.º 7
0
 protected void SetChild(LeafNode newChild)
 {
     child = newChild;
 }
Exemplo n.º 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;
 }