Beispiel #1
0
        private void Swap(int i, int j)
        {
            ArrayListItem ci = GetItem(i);
            ArrayListItem cj = GetItem(j);

            Figure temp = ci.data;

            ci.data = cj.data;
            cj.data = temp;
        }
Beispiel #2
0
        public IEnumerator GetEnumerator()
        {
            ArrayListItem current = this.first;

            //Перебор элементов
            while (current != null)
            {
                //Возврат текущего значения
                yield return(current.data);

                //Переход к следующему элементу
                current = current.next;
            }
        }
Beispiel #3
0
        public ArrayListItem GetItem(int number)
        {
            if ((number < 0) || (number >= this.Count))
            {
                throw new Exception("Выход за границу индекса");
            }
            ArrayListItem current = this.first;
            int           i       = 0;

            while (i < number)
            {
                current = current.next;
                i++;
            }
            return(current);
        }
Beispiel #4
0
        public void Add(Figure element)
        {
            ArrayListItem newItem = new ArrayListItem(element);

            this.Count++;

            if (last == null)
            {
                this.first = newItem;
                this.last  = newItem;
            }

            else
            {
                this.last.next = newItem;
                this.last      = newItem;
            }
        }