Exemplo n.º 1
0
        public int CompareTo(AbsHeap <T> other)
        {
            if (ReferenceEquals(other, null))
            {
                return(1);
            }
            if (ReferenceEquals(this, other))
            {
                return(0);
            }
            T myVal;

            lock (_syncRoot)
            {
                if (HighIndex < 0)
                {
                    return(_emptyDefault);
                }
                myVal = _data[0].Obj;
            }
            //!!! ALWAYS OUTSIDE OF LOCK... else DEADLOCK can happen
            //other will take the lock inside this call

            //It is OK, if during this time, value changes again => Opportunity COST!
            //But we cannot avoid it... it's the best effort!
            return(other.GivenCompareToRoot(myVal));
        }
Exemplo n.º 2
0
 public int GetHashCode(AbsHeap <T> obj)
 {
     return(obj.Id);
 }
Exemplo n.º 3
0
 public bool Equals(AbsHeap <T> x, AbsHeap <T> y)
 {
     return(x.Id == y.Id);
 }