Пример #1
0
        public static FSharpList <RankedTree <a> > insertTree <a>(IComparer <a> comparer, RankedTree <a> t, FSharpList <RankedTree <a> > ts)
        {
            while (true)
            {
                FSharpList <RankedTree <a> > fsharpList1 = ts;
                if (fsharpList1.get_TailOrNull() != null)
                {
                    FSharpList <RankedTree <a> > fsharpList2 = fsharpList1;
                    FSharpList <RankedTree <a> > tailOrNull  = fsharpList2.get_TailOrNull();
                    RankedTree <a> headOrDefault             = fsharpList2.get_HeadOrDefault();
                    if (BinomialHeap.rank <a>(t) >= BinomialHeap.rank <a>(headOrDefault))
                    {
                        IComparer <a>  comparer1  = comparer;
                        RankedTree <a> rankedTree = BinomialHeap.link <a>(comparer, t, headOrDefault);
                        ts       = tailOrNull;
                        t        = rankedTree;
                        comparer = comparer1;
                    }
                    else
                    {
                        goto label_3;
                    }
                }
                else
                {
                    break;
                }
            }
            return(FSharpList <RankedTree <a> > .Cons(t, FSharpList <RankedTree <a> > .get_Empty()));

label_3:
            return(FSharpList <RankedTree <a> > .Cons(t, ts));
        }
Пример #2
0
        internal static Tuple <RankedTree <a>, FSharpList <RankedTree <a> > > removeMinTree <a>(IComparer <a> comparer, FSharpList <RankedTree <a> > heap)
        {
            FSharpList <RankedTree <a> > fsharpList1 = heap;

            if (fsharpList1.get_TailOrNull() == null)
            {
                throw new InvalidOperationException("The heap is empty.");
            }
            FSharpList <RankedTree <a> > fsharpList2 = fsharpList1;

            if (fsharpList2.get_TailOrNull().get_TailOrNull() == null)
            {
                return(new Tuple <RankedTree <a>, FSharpList <RankedTree <a> > >(fsharpList2.get_HeadOrDefault(), FSharpList <RankedTree <a> > .get_Empty()));
            }
            FSharpList <RankedTree <a> > tailOrNull = fsharpList2.get_TailOrNull();
            RankedTree <a> headOrDefault            = fsharpList2.get_HeadOrDefault();
            Tuple <RankedTree <a>, FSharpList <RankedTree <a> > > tuple = BinomialHeap.removeMinTree <a>(comparer, tailOrNull);
            FSharpList <RankedTree <a> > fsharpList3 = tuple.Item2;
            RankedTree <a> rankedTree = tuple.Item1;
            FSharpChoice <Unit, Unit, Unit> fsharpChoice = BinomialHeap.LTGTEQ(comparer.Compare(BinomialHeap.root <a>(headOrDefault), BinomialHeap.root <a>(rankedTree)));

            if (fsharpChoice is FSharpChoice <Unit, Unit, Unit> .Choice1Of3 || fsharpChoice is FSharpChoice <Unit, Unit, Unit> .Choice3Of3)
            {
                return(new Tuple <RankedTree <a>, FSharpList <RankedTree <a> > >(headOrDefault, tailOrNull));
            }
            return(new Tuple <RankedTree <a>, FSharpList <RankedTree <a> > >(rankedTree, FSharpList <RankedTree <a> > .Cons(headOrDefault, fsharpList3)));
        }
Пример #3
0
        public virtual bool Equals(object obj, IEqualityComparer comp)
        {
            if (this == null)
            {
                return(obj == null);
            }
            RankedTree <T> rankedTree1 = obj as RankedTree <T>;

            if (rankedTree1 == null)
            {
                return(false);
            }
            RankedTree <T> rankedTree2 = rankedTree1;
            RankedTree <T> rankedTree3 = this;
            RankedTree <T> rankedTree4 = this;
            RankedTree <T> rankedTree5 = rankedTree2;

            if (rankedTree4.item1 != rankedTree5.item1 || !LanguagePrimitives.HashCompare.GenericEqualityWithComparerIntrinsic <T>(comp, (M0)rankedTree4.item2, (M0)rankedTree5.item2))
            {
                return(false);
            }
            IEqualityComparer equalityComparer = comp;

            return(rankedTree4.item3.Equals((object)rankedTree5.item3, equalityComparer));
        }
