-
Notifications
You must be signed in to change notification settings - Fork 0
/
itor_vector.h
54 lines (37 loc) · 890 Bytes
/
itor_vector.h
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#ifndef ITOR_VECTOR_H
#define ITOR_VECTOR_H
#include "Itor.h"
template <typename T> class vector;
template <typename T>
class Itor_vector : public Itor<T> {
public:
vector<T>& v;
size_t index;
Itor_vector<T>(vector<T>& vec) : v{vec} {
index = 0;
}
Itor_vector(vector<T>& vec, size_t size) : v{vec}{
index = size;
}
T* first() {
return &v[0];
}
// Указатель на следующий элемент
virtual T* next() {
return &v[index+1];
}
bool operator!=(const Itor_vector<T>& other) const{
return index != other.index;
}
bool operator==(const Itor<T>& other) const{
return index == other.index;
}
Itor_vector<T>& operator++(){
++index;
return *this;
}
T& operator*() const{
return v[index];
}
};
#endif // ITOR_VECTOR_H