All Downloads are FREE. Search and download functionalities are using the official Maven repository.

stonehorse.grit.map.EntrySet Maven / Gradle / Ivy

Go to download

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;
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy