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

monniasza.collects.CollectionOps Maven / Gradle / Ivy

Go to download

Dependency for the MultiMachineBuilder, a voxel game about building an industrial empire in a finite world. THIS RELEASE IS NOT PLAYABLE. To play the game, donwload from >ITCH.IO LINK HERE< or >GH releases link here<

There is a newer version: 0.6
Show newest version
/**
 * 
 */
package monniasza.collects;

import java.util.function.Predicate;

/**
 * Functional-style operations on collections
 * @author oskar
 */
public class CollectionOps {
	private CollectionOps() {}
	
	//Collection to boolean
	/**
	 * Checks if all values meet a predicate
	 * @param  type of values
	 * @param collection collection to test
	 * @param predicate condition
	 * @return do all items meet a criterion?
	 */
	public static  boolean isAll(Iterable collection, Predicate predicate) {
		for(T value: collection) 
			if(!predicate.test(value)) return false;
		return true;
	}
	/**
	 * Checks if any value meets a predicate
	 * @param  type of values
	 * @param collection collection to test
	 * @param predicate condition
	 * @return does any items meet a criterion?
	 */
	public static  boolean isAny(Iterable collection, Predicate predicate) {
		for(T value: collection) 
			if(predicate.test(value)) return true;
		return false;
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy