Beispiel #1
0
            internal void BubbleDownData(Func <T, T, bool> compare)
            {
                if (LeftChild == null && RightChild == null)
                {
                    return;
                }

                if (LeftChild != null && !compare(Data, LeftChild.Data))
                {
                    // Swap
                    // TODO into a method
                    T temp = LeftChild.Data;
                    LeftChild.Data = Data;
                    Data           = temp;
                    LeftChild.BubbleDownData(compare);
                }
                else if (RightChild != null && !compare(Data, RightChild.Data))
                {
                    // Swap
                    T temp = RightChild.Data;
                    RightChild.Data = Data;
                    Data            = temp;
                    RightChild.BubbleDownData(compare);
                }
            }