Advertisement
Guest User

Untitled

a guest
May 27th, 2016
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.76 KB | None | 0 0
  1. void DinamycList::Add(Equipment _path)
  2. {
  3. list[position] = _path;
  4.  
  5. position++;
  6. if (position == size)
  7. {
  8. Equipment *temp = new Equipment[size];
  9. for (int i = 0; i < position; i++)
  10. temp[i] = list[i];
  11.  
  12.  
  13. delete[] list;
  14. size *= 1.5;
  15. list = new Equipment[size];
  16.  
  17. for (int i = 0; i < position; i++)
  18. list[i] = temp[i];
  19. }
  20. }
  21.  
  22.  
  23.  
  24. void DinamycList::Erase(int _id)
  25. {
  26. for (int i = _id; i < position; i++)
  27. list[i] = list[i + 1];
  28. position--;
  29.  
  30.  
  31. if (size / 1.5 >= position)
  32. {
  33. size /= 1.5;
  34. Equipment *temp = new Equipment[size];
  35. for (int i = 0; i < position; i++)
  36. temp[i] = list[i];
  37.  
  38.  
  39. delete[] list;
  40. list = new Equipment[size];
  41. for (int i = 0; i < position; i++)
  42. list[i] = temp[i];
  43. delete[] temp;
  44. }
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement