Example #1
0
 //метод увеличивает размер массива на 1
 private void IncreaseLength()
 {
     TCollectionItem[] tmp = new TCollectionItem[PCollection.Length + 1];
     Array.Copy(PCollection, 0, tmp, 0, PCollection.Length);
     PCollection = tmp;
     Length      = PCollection.Length - 1;
 }
Example #2
0
 //поиск индекса элемента по значению элемента
 public int Search(TCollectionItem elem)
 {
     for (int i = 0; i < PCollection.Length; i++)
     {
         if (PCollection[i].Equals(elem))
         {
             return(i);
         }
     }
     Console.WriteLine("Элемент не найден :(");
     return(-1);
 }
Example #3
0
        //удаление по индексу
        public void Delete(int index)
        {
            TCollectionItem[] tmp = new TCollectionItem[PCollection.Length - 1];
            int j = 0;

            for (int i = 0; i < PCollection.Length; i++)
            {
                if (i != index)
                {
                    tmp[j].Value = PCollection[i].Value;
                    j++;
                }
            }
            PCollection = tmp;
            Length--;
        }
Example #4
0
        //вставка по индексу
        public void Add(TCollectionItem elem, int index)
        {
            IncreaseLength();
            if (!IsInside(index))
                index = PCollection.Length;
            if (PCollection.Length > 1)
            {
                for (int i = PCollection.Length - 2; i > index + 1; i--)
                {
                    PCollection[i + 1].Value = PCollection[i].Value;
                }
                PCollection[index + 1].Value = elem;
            }
            else
            {

                PCollection[index].Value = elem;
            }
        }
Example #5
0
 //вставка по индексу
 public void Add(TCollectionItem elem, int index)
 {
     IncreaseLength();
     if (!IsInside(index))
     {
         index = PCollection.Length;
     }
     if (PCollection.Length > 1)
     {
         for (int i = PCollection.Length - 2; i > index + 1; i--)
         {
             PCollection[i + 1].Value = PCollection[i].Value;
         }
         PCollection[index + 1].Value = elem;
     }
     else
     {
         PCollection[index].Value = elem;
     }
 }
Example #6
0
 //метод увеличивает размер массива на 1
 private void IncreaseLength()
 {
     TCollectionItem[] tmp = new TCollectionItem[PCollection.Length + 1];
     Array.Copy(PCollection, 0, tmp, 0, PCollection.Length);
     PCollection = tmp;
     Length = PCollection.Length - 1;
 }
Example #7
0
 //поиск индекса элемента по значению элемента
 public int Search(TCollectionItem elem)
 {
     for (int i = 0; i < PCollection.Length; i++)
     {
         if (PCollection[i].Equals(elem))
         {
             return i;
         }
     }
     Console.WriteLine("Элемент не найден :(");
     return -1;
 }
Example #8
0
 //удаление по индексу
 public void Delete(int index)
 {
     TCollectionItem[] tmp = new TCollectionItem[PCollection.Length - 1];
     int j = 0;
     for (int i = 0; i < PCollection.Length; i++)
     {
         if (i != index)
         {
             tmp[j].Value = PCollection[i].Value;
             j++;
         }
     }
     PCollection = tmp;
     Length--;
 }