Пример #4
0
        public virtual int CompareTo(object obj, IComparer comp)
        {
            RankedTree <T> rankedTree1 = (RankedTree <T>)obj;

            if (this != null)
            {
                if ((RankedTree <T>)obj == null)
                {
                    return(1);
                }
                RankedTree <T> rankedTree2 = this;
                RankedTree <T> rankedTree3 = this;
                RankedTree <T> rankedTree4 = rankedTree1;
                int            num1        = rankedTree3.item1;
                int            num2        = rankedTree4.item1;
                int            num3        = num1 >= num2 ? (num1 > num2 ? 1 : 0) : -1;
                if (num3 < 0 || num3 > 0)
                {
                    return(num3);
                }
                int num4 = LanguagePrimitives.HashCompare.GenericComparisonWithComparerIntrinsic <T>(comp, (M0)rankedTree3.item2, (M0)rankedTree4.item2);
                if (num4 < 0 || num4 > 0)
                {
                    return(num4);
                }
                IComparer comparer = comp;
                return(rankedTree3.item3.CompareTo((object)rankedTree4.item3, comparer));
            }
            return((RankedTree <T>)obj != null ? -1 : 0);
        }
Пример #5
0
 public virtual int CompareTo(RankedTree <T> obj)
 {
     if (this != null)
     {
         if (obj == null)
         {
             return(1);
         }
         RankedTree <T> rankedTree1 = this;
         RankedTree <T> rankedTree2 = this;
         RankedTree <T> rankedTree3 = obj;
         LanguagePrimitives.get_GenericComparer();
         int num1 = rankedTree2.item1;
         int num2 = rankedTree3.item1;
         int num3 = num1 >= num2 ? (num1 > num2 ? 1 : 0) : -1;
         if (num3 < 0 || num3 > 0)
         {
             return(num3);
         }
         int num4 = LanguagePrimitives.HashCompare.GenericComparisonWithComparerIntrinsic <T>(LanguagePrimitives.get_GenericComparer(), (M0)rankedTree2.item2, (M0)rankedTree3.item2);
         if (num4 < 0 || num4 > 0)
         {
             return(num4);
         }
         IComparer genericComparer = LanguagePrimitives.get_GenericComparer();
         return(rankedTree2.item3.CompareTo((object)rankedTree3.item3, genericComparer));
     }
     return(obj != null ? -1 : 0);
 }
Пример #6
0
        public override sealed bool Equals(object obj)
        {
            RankedTree <T> rankedTree = obj as RankedTree <T>;

            if (rankedTree != null)
            {
                return(this.Equals(rankedTree));
            }
            return(false);
        }
Пример #7
0
        public virtual int GetHashCode(IEqualityComparer comp)
        {
            if (this == null)
            {
                return(0);
            }
            RankedTree <T> rankedTree1 = this;
            RankedTree <T> rankedTree2 = this;
            int            num1        = 0;
            int            num2        = rankedTree2.item3.GetHashCode(comp) + ((num1 << 6) + (num1 >> 2)) - 1640531527;
            int            num3        = LanguagePrimitives.HashCompare.GenericHashWithComparerIntrinsic <T>(comp, (M0)rankedTree2.item2) + ((num2 << 6) + (num2 >> 2)) - 1640531527;

            return(rankedTree2.item1 + ((num3 << 6) + (num3 >> 2)) - 1640531527);
        }
Пример #8
0
        internal static RankedTree <a> link <a>(IComparer <a> comparer, RankedTree <a> _arg2, RankedTree <a> _arg1)
        {
            RankedTree <a> rankedTree1 = _arg2;
            a   x   = rankedTree1.item2;
            int num = rankedTree1.item1;
            FSharpList <RankedTree <a> > fsharpList1 = rankedTree1.item3;
            RankedTree <a> rankedTree2 = _arg1;
            a y = rankedTree2.item2;
            FSharpList <RankedTree <a> > fsharpList2 = rankedTree2.item3;

            if (BinomialHeap.LTGTEQ(comparer.Compare(x, y)) is FSharpChoice <Unit, Unit, Unit> .Choice2Of3)
            {
                return(RankedTree <a> .NewNode(num + 1, y, FSharpList <RankedTree <a> > .Cons(rankedTree1, fsharpList2)));
            }
            return(RankedTree <a> .NewNode(num + 1, x, FSharpList <RankedTree <a> > .Cons(rankedTree2, fsharpList1)));
        }
