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

org.psjava.util.SingleElementCollection Maven / Gradle / Ivy

There is a newer version: 0.1.19
Show newest version
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