Esempio n. 1
0
        public void GetElementPriority(int i, out SmartEntity element, out int priority)
        {
            SmartEntityElementPriorityPair smartEntityElementPriorityPair = this.list.Array[i];

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

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

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

            if (length == capacity)
            {
                int num = capacity * 2;
                SmartEntityElementPriorityPair[] array2 = new SmartEntityElementPriorityPair[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++;
        }
Esempio n. 5
0
        public void Insert(int index, SmartEntityElementPriorityPair element)
        {
            SmartEntityElementPriorityPair[] array = this.Array;
            int length   = this.Length;
            int capacity = this.Capacity;

            if (length == capacity)
            {
                int num = capacity * 2;
                SmartEntityElementPriorityPair[] array2 = new SmartEntityElementPriorityPair[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
            {
                SmartEntityElementPriorityPair smartEntityElementPriorityPair = array[index];
                array[index] = element;
                for (int j = index + 1; j < length; j++)
                {
                    SmartEntityElementPriorityPair smartEntityElementPriorityPair2 = array[j];
                    array[j] = smartEntityElementPriorityPair;
                    smartEntityElementPriorityPair = smartEntityElementPriorityPair2;
                }
                array[length] = smartEntityElementPriorityPair;
                this.Length++;
            }
        }
Esempio n. 6
0
 public bool Equals(SmartEntityElementPriorityPair other)
 {
     return(this.Element == other.Element && this.Priority == other.Priority);
 }