org.melati.poem.util
Class ArrayUtils

Package class diagram package ArrayUtils
java.lang.Object
  extended by org.melati.poem.util.ArrayUtils

public final class ArrayUtils
extends Object

A collection of useful operations on Arrays.


Method Summary
static Object[] added(Object[] xs, Object y)
          Add an Object to an Array.
static Object[] arrayOf(Enumeration e)
          Create an Array from an Enumeration.
static Object[] arrayOf(Vector v)
          Create an Array from a Vector.
static Object[] concatenated(Object[] xs, Object[] ys)
          Create a new Array from two Arrays.
static boolean contains(Object[] xs, Object x)
          Whether an Array contains an Object.
static int indexOf(Object[] xs, Object x)
          Lookup the first instance of an Object in an Array.
static Object[] removed(Object[] xs, Object y)
          Remove an Object from an Array.
static Object[] section(Object[] xs, int start, int limit)
          Extract a subsection of an Array.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

arrayOf

public static Object[] arrayOf(Vector v)
Create an Array from a Vector.

Parameters:
v - the Vector
Returns:
the Array

arrayOf

public static Object[] arrayOf(Enumeration e)
Create an Array from an Enumeration.

Parameters:
e - the Enumeration
Returns:
the Array

added

public static Object[] added(Object[] xs,
                             Object y)
Add an Object to an Array.

Parameters:
xs - the array to add to
y - the object to add
Returns:
the enlarged array

removed

public static Object[] removed(Object[] xs,
                               Object y)
Remove an Object from an Array.

Parameters:
xs - the array to remove from
y - the object to remove
Returns:
the reduced array

concatenated

public static Object[] concatenated(Object[] xs,
                                    Object[] ys)
Create a new Array from two Arrays.

Parameters:
xs - first Array
ys - second Array
Returns:
a new Array with the elements of the second appended to the first

section

public static Object[] section(Object[] xs,
                               int start,
                               int limit)
Extract a subsection of an Array.

Parameters:
xs - the input Array
start - the index in the original array to start our section, inclusive
limit - the index in the original array to stop at, inclusive
Returns:
the new Array

indexOf

public static int indexOf(Object[] xs,
                          Object x)
Lookup the first instance of an Object in an Array.

Parameters:
xs - the Array to search
x - the Object to check
Returns:
the index of the first equal object

contains

public static boolean contains(Object[] xs,
                               Object x)
Whether an Array contains an Object.

Parameters:
xs - the Array to search
x - the Object to check
Returns:
whether it is there or not


Copyright © 2000-2010 PanEris. All Rights Reserved.