Exemplo n.º 1
0
        private static bool EqAggregateTreap(IAggregateTreap <int> fstTreap, IAggregateTreap <int> sndTreap)
        {
            if (fstTreap.Count != sndTreap.Count)
            {
                return(false);
            }

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

            for (int i = 0; i < fstTreap.Count; i++)
            {
                for (int j = i; j < fstTreap.Count; j++)
                {
                    int aggregate1 = fstTreap.Aggregate(i, j);
                    int aggregate2 = sndTreap.Aggregate(i, j);
                    if (aggregate1 != aggregate2)
                    {
                        return(false);
                    }
                }
            }

            return(true);
        }