dev.marksman.collectionviews.EmptySet Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of collection-views Show documentation
Show all versions of collection-views Show documentation
Low overhead, protected views over Java collections
package dev.marksman.collectionviews;
import java.util.Iterator;
import static java.util.Collections.emptyIterator;
final class EmptySet extends ConcreteSet implements ImmutableSet, Primitive {
private static final EmptySet> INSTANCE = new EmptySet<>();
@Override
public int size() {
return 0;
}
@Override
public boolean contains(A element) {
return false;
}
@Override
public Iterator iterator() {
return emptyIterator();
}
@SuppressWarnings("unchecked")
static EmptySet emptySet() {
return (EmptySet) INSTANCE;
}
}