Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- template <typename T>
- class SimpleVector
- {
- private:
- T* x = new T[];
- static int size;
- public:
- SimpleVector(T*, int)
- {
- };
- void push_back(int x)
- {
- this->x[size] = x;
- size++;
- }
- void getX(int size)
- {
- return x[size];
- }
- int find(T x)
- {
- int i = 0;
- while (this->x[i] != x && i < size)
- {
- i++;
- }
- if (this->x[i] != x)
- return -1;
- return i;
- }
- void remove(T x)
- {
- int i = 0;
- while (this->x[i] != x && i < size)
- {
- i++;
- }
- if (this->x[i] != x)
- return;
- for (int j = i + 1; j < size; j++)
- this->x[j - 1] = this->x[j];
- size--;
- }
- bool insert_after(int x, int y)
- {
- int i = 0;
- while (this->x[i] != y && i < size)
- {
- i++;
- }
- if (this->x[i] != y)
- return false;
- size++;
- for (int j = size - 1; j > i; j--)
- this->x[j] = this->x[j - 1];
- this->x[i] = x;
- return true;
- }
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement