Exemplo n.º 1
0
        public void GetElementPriority(int i, out IEventObserver element, out int priority)
        {
            EventObserverElementPriorityPair eventObserverElementPriorityPair = this.list.Array[i];

            element  = eventObserverElementPriorityPair.Element;
            priority = eventObserverElementPriorityPair.Priority;
        }
Exemplo n.º 2
0
        public virtual int Add(IEventObserver element, int priority)
        {
            if (element == null)
            {
                return(-1);
            }
            int i      = 0;
            int length = this.list.Length;

            while (i < length)
            {
                EventObserverElementPriorityPair eventObserverElementPriorityPair = this.list.Array[i];
                if (eventObserverElementPriorityPair.Element == element)
                {
                    return(-1);
                }
                if (priority > eventObserverElementPriorityPair.Priority)
                {
                    this.list.Insert(i, new EventObserverElementPriorityPair(element, priority));
                    return(i);
                }
                i++;
            }
            this.list.Add(new EventObserverElementPriorityPair(element, priority));
            return(this.list.Length - 1);
        }
Exemplo n.º 3
0
        public int IndexOf(EventObserverElementPriorityPair element)
        {
            EventObserverElementPriorityPair[] array = this.Array;
            int length = this.Length;

            for (int i = 0; i < length; i++)
            {
                if (array[i].Equals(element))
                {
                    return(i);
                }
            }
            return(-1);
        }
Exemplo n.º 4
0
        public void Add(EventObserverElementPriorityPair element)
        {
            EventObserverElementPriorityPair[] array = this.Array;
            int length   = this.Length;
            int capacity = this.Capacity;

            if (length == capacity)
            {
                int num = capacity * 2;
                EventObserverElementPriorityPair[] array2 = new EventObserverElementPriorityPair[num];
                for (int i = 0; i < length; i++)
                {
                    array2[i] = array[i];
                }
                this.Array    = array2;
                this.Capacity = num;
                array         = array2;
            }
            array[length] = element;
            this.Length++;
        }
Exemplo n.º 5
0
        public void Insert(int index, EventObserverElementPriorityPair element)
        {
            EventObserverElementPriorityPair[] array = this.Array;
            int length   = this.Length;
            int capacity = this.Capacity;

            if (length == capacity)
            {
                int num = capacity * 2;
                EventObserverElementPriorityPair[] array2 = new EventObserverElementPriorityPair[num];
                for (int i = 0; i < length; i++)
                {
                    array2[i] = array[i];
                }
                this.Array    = array2;
                this.Capacity = num;
                array         = array2;
            }
            if (index == length)
            {
                array[length] = element;
                this.Length++;
            }
            else
            {
                EventObserverElementPriorityPair eventObserverElementPriorityPair = array[index];
                array[index] = element;
                for (int j = index + 1; j < length; j++)
                {
                    EventObserverElementPriorityPair eventObserverElementPriorityPair2 = array[j];
                    array[j] = eventObserverElementPriorityPair;
                    eventObserverElementPriorityPair = eventObserverElementPriorityPair2;
                }
                array[length] = eventObserverElementPriorityPair;
                this.Length++;
            }
        }
Exemplo n.º 6
0
 public bool Equals(EventObserverElementPriorityPair other)
 {
     return(this.Element == other.Element && this.Priority == other.Priority);
 }