Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void pushback (T x)
- {
- size += 1;
- if (size >= capacity) {
- reallocate(capacity*2);
- capacity = capacity*2;
- }
- data[size++] = x;
- }
- void reallocate(size_t s)
- {
- if (s < capacity)
- {
- std::cout << "what are you doing mazafuka" << std::endl;
- return;
- }
- T* data_new = new T[s];
- for(int it = 0; it != size ; ++it)
- {
- data_new[it] = data[it];
- }
- data = data_new;
- delete[] data;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement