aboutsummaryrefslogtreecommitdiff
path: root/week13/Exercise2/Vector.hpp
blob: ba66049f137510a25cd7ece2ef41b5401eded1fe (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#pragma once
#include "Indexable.hpp"
#include "Resizeable.hpp"

template <class T>
class Vector : public Indexable<T>, public Resizeable<T> {
public:
	void pop_back();
	void pop_front();
	void push_back(const T& element);
	void push_front(const T& element);
};

template <class T>
void Vector<T>::pop_back() {
	this->size--;
}

template <class T>
void Vector<T>::pop_front() {
	for (int i = 0; i < this->size - 1; i++) {
		this->arr[i] = this->arr[i+1];
	}
	this->size--;
}

template <class T>
void Vector<T>::push_back(const T& element) {
	this->InsertAt(this->size - 1, element);
}

template <class T>
void Vector<T>::push_front(const T& element) {
	this->InsertAt(0, element);
}