public final class CollectionUtils
extends java.lang.Object
Compatibility: Public
Modifier and Type | Method and Description |
---|---|
static <E> FastCollection<E> |
emptyFastCollection()
Create an empty, immutable fast collection.
|
static <E> java.lang.Iterable<E> |
fast(java.lang.Iterable<E> iter)
Use the fast iterator of an iterable, if available.
|
static <E> FastIterable<E> |
fastFilterAndLimit(java.lang.Iterable<E> iter,
Predicate<? super E> pred,
int limit)
Fast-aware filter-and-limit operation, filtering an iterable.
|
static IntList |
interval(int from,
int to)
Create an
IntList that contains all numbers in a specified interval. |
static <E> ObjectCollection<E> |
objectCollection(java.util.Collection<E> objects)
Wrap a
Collection in an ObjectCollection . |
static <T> java.util.List<T> |
repeat(T obj,
int n)
Return a list that repeats a single object multiple times.
|
public static <E> java.lang.Iterable<E> fast(java.lang.Iterable<E> iter)
E
- The type of object to iterate.iter
- An iterable to wrapfastIterator()
method, like is present in Long2DoubleMap.FastEntrySet
.public static <E> FastIterable<E> fastFilterAndLimit(java.lang.Iterable<E> iter, Predicate<? super E> pred, int limit)
E
- The type of data in the iterable.iter
- The iterable to filter and limit.pred
- The predicate for filtering.limit
- The maximum number of items to return (negative for unlimited).public static <E> ObjectCollection<E> objectCollection(java.util.Collection<E> objects)
Collection
in an ObjectCollection
.E
- The type of objects.objects
- The collection of objects.ObjectCollection
.public static <T> java.util.List<T> repeat(T obj, int n)
T
- The type of list elements.obj
- The object.n
- The size of the list.public static <E> FastCollection<E> emptyFastCollection()
E
- The type of fast collection.