Пример #9
0
        public virtual bool Equals(RankedTree <T> obj)
        {
            if (this == null)
            {
                return(obj == null);
            }
            if (obj == null)
            {
                return(false);
            }
            RankedTree <T> rankedTree1 = this;
            RankedTree <T> rankedTree2 = this;
            RankedTree <T> rankedTree3 = obj;

            if (rankedTree2.item1 == rankedTree3.item1 && LanguagePrimitives.HashCompare.GenericEqualityERIntrinsic <T>((M0)rankedTree2.item2, (M0)rankedTree3.item2))
            {
                return(LanguagePrimitives.HashCompare.GenericEqualityERIntrinsic <FSharpList <RankedTree <T> > >((M0)rankedTree2.item3, (M0)rankedTree3.item3));
            }
            return(false);
        }
Пример #10
0
        public static FSharpList <RankedTree <a> > mergeTrees <a>(IComparer <a> comparer, FSharpList <RankedTree <a> > _arg1_0, FSharpList <RankedTree <a> > _arg1_1)
        {
            Tuple <FSharpList <RankedTree <a> >, FSharpList <RankedTree <a> > > tuple = new Tuple <FSharpList <RankedTree <a> >, FSharpList <RankedTree <a> > >(_arg1_0, _arg1_1);
            FSharpList <RankedTree <a> > fsharpList1;

            if (tuple.Item2.get_TailOrNull() != null)
            {
                FSharpList <RankedTree <a> > fsharpList2 = tuple.Item2;
                if (tuple.Item1.get_TailOrNull() != null)
                {
                    FSharpList <RankedTree <a> > fsharpList3 = tuple.Item1;
                    FSharpList <RankedTree <a> > tailOrNull1 = fsharpList2.get_TailOrNull();
                    FSharpList <RankedTree <a> > fsharpList4 = tuple.Item2;
                    FSharpList <RankedTree <a> > tailOrNull2 = fsharpList3.get_TailOrNull();
                    FSharpList <RankedTree <a> > fsharpList5 = tuple.Item1;
                    RankedTree <a> headOrDefault1            = fsharpList2.get_HeadOrDefault();
                    RankedTree <a> headOrDefault2            = fsharpList3.get_HeadOrDefault();
                    int            num1 = BinomialHeap.rank <a>(headOrDefault2);
                    int            num2 = BinomialHeap.rank <a>(headOrDefault1);
                    FSharpChoice <Unit, Unit, Unit> fsharpChoice = BinomialHeap.LTGTEQ(num1 >= num2 ? (num1 > num2 ? 1 : 0) : -1);
                    if (fsharpChoice is FSharpChoice <Unit, Unit, Unit> .Choice2Of3)
                    {
                        return(FSharpList <RankedTree <a> > .Cons(headOrDefault1, BinomialHeap.mergeTrees <a>(comparer, fsharpList5, tailOrNull1)));
                    }
                    if (!(fsharpChoice is FSharpChoice <Unit, Unit, Unit> .Choice3Of3))
                    {
                        return(FSharpList <RankedTree <a> > .Cons(headOrDefault2, BinomialHeap.mergeTrees <a>(comparer, tailOrNull2, fsharpList4)));
                    }
                    return(BinomialHeap.insertTree <a>(comparer, BinomialHeap.link <a>(comparer, headOrDefault2, headOrDefault1), BinomialHeap.mergeTrees <a>(comparer, tailOrNull2, tailOrNull1)));
                }
                fsharpList1 = tuple.Item2;
            }
            else
            {
                fsharpList1 = tuple.Item1;
            }
            return(fsharpList1);
        }
Пример #11
0
 internal static a root <a>(RankedTree <a> _arg1)
 {
     return(_arg1.item2);
 }
Пример #12
0
 internal static int rank <a>(RankedTree <a> _arg1)
 {
     return(_arg1.item1);
 }
Пример #13
0
        public static BinomialHeap <a> insert <a>(a x, BinomialHeap <a> heap)
        {
            FSharpList <RankedTree <a> > heap1 = BinomialHeap.insertTree <a>(heap.Comparer, RankedTree <a> .NewNode(0, x, FSharpList <RankedTree <a> > .get_Empty()), heap.Heap);

            return(new BinomialHeap <a>(heap.Comparer, heap1));
        }
Пример #14
0
        public int get_Tag()
        {
            RankedTree <T> rankedTree = this;

            return(0);
        }