forked from leafgray/pysonar2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
TypeStack.java
47 lines (34 loc) · 1.02 KB
/
TypeStack.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
package org.python.indexer;
import java.util.ArrayList;
import java.util.List;
public class TypeStack {
class Pair {
public Object first;
public Object second;
public Pair(Object first, Object second) {
this.first = first;
this.second = second;
}
@Override
public int hashCode() {
return (first.hashCode() + second.hashCode()) / 2;
}
}
private List<Pair> stack = new ArrayList<Pair>();
public void push(Object first, Object second) {
stack.add(new Pair(first, second));
}
public void pop(Object first, Object second) {
// stack.remove(new Pair(first, second));
stack.remove(stack.size() - 1);
}
public boolean contains(Object first, Object second) {
for (Pair p : stack) {
if (p.first == first && p.second == second ||
p.first == second && p.second == first) {
return true;
}
}
return false;
}
}