Esempio n. 1
0
    public bool Equals(IMyList <T> that)
    {
        if (this == that)
        {
            return(true);
        }
        if (that == null || this.Count != that.Count)
        {
            return(false);
        }
        Node            thisnode = this.first;
        IEnumerator <T> thatenm  = that.GetEnumerator();

        while (thisnode != null)
        {
            if (!thatenm.MoveNext())
            {
                throw new ApplicationException("Impossible: LinkedList<T>.Equals");
            }
            // assert MoveNext() was true (because of the above size test)
            if (!thisnode.item.Equals(thatenm.Current))
            {
                return(false);
            }
            thisnode = thisnode.next;
        }
        // assert !MoveNext(); // because of the size test
        return(true);
    }
Esempio n. 2
0
        public IEnumerator <T> GetEnumerator()
        {
            IMyList <IEnumerator <T> > enumerators = new MyList <IEnumerator <T> >();

            for (int i = 0; i < this.buckets.Length; i++)
            {
                IMyList <T> bucket = this.buckets[i];

                if (bucket != null && bucket.Count > 0)
                {
                    enumerators.Add(bucket.GetEnumerator());
                }
            }

            return(new MyHashTableEnumerator <T>(enumerators));
        }