|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectinfo.javelot.functionalj.util.Lists
public final class Lists
Methods concerning Collections, Lists and Sets.
| Field Summary | |
|---|---|
static Function1<Integer,Collection> |
sizeOf
|
| Method Summary | ||
|---|---|---|
static boolean[] |
asBooleanArray(Collection<Boolean> p_coll)
Returns an array of booleans from a collection of
Booleans. |
|
static byte[] |
asByteArray(Collection<Byte> p_coll)
Returns an array of bytes from a collection of
Bytes. |
|
static char[] |
asCharArray(Collection<Character> p_coll)
Returns an array of chars from a collection of
Characters. |
|
static double[] |
asDoubleArray(Collection<Double> p_coll)
Returns an array of doubles from a collection of
Doubles. |
|
static float[] |
asFloatArray(Collection<Float> p_coll)
Returns an array of floats from a collection of
Floats. |
|
static int[] |
asIntArray(Collection<Integer> p_coll)
Returns an array of ints from a collection of
Integers. |
|
static List<Boolean> |
asList(boolean... p_booleans)
Returns a List of Booleans from an array
of booleans. |
|
static List<Byte> |
asList(byte... p_bytes)
Returns a List of Bytes from an array
of bytes. |
|
static List<Character> |
asList(char... p_chars)
Returns a List of Characters from an array
of chars. |
|
static List<Double> |
asList(double... p_doubles)
Returns a List of Doubles from an array
of doubles. |
|
static List<Float> |
asList(float... p_floats)
Returns a List of Floats from an array
of floats. |
|
static List<Integer> |
asList(int... p_ints)
Returns a List of Integers from an array
of ints. |
|
static List<Long> |
asList(long... p_longs)
Returns a List of Longs from an array
of longs. |
|
static List<Short> |
asList(short... p_shorts)
Returns a List of Shorts from an array
of shorts. |
|
static List<Character> |
asList(String p_string)
Returns a List of Characters from a
String. |
|
static
|
asList(T... p_objects)
Returns a List from an array of Objects,
returning an empty List if the array is null. |
|
static long[] |
asLongArray(Collection<Long> p_coll)
Returns an array of longs from a collection of
Longs. |
|
static short[] |
asShortArray(Collection<Short> p_coll)
Returns an array of shorts from a collection of
Shorts. |
|
static Object[] |
concat(Object[] p_array1,
Object[] p_array2)
Combines two arrays of parameters into one by concatenating the two, treating null arrays as zero-length arrays. |
|
static
|
first(Collection<T> p_collection)
Returns the first element of a collection. |
|
static
|
first(T[] p_array)
Version of first(Collection) which accepts an array. |
|
static
|
init(Collection<T> p_collection)
Returns the initial of a collection, that is, all elements except the last. |
|
static
|
init(T[] p_array)
Version of init(Collection) that accepts an array. |
|
static Object[] |
initArray(Object[] p_array)
Version of init(Collection) which accepts an array and returns an
array, without using an intermediate Collection. |
|
static
|
iterable(Collection<? extends T> p_coll)
Returns the Iterable for the specified collection, or an
empty Iterable if the collection is null, to avoid
NullPointerExceptions. |
|
static
|
iterable(T[] p_array)
Returns the Iterable for the specified array, or an empty
Iterable if the array is null, to avoid
NullPointerExceptions. |
|
static
|
iterator(Collection<? extends T> p_coll)
Returns the Iterator for the specified collection, or an
empty iterator if the collection is null, to avoid
NullPointerExceptions. |
|
static
|
iterator(T[] p_array)
Returns the Iterator for the specified array, or an empty
iterator if the array is null, to avoid
NullPointerExceptions. |
|
static
|
last(Collection<T> p_collection)
Returns the last element of a collection. |
|
static
|
last(T[] p_array)
Version of last(Collection) that accepts an array. |
|
static int |
sizeOf(Collection p_collection)
Returns the size of a collection, returning zero if the list is null. |
|
static
|
sizeOf(T... p_array)
Returns the size of a array, returning zero if the array is null. |
|
static
|
splitAt(int p_index,
List<T> p_list)
Splits a list in two at the specified index, returning a pair of lists. |
|
static
|
splitAt(int p_index,
T[] p_array)
Version of splitAt(int, List) that accepts an array. |
|
static Pair<Object[],Object[]> |
splitAtArray(int p_index,
Object[] p_array)
Version of splitAt(int, List) that accepts an array and returns a
Pair of arrays, without using an intermediate Collection. |
|
static
|
tail(Collection<T> p_collection)
Returns the tail of a collection, that is, all elements except the first. |
|
static
|
tail(T[] p_array)
Version of tail(Collection) which accepts an array. |
|
static Object[] |
tailArray(Object[] p_array)
Version of tail(Collection) which accepts an array and returns an
array, without using an intermediate Collection. |
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final Function1<Integer,Collection> sizeOf
| Method Detail |
|---|
public static <T> T first(Collection<T> p_collection)
throws FunctionException
p_collection - the collection for which to return the first element.
FunctionException - thrown if the collection is null or
empty.
public static <T> T first(T[] p_array)
throws FunctionException
first(Collection) which accepts an array.
FunctionExceptionpublic static <T> T last(Collection<T> p_collection)
p_collection - the list for which to return the last element.
FunctionException - thrown if the collection is null or
empty.public static <T> T last(T[] p_array)
last(Collection) that accepts an array.
public static <T> List<T> init(Collection<T> p_collection)
p_collection - the collection for which to return the initial part.
public static <T> List<T> init(T[] p_array)
init(Collection) that accepts an array.
public static Object[] initArray(Object[] p_array)
init(Collection) which accepts an array and returns an
array, without using an intermediate Collection.
public static <T> List<T> tail(Collection<T> p_collection)
p_collection - the collection for which to return the tail.
public static <T> List<T> tail(T[] p_array)
tail(Collection) which accepts an array.
public static Object[] tailArray(Object[] p_array)
tail(Collection) which accepts an array and returns an
array, without using an intermediate Collection.
public static <T> Pair<List<T>,List<T>> splitAt(int p_index,
List<T> p_list)
Particular cases:
public static <T> Pair<List<T>,List<T>> splitAt(int p_index,
T[] p_array)
splitAt(int, List) that accepts an array.
public static Pair<Object[],Object[]> splitAtArray(int p_index,
Object[] p_array)
splitAt(int, List) that accepts an array and returns a
Pair of arrays, without using an intermediate Collection.
public static int sizeOf(Collection p_collection)
null.
p_collection - the collection for which to return the size.
0 if the collection is
null.public static <T> int sizeOf(T... p_array)
null.
p_array - the array for which to return the size.
0 if the array is
null.public static <T> List<T> asList(T... p_objects)
List from an array of Objects,
returning an empty List if the array is null.
p_objects - the array of Objects to be converted to
a List.
List of Objects.public static List<Boolean> asList(boolean... p_booleans)
List of Booleans from an array
of booleans. Returns an empty list if the array is
null.
p_booleans - the array of boolean values to be converted to
a List.
List of
Boolean objects.public static List<Byte> asList(byte... p_bytes)
List of Bytes from an array
of bytes. Returns an empty list if the array is
null.
p_bytes - the array of byte values to be converted to a
List.
List of Byte objects.public static List<Character> asList(char... p_chars)
List of Characters from an array
of chars. Returns an empty list if the array is
null.
p_chars - the array of char values to be converted to a
List.
List of Character objects.public static List<Double> asList(double... p_doubles)
List of Doubles from an array
of doubles. Returns an empty list if the array is
null.
p_doubles - the array of double values to be converted to a
List.
List of Double objects.public static List<Float> asList(float... p_floats)
List of Floats from an array
of floats. Returns an empty list if the array is
null.
p_floats - the array of float values to be converted to a
List.
List of Float objects.public static List<Integer> asList(int... p_ints)
List of Integers from an array
of ints. Returns an empty list if the array is
null.
p_ints - the array of int values to be converted to a
List.
List of Integer objects.public static List<Long> asList(long... p_longs)
List of Longs from an array
of longs. Returns an empty list if the array is
null.
p_longs - the array of long values to be converted to a
List.
List of Long objects.public static List<Short> asList(short... p_shorts)
List of Shorts from an array
of shorts. Returns an empty list if the array is
null.
p_shorts - the array of short values to be converted to a
List.
List of Short objects.public static List<Character> asList(String p_string)
List of Characters from a
String. Returns an empty list if the string is
null.
p_string - the String to be converted to a
List.
List of Character objects.
public static Object[] concat(Object[] p_array1,
Object[] p_array2)
p_array1 - the first array.p_array2 - the second array.
public static boolean[] asBooleanArray(Collection<Boolean> p_coll)
booleans from a collection of
Booleans.
Returns an empty array if the collection is null.
p_coll - the collection of Booleans to be converted to an
array of booleans.
booleans.public static byte[] asByteArray(Collection<Byte> p_coll)
bytes from a collection of
Bytes.
Returns an empty array if the collection is null.
p_coll - the collection of Bytes to be converted to an
array of bytes.
bytes.public static char[] asCharArray(Collection<Character> p_coll)
chars from a collection of
Characters.
Returns an empty array if the collection is null.
p_coll - the collection of Characters to be converted to an
array of chars.
chars.public static double[] asDoubleArray(Collection<Double> p_coll)
doubles from a collection of
Doubles.
Returns an empty array if the collection is null.
p_coll - the collection of Doubles to be converted to an
array of doubles.
doubles.public static float[] asFloatArray(Collection<Float> p_coll)
floats from a collection of
Floats.
Returns an empty array if the collection is null.
p_coll - the collection of Floats to be converted to an
array of floats.
doubles.public static int[] asIntArray(Collection<Integer> p_coll)
ints from a collection of
Integers.
Returns an empty array if the collection is null.
p_coll - the collection of Integers to be converted to an
array of ints.
ints.public static long[] asLongArray(Collection<Long> p_coll)
longs from a collection of
Longs.
Returns an empty array if the collection is null.
p_coll - the collection of Longs to be converted to an
array of longs.
longs.public static short[] asShortArray(Collection<Short> p_coll)
shorts from a collection of
Shorts.
Returns an empty array if the collection is null.
p_coll - the collection of Shorts to be converted to an
array of shorts.
shorts.public static <T> Iterator<? extends T> iterator(Collection<? extends T> p_coll)
Iterator for the specified collection, or an
empty iterator if the collection is null, to avoid
NullPointerExceptions.
public static <T> Iterator<T> iterator(T[] p_array)
Iterator for the specified array, or an empty
iterator if the array is null, to avoid
NullPointerExceptions.
public static <T> Iterable<? extends T> iterable(Collection<? extends T> p_coll)
Iterable for the specified collection, or an
empty Iterable if the collection is null, to avoid
NullPointerExceptions.
public static <T> Iterable<T> iterable(T[] p_array)
Iterable for the specified array, or an empty
Iterable if the array is null, to avoid
NullPointerExceptions.
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||