-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMapa.java
137 lines (113 loc) · 2.79 KB
/
Mapa.java
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
import java.util.*;
public class Mapa implements Data, VLS, VL, VLSM{
public Map<Data,Data> map;
public Mapa() {
map = new HashMap<Data,Data>();
}
public int size(){return map.size();}
public void addDataMap(Data key,Data data){ map.put(key,data); }
@Override
public void addData(Data a) {
}
@Override
public Data functionget(Data element, Data defecto) {
if (defecto!=null )
return defecto;
if(map.containsKey(element))
return map.get(element);
return new Nil();
}
public void addDataLista(Data data){ }
@Override
public Boolean contains(Data element) {
for (Data x:map.keySet()){
if(x.equals(element))
return true;
}
return false;
}
public Object getData(){ return map; }
public void setData(Object l) {
map = ((Map<Data,Data>) (l));
}
@Override
public String toString() {
return map.toString();
}
public Data getDataWithget(Data element) {
for (Data x:map.keySet()){
if(x.equals(element))
return map.get(element);
}
return null;
}
@Override
public boolean equals(Object o) {
if (!(o instanceof Mapa))
return false;
Mapa aux = (Mapa) o;
if(aux.size()!=map.size())
return false;
for (Data x:map.keySet()) {
if (!aux.contains(x))
return false;
if (!aux.getDataWithget(x).equals(map.get(x)))
return false;
}
return true;
}
@Override
public int hashCode() {
return map.hashCode();
}
@Override
public Data getDataWithNTH(Integer n) {
return null;
}
@Override
public double suma() {
return 0;
}
@Override
public double restar() {
return 0;
}
@Override
public double multiplicar() {
return 0;
}
@Override
public double dividir() {
return 0;
}
@Override
public Data functionfirst() {
Mapa mapa = new Mapa();
if (map.size()!=0)
for (Data x:map.keySet()){
mapa.addDataMap(x,map.get(x));
return mapa;
}
return null;
}
@Override
public List<Data> copyData() {
ArrayList<Data> a = new ArrayList<>();
Vector vector;
for(Data data : map.keySet()){
vector = new Vector();
vector.addData(data);
vector.addData(map.get(data));
a.add(vector);
}
return a;
}
@Override
public Object clone() {
try {
return super.clone();
} catch (Exception e){
return null;
}
}
}