예제 #1
0
        public void RemoveObserver(IObserver <T> observer)
        {
            PriorityObserver <T> obs = null;

            foreach (var observerPair in m_observers)
            {
                if (observerPair.Observer == observer)
                {
                    obs = observerPair;
                    break;
                }
            }

            if (obs != null)
            {
                m_observers.Remove(obs);
            }
        }
예제 #2
0
        public int Compare(PriorityObserver <T> x, PriorityObserver <T> y)
        {
            if (x.Observer != y.Observer)
            {
                if (x.Priority > y.Priority)
                {
                    return(1);
                }
                else if (x.Priority < y.Priority)
                {
                    return(-1);
                }
                else if (x.Priority == y.Priority)
                {
                    return(1);
                }
            }

            return(0);
        }