info.javelot.functionalj.util
Class Lists

java.lang.Object
  extended byinfo.javelot.functionalj.util.Lists

public final class Lists
extends Object

Methods concerning Lists.

Author:
Copyright © 2006 Frederic Daoud

Method Summary
static List asList(boolean[] p_booleans)
          Returns a List of Booleans from an array of booleans.
static List asList(byte[] p_bytes)
          Returns a List of Bytes from an array of bytes.
static List asList(char[] p_chars)
          Returns a List of Characters from an array of chars.
static List asList(double[] p_doubles)
          Returns a List of Doubles from an array of doubles.
static List asList(float[] p_floats)
          Returns a List of Floats from an array of floats.
static List asList(int[] p_ints)
          Returns a List of Integers from an array of ints.
static List asList(long[] p_longs)
          Returns a List of Longs from an array of longs.
static List asList(Object[] p_objects)
          Returns a List from an array of Objects, returning an empty List if the array is null.
static List asList(short[] p_shorts)
          Returns a List of Shorts from an array of shorts.
static List asList(String p_string)
          Returns a List of Characters from a String.
static Object head(List p_list)
          Returns the head (first) element of a list.
static List init(List p_list)
          Returns the initial of a list, that is, all elements except the last.
static Iterator iterator(List p_list)
          Returns the Iterator for the specified list, or an empty iterator if the list is null, to avoid NullPointerExceptions.
static Object last(List p_list)
          Returns the last element of a list.
static int sizeOf(List p_list)
          Returns the size of a list, returning zero if the list is null.
static int sizeOf(Object[] p_array)
          Returns the size of a array, returning zero if the array is null.
static int sizeOf(String p_string)
          Returns the size of a string, returning zero if the string is null.
static List tail(List p_list)
          Returns the tail of a list, that is, all elements except the first.
static int[] toIntArray(List p_list)
          Returns an array of ints from a List of Integers.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

head

public static Object head(List p_list)
                   throws FunctionException
Returns the head (first) element of a list.

Parameters:
p_list - the list for which to return the head element.
Returns:
the head (first) element of the list.
Throws:
FunctionException - thrown if the list is null or empty.

tail

public static List tail(List p_list)
Returns the tail of a list, that is, all elements except the first.

Parameters:
p_list - the list for which to return the tail.
Returns:
all elements of the list except the first, or an empty list if the specified list is empty.

init

public static List init(List p_list)
Returns the initial of a list, that is, all elements except the last.

Parameters:
p_list - the list for which to return the initial part.
Returns:
all elements of the list except the last, or an empty list if the specified list is empty.

last

public static Object last(List p_list)
Returns the last element of a list.

Parameters:
p_list - the list for which to return the last element.
Returns:
the last element of the list.
Throws:
FunctionException - thrown if the list is null or empty.

asList

public static List asList(Object[] p_objects)
Returns a List from an array of Objects, returning an empty List if the array is null.

Parameters:
p_objects - the array of Objects to be converted to a List.
Returns:
a List of Objects.

asList

public static List asList(boolean[] p_booleans)
Returns a List of Booleans from an array of booleans.

Parameters:
p_booleans - the array of boolean values to be converted to a List.
Returns:
a List of Boolean objects.

asList

public static List asList(byte[] p_bytes)
Returns a List of Bytes from an array of bytes.

Parameters:
p_bytes - the array of byte values to be converted to a List.
Returns:
a List of Byte objects.

asList

public static List asList(char[] p_chars)
Returns a List of Characters from an array of chars.

Parameters:
p_chars - the array of char values to be converted to a List.
Returns:
a List of Character objects.

asList

public static List asList(double[] p_doubles)
Returns a List of Doubles from an array of doubles.

Parameters:
p_doubles - the array of double values to be converted to a List.
Returns:
a List of Double objects.

asList

public static List asList(float[] p_floats)
Returns a List of Floats from an array of floats.

Parameters:
p_floats - the array of float values to be converted to a List.
Returns:
a List of Float objects.

asList

public static List asList(int[] p_ints)
Returns a List of Integers from an array of ints.

Parameters:
p_ints - the array of int values to be converted to a List.
Returns:
a List of Integer objects.

asList

public static List asList(long[] p_longs)
Returns a List of Longs from an array of longs.

Parameters:
p_longs - the array of long values to be converted to a List.
Returns:
a List of Long objects.

asList

public static List asList(short[] p_shorts)
Returns a List of Shorts from an array of shorts.

Parameters:
p_shorts - the array of short values to be converted to a List.
Returns:
a List of Short objects.

asList

public static List asList(String p_string)
Returns a List of Characters from a String.

Parameters:
p_string - the String to be converted to a List.
Returns:
a List of Character objects.

sizeOf

public static int sizeOf(List p_list)
Returns the size of a list, returning zero if the list is null.

Parameters:
p_list - the list for which to return the size.
Returns:
the size of the list, or 0 if the list is null.

sizeOf

public static int sizeOf(Object[] p_array)
Returns the size of a array, returning zero if the array is null.

Parameters:
p_array - the array for which to return the size.
Returns:
the size of the array, or 0 if the array is null.

sizeOf

public static int sizeOf(String p_string)
Returns the size of a string, returning zero if the string is null.

Parameters:
p_string - the string for which to return the size.
Returns:
the size of the string, or 0 if the string is null.

toIntArray

public static int[] toIntArray(List p_list)
Returns an array of ints from a List of Integers.

Parameters:
p_list - the list of Integers to be converted to an array of ints.
Returns:
an array of ints.

iterator

public static Iterator iterator(List p_list)
Returns the Iterator for the specified list, or an empty iterator if the list is null, to avoid NullPointerExceptions.