-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAggregate.java
executable file
·49 lines (47 loc) · 1.53 KB
/
Aggregate.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
/**************************************************************************
* @author Mahdi Eslamimehr
* @version 0.1
***************************************************************************/
package ContractGen;
import java.util.HashSet;
import java.util.Iterator;
public class Aggregate extends HashSet {
public Aggregate(HashSet c) {
super(c);
}
public Aggregate() {
super();
}
public Aggregate(Synonym c) {
super();
add(c);
}
public void replace(Synonym replaceThis, Aggregate withThis) {
Aggregate iBecomeThis = new Aggregate();
InstField I = null;
Iterator it = iterator();
while(it.hasNext()) {
Synonym whatWas = (Synonym) it.next();
if (whatWas.equals(replaceThis)) {
iBecomeThis.addAll(withThis);
} else if (whatWas.isIfr() && (I = (InstField) whatWas.v()).base().equals(replaceThis)) {
for (Iterator wit = withThis.iterator(); wit.hasNext(); ) {
Synonym newBase = (Synonym) wit.next();
Synonym syn = new Synonym(newBase, I.field());
iBecomeThis.add(syn);
}
} else {
iBecomeThis.add(whatWas);
}
}
clear();
addAll(iBecomeThis);
}
public int hashCode() {
return super.hashCode();
}
public boolean equals(Object o) {
Aggregate a = (Aggregate) o;
return super.equals((HashSet) a);
}
}