org.psjava.util.SingleElementCollection Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of psjava Show documentation
Show all versions of psjava Show documentation
Problem Solving Library for Java
package org.psjava.util;
import java.util.Iterator;
import org.psjava.ds.Collection;
public class SingleElementCollection {
public static Collection create(final T value) {
return new Collection() {
@Override
public boolean isEmpty() {
return false;
}
@Override
public Iterator iterator() {
return SingleElementIterator.create(value);
}
@Override
public int size() {
return 1;
}
};
}
private SingleElementCollection() {
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy