-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathIterador.h
75 lines (61 loc) · 1.08 KB
/
Iterador.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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#ifndef ITERADOR_H
#define ITERADOR_H
#include <iostream>
using namespace std;
template <class T>
class Iterador {
private:
Iterador<T> *ref;
protected:
Iterador() {
ref = NULL;
}
public:
Iterador(const Iterador<T> &it) {
ref = NULL;
*this = it;
}
virtual Iterador &operator=(const Iterador<T> &it) {
if (this != &it) {
delete ref;
ref = it.Clon();
}
return *this;
}
virtual Iterador<T> *Clon() const {
if (ref == NULL) {
Iterador<T> *it = new Iterador<T>();
return it;
}
else
return ref->Clon();
}
virtual ~Iterador() {
delete this->ref;
}
virtual const T &Elemento() const {
return ref->Elemento();
}
virtual void Resto() {
ref->Resto();
}
virtual bool EsFin() const {
return ref->EsFin();
}
virtual void Principio() {
ref->Principio();
}
virtual const T &operator ++() {
Resto();
return Elemento();
}
virtual const T &operator ++(int) {
const T &ant = Elemento();
Resto();
return ant;
}
virtual const T &operator*() {
return Elemento();
}
};
#endif