Exemple #1
0
        public override int GetHashCode()
        {
            int hash = (113 + (11 * RootValue.GetHashCode()) + (17 * RootKey.GetHashCode()) + (31 * subTrees.Count));

            for (int i = 0; i < subTrees.Count; i++)
            {
                hash += ((int)Math.Pow(73, i) * subTrees[i].GetHashCode());
            }

            return(hash);
        }
Exemple #2
0
        public override bool Equals(object obj)
        {
            BinomialTree <TKey, TValue> other;

            if ((other = obj as BinomialTree <TKey, TValue>) == null)
            {
                return(false);
            }

            if (!RootValue.Equals(other.RootValue) || (RootKey.CompareTo(other.RootKey) != 0) || (subTrees.Count != other.subTrees.Count))
            {
                return(false);
            }

            foreach (BinomialTree <TKey, TValue> subTree in subTrees)
            {
                if (!other.subTrees.Contains(subTree))
                {
                    return(false);
                }
            }

            return(true);
        }