Example #1
0
        public void SetRightChild(SortedTreeNode <IdType, DataType> node)
        {
            if (ReferenceEquals(node, this))
            {
                return;
            }

            if (RightChildNode == null)
            {
                RightChildNode = node;
                node.Parent    = this;
            }
            else
            {
                RightChildNode.SetLeftChild(node);
            }
        }
Example #2
0
        public void SetNodeAfter(SortedTreeNode <IdType, DataType> node)
        {
            if (ReferenceEquals(node, this))
            {
                return;
            }

            if (NodeAfter == null)
            {
                NodeAfter   = node;
                node.Parent = this;
            }
            else
            {
                NodeAfter.SetNodeBefore(node);
            }
        }
Example #3
0
        private void AddLinkedNodesToList(SortedTreeNode <IdType, DataType> node, List <DataType> list)
        {
            if (node == null)
            {
                return;
            }

            if (node.LeftChildNode != null)
            {
                AddLinkedNodesToList(node.LeftChildNode, list);
            }

            if (!list.Contains(node.Data))
            {
                list.Add(node.Data);
            }

            if (node.RightChildNode != null)
            {
                AddLinkedNodesToList(node.RightChildNode, list);
            }
        }
Example #4
0
        private bool HasSortPreferenceWith(SortedTreeNode <IdType, DataType> a, GetCollection getCollection, SortedTreeNode <IdType, DataType> b)
        {
            IList <IdType> collection = getCollection.Invoke(a);

            if (collection.Count == 0)
            {
                return(false);
            }

            if (collection.Contains(b.Id))
            {
                return(true);
            }

            foreach (IdType aDependency in collection)
            {
                if (!NodesToSort.TryGetValue(aDependency, out SortedTreeNode <IdType, DataType> aDep))
                {
                    continue;
                }

                if (HasSortPreferenceWith(aDep, getCollection, b))
                {
                    return(true);
                }
            }

            return(false);
        }
Example #5
0
 public void ClearLinks()
 {
     LeftChildNode  = null;
     RightChildNode = null;
 }
Example #6
0
 public void ClearLinks()
 {
     NodeBefore = null;
     NodeAfter  = null;
 }