Advertisement
FIDANzza

Untitled

Jan 19th, 2018
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.52 KB | None | 0 0
  1. template< class T > struct TArray
  2. {
  3. public:
  4. T* Data;
  5. int Count;
  6. int Max;
  7.  
  8. public:
  9. TArray()
  10. {
  11. Data = NULL;
  12. Count = Max = 0;
  13. };
  14.  
  15. public:
  16. int Num()
  17. {
  18. return this->Count;
  19. };
  20.  
  21. T& operator() (int i)
  22. {
  23. return this->Data[i];
  24. };
  25.  
  26. const T& operator() (int i) const
  27. {
  28. return this->Data[i];
  29. };
  30.  
  31. void Add(T InputData)
  32. {
  33. Data = (T*)realloc(Data, sizeof(T) * (Count + 1));
  34. Data[Count++] = InputData;
  35. Max = Count;
  36. };
  37.  
  38. void Clear()
  39. {
  40. free(Data);
  41. Count = Max = 0;
  42. };
  43. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement