Пример #1
0
            public bool Add(T Element)
            {
                ItemsInNode++;

                if (this.Element == null)
                {
                    this.Element = Element;

                    return(true);
                }
                else
                {
                    T comparing = Element;

                    if (this.Element.CompareTo(comparing) > 0)
                    {
                        comparing    = this.Element;
                        this.Element = Element;
                    }

                    if (Lewy == null)
                    {
                        Lewy = new KopiecElement(comparing);
                        return(true);
                    }

                    if (Lewy.Element.CompareTo(comparing) > 0)
                    {
                        T temp = Lewy.Element;
                        Lewy.Element = comparing;
                        comparing    = temp;
                    }

                    if (Prawy == null)
                    {
                        Prawy = new KopiecElement(comparing);
                        return(true);
                    }

                    if (Prawy.ItemsInNode < Lewy.ItemsInNode)
                    {
                        return(Prawy.Add(comparing));
                    }
                    else
                    {
                        return(Lewy.Add(comparing));
                    }
                }
            }
Пример #2
0
        public int Add(T Element)
        {
            if (Szczyt == null)
            {
                Szczyt = new KopiecElement(Element);
                Min    = Element;
            }
            else
            {
                Szczyt.Add(Element);

                if (Element.CompareTo(Min) < 0)
                {
                    Min = Element;
                }
            }

            return(Dlugosc);
        }