at.chrl.nutils.CollectionUtils Maven / Gradle / Ivy
The newest version!
/**
* (C) ChRL 2014 - chrl-utils - at.chrl.nutils - CollectionUtils.java Created:
* 02.08.2014 - 11:48:00
*/
package at.chrl.nutils;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Deque;
import java.util.List;
import java.util.Map;
import java.util.Queue;
import java.util.Set;
import java.util.WeakHashMap;
import java.util.concurrent.ConcurrentHashMap;
import java.util.function.Supplier;
import java.util.stream.Collectors;
import java.util.stream.IntStream;
import gnu.trove.map.hash.THashMap;
import gnu.trove.set.hash.THashSet;
/**
* @author Vinzynth
*
*/
public final class CollectionUtils {
private CollectionUtils() {
}
/**
* Returns a capacity that is sufficient to keep the map from being resized
* as long as it grows no larger than expectedSize and the load factor is >=
* its default (0.75).
*/
public static int capacity(int expectedSize) {
return (int) ((expectedSize / 0.75) + 1);
}
public static Supplier