stonehorse.grit.map.EntrySet Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of grit Show documentation
Show all versions of grit Show documentation
Persistent Collections for Java. Immutable
containers with mutation as expression
The newest version!
package stonehorse.grit.map;
import java.util.AbstractSet;
import java.util.Iterator;
import java.util.Map.Entry;
final class EntrySet extends AbstractSet> {
private final APMap apMap;
EntrySet(APMap apMap) {
this.apMap = apMap;
}
public Iterator> iterator() {
final Iterator> i = apMap.iterator();
return new Iterator>() {
@Override public boolean hasNext() {
return i.hasNext();
}
@Override public Entry next() {
return i.next();
}
};
}
@Override public int size() {
return apMap.size();
}
@Override public int hashCode() {
return apMap.hashCode();
}
@Override public boolean contains(Object o) {
if (o instanceof Entry) {
Entry, ?> e = (Entry, ?>) o;
if (this.apMap.has(e.getKey())) {
Object value = this.apMap.get(e.getKey());
if (value == e.getValue())
return true;
if (value == null)
return false;
return value.equals(e.getValue());
}
}
return false;
}
}