Sha256: 8e4469e1326f1ae4d8cbfd964ca54e0fcbf8b3cc613c73ed50bf15346a37c7a1

Contents?: true

Size: 638 Bytes

Versions: 396

Compression:

Stored size: 638 Bytes

Contents

import java.util.ArrayList;
import java.util.List;
import java.util.function.Predicate;

public class Strain {

	public static <T> List<T> keep(List<T> collection, Predicate<T> predicate) {
		return filter(collection, predicate);
	}

	public static <T> List<T> discard(List<T> collection, Predicate<T> predicate) {
		return filter(collection, predicate.negate());
	}

	public static <T> List<T> filter(List<T> collection, Predicate<T> predicate) {
		List<T> filteredCollection = new ArrayList<>();

		for (T item : collection) {
			if (predicate.test(item)) {
				filteredCollection.add(item);
			}
		}

		return filteredCollection;
	}
}

Version data entries

396 entries across 396 versions & 1 rubygems

Version Path
trackler-2.2.1.180 tracks/java/exercises/strain/.meta/src/reference/java/Strain.java
trackler-2.2.1.179 tracks/java/exercises/strain/.meta/src/reference/java/Strain.java
trackler-2.2.1.178 tracks/java/exercises/strain/.meta/src/reference/java/Strain.java
trackler-2.2.1.177 tracks/java/exercises/strain/.meta/src/reference/java/Strain.java
trackler-2.2.1.176 tracks/java/exercises/strain/.meta/src/reference/java/Strain.java
trackler-2.2.1.175 tracks/java/exercises/strain/.meta/src/reference/java/Strain.java
trackler-2.2.1.174 tracks/java/exercises/strain/.meta/src/reference/java/Strain.java
trackler-2.2.1.173 tracks/java/exercises/strain/.meta/src/reference/java/Strain.java
trackler-2.2.1.172 tracks/java/exercises/strain/.meta/src/reference/java/Strain.java
trackler-2.2.1.171 tracks/java/exercises/strain/.meta/src/reference/java/Strain.java
trackler-2.2.1.170 tracks/java/exercises/strain/.meta/src/reference/java/Strain.java
trackler-2.2.1.169 tracks/java/exercises/strain/.meta/src/reference/java/Strain.java
trackler-2.2.1.167 tracks/java/exercises/strain/.meta/src/reference/java/Strain.java
trackler-2.2.1.166 tracks/java/exercises/strain/.meta/src/reference/java/Strain.java
trackler-2.2.1.165 tracks/java/exercises/strain/.meta/src/reference/java/Strain.java
trackler-2.2.1.164 tracks/java/exercises/strain/.meta/src/reference/java/Strain.java
trackler-2.2.1.163 tracks/java/exercises/strain/.meta/src/reference/java/Strain.java
trackler-2.2.1.162 tracks/java/exercises/strain/.meta/src/reference/java/Strain.java
trackler-2.2.1.161 tracks/java/exercises/strain/.meta/src/reference/java/Strain.java
trackler-2.2.1.160 tracks/java/exercises/strain/.meta/src/reference/java/Strain.java