01: /*
02: * All content copyright (c) 2003-2006 Terracotta, Inc., except as may otherwise be noted in a separate copyright notice. All rights reserved.
03: */
04: package com.tc.util;
05:
06: import com.tc.object.bytecode.ManagerUtil;
07:
08: import java.util.Iterator;
09: import java.util.Set;
10:
11: /**
12: * Since a Set is just a wrapper around a HashMap we need to use this to find out about removes from iterators on sets.
13: * This is how we are doing it.
14: */
15: public class SetIteratorWrapper implements Iterator {
16: private final Set set;
17: private final Iterator iterator;
18: private Object current;
19:
20: public SetIteratorWrapper(Iterator iterator, Set set) {
21: this .set = set;
22: this .iterator = iterator;
23: }
24:
25: public boolean hasNext() {
26: return this .iterator.hasNext();
27: }
28:
29: public Object next() {
30: current = iterator.next();
31: return current;
32: }
33:
34: public void remove() {
35: ManagerUtil.checkWriteAccess(set);
36: iterator.remove();
37: ManagerUtil.logicalInvoke(set, "remove(Ljava/lang/Object;)Z",
38: new Object[] { current });
39: }
40: }
|