Пример #1
0
        public void addCounterElement(T elem)
        {
            CountedElement <T> cursor
                = this.Find(x => x.Value.Equals(elem));

            if (cursor != null)
            {
                cursor.increment();
            }
            else
            {
                this.Add(new CountedElement <T>(elem));
            }
        }
Пример #2
0
        public int CompareTo(object other)
        {
            if (other == null)
            {
                return(1);
            }

            CountedElement <T> that = other as CountedElement <T>;
            int thisCounter         = this.counter;
            int thatCounter         = that.counter;

            if (thisCounter < thatCounter)
            {
                return(-1);
            }
            else if (thisCounter > thatCounter)
            {
                return(1);
            }
            return(0);
        }