Pimeko

Untitled

Apr 13th, 2014
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.79 KB | None | 0 0
  1.  
  2.         public void Insert(T elt)
  3.         {
  4.             T[] newArray = new T[nbElements * 2];
  5.             for (int i = 0; i < nbElements; i++)
  6.             {
  7.                 newArray[i] = array[i];
  8.             }
  9.             array = newArray;
  10.  
  11.  
  12.             array[nbElements] = elt;
  13.             nbElements++;
  14.         }
  15.  
  16.         public bool Delete(T elt)
  17.         {
  18.             int index = 0;
  19.             while (!array[index].Equals(elt))
  20.                 index++;
  21.  
  22.             if (index < nbElements)
  23.             {
  24.                 for (int i = index; i < nbElements; i++)
  25.                     array[i] = array[i + 1];
  26.                 nbElements--;
  27.                 return true;
  28.             }
  29.  
  30.             else
  31.             {
  32.                 return false;
  33.             }
  34.         }
Advertisement
Add Comment
Please, Sign In to add comment