Beispiel #1
0
        private static void GenerateTreap(IInverseIntTreap <int> treap, int seed)
        {
            Random random = new Random(seed);

            for (int i = 0; i < 1000; i++)
            {
                treap.Insert(i, i + 1);
            }

            for (int i = 0; i < 1000; i++)
            {
                int source = random.Next() % treap.Count;
                int dest   = random.Next() % treap.Count;
                treap.Move(source, dest);
            }
        }
Beispiel #2
0
        private static bool EqInverseTreap(IInverseIntTreap <int> fstTreap, IInverseIntTreap <int> sndTreap)
        {
            if (fstTreap.Count != sndTreap.Count)
            {
                return(false);
            }

            for (int i = 0; i < fstTreap.Count; i++)
            {
                if (fstTreap[i] != sndTreap[i])
                {
                    return(false);
                }

                if (fstTreap.GetInverse(i + 1) != sndTreap.GetInverse(i + 1))
                {
                    return(false);
                }
            }

            return(true);
        }