예제 #1
0
파일: Heaps.cs 프로젝트: samaysar/cryptopoc
        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));
        }
예제 #2
0
파일: Heaps.cs 프로젝트: samaysar/cryptopoc
 public int GetHashCode(AbsHeap <T> obj)
 {
     return(obj.Id);
 }
예제 #3
0
파일: Heaps.cs 프로젝트: samaysar/cryptopoc
 public bool Equals(AbsHeap <T> x, AbsHeap <T> y)
 {
     return(x.Id == y.Id);
 }