-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMemTable.java
53 lines (43 loc) · 1012 Bytes
/
MemTable.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
package mmn14_2;
import java.io.Serializable;
import java.util.Enumeration;
import java.util.Hashtable;
import java.util.Iterator;
public class MemTable extends Hashtable<MemTime, String> {
public MemTable() {
super();
}
public MemTable(MemTable mem) {
super();
if(mem!=null) {
Iterator<MemTime> itr = mem.iterator();
while(itr.hasNext()) {
MemTime t = itr.next();
this.put(t, mem.get(t));
}
}
}
public Iterator<MemTime> iterator() {
Iterator<MemTime> iterator =new Iterator<MemTime>() {
private Enumeration<MemTime> _enum= keys();
@Override
public void remove() {
if(this.hasNext()) {
this._enum.nextElement();
}
}
@Override
public MemTime next() {
if(!hasNext()) {
return null;
}
return this._enum.nextElement();
}
@Override
public boolean hasNext() {
return (_enum != null && this._enum.hasMoreElements());
}
};
return iterator;
}
}