marf.util
Class Arrays

java.lang.Object
  |
  +--marf.util.Arrays

public class Arrays
extends java.lang.Object

Extension of java.util.Arrays to allow copying array portions.

NOTE: it does not actually inherit (extend) from java.util.Arrays, but rather wraps existing methods, plus adds the copy() wrappers of System.arraycopy(). TODO: Implement/reconsider missing methods for different types. TODO: Document.

$Id: Arrays.java,v 1.15 2005/06/04 23:51:05 mokhov Exp $

Since:
0.3.0
Version:
$Revision: 1.15 $
Author:
Serguei Mokhov
See Also:
Arrays, System.arraycopy(Object, int, Object, int, int)

Constructor Summary
protected Arrays()
          TODO: should we allow it? For what reason?
 
Method Summary
static java.util.Vector arrayToVector(double[] padData)
          Converts array of doubles to Vector.
static java.util.Vector arrayToVector(int[] paiData)
          Converts array of ints to Vector.
static java.util.List asList(java.lang.Object[] paoObjects)
          Provides an array-of-objects-to-List bridge.
static void copy(double[] padDestination, double[] padSource, int piHowMany)
          Copies N double elements from source to destination.
static void copy(double[] padDestination, int piStartIndex, double[] padSource)
          Copies source to destination starting at certain index in the destination.
static void copy(double[] padDestination, int piStartIndex, double[] padSource, int piHowMany)
          Copies N double elements from source to destination starting at certain index in the destination.
static void copy(double[] padDestination, int piDestinationStartIndex, double[] padSource, int piSourceStartIndex, int piHowMany)
          Copies N double elements from source to destination starting at certain index in the destination.
static void copy(int[] paiDestination, int[] paiSource, int piHowMany)
          Copies N int elements from source to destination.
static void copy(java.lang.Object[] paoDestination, int piDestinationStartIndex, java.lang.Object[] paoSource, int piSourceStartIndex, int piHowMany)
          Generic copy() routine based on System.arraycopy().
static void copy(java.lang.Object poDestination, int piDestinationStartIndex, java.lang.Object poSource, int piSourceStartIndex, int piHowMany)
          Generic copy() routine based on System.arraycopy().
static boolean equals(boolean[] a, boolean[] a2)
           
static boolean equals(byte[] a, byte[] a2)
           
static boolean equals(char[] a, char[] a2)
           
static boolean equals(double[] a, double[] a2)
           
static boolean equals(float[] a, float[] a2)
           
static boolean equals(int[] a, int[] a2)
           
static boolean equals(long[] a, long[] a2)
           
static boolean equals(java.lang.Object[] a, java.lang.Object[] a2)
           
static boolean equals(short[] a, short[] a2)
           
static void fill(boolean[] a, boolean val)
           
static void fill(boolean[] a, int fromIndex, int toIndex, boolean val)
           
static void fill(byte[] a, byte val)
           
static void fill(byte[] a, int fromIndex, int toIndex, byte val)
           
static void fill(char[] a, char val)
           
static void fill(char[] a, int fromIndex, int toIndex, char val)
           
static void fill(double[] a, double val)
           
static void fill(double[] a, int fromIndex, int toIndex, double val)
           
static void fill(float[] a, float val)
           
static void fill(float[] a, int fromIndex, int toIndex, float val)
           
static void fill(int[] a, int val)
           
static void fill(int[] a, int fromIndex, int toIndex, int val)
           
static void fill(long[] a, int fromIndex, int toIndex, long val)
           
static void fill(long[] a, long val)
           
static void fill(java.lang.Object[] a, int fromIndex, int toIndex, java.lang.Object val)
           
static void fill(java.lang.Object[] a, java.lang.Object val)
           
static void fill(short[] a, int fromIndex, int toIndex, short val)
           
static void fill(short[] a, short val)
           
static java.lang.String getRevision()
          Returns source code revision information.
static void sort(double[] padArrayToSort)
          A wrapper of java.util.Arrays.sort(double[]).
static void sort(java.lang.Object[] paoArrayToSort, java.util.Comparator poComparator)
          A wrapper of java.util.Arrays.sort(Object[], Comparator).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Arrays

protected Arrays()
TODO: should we allow it? For what reason?

Method Detail

copy

public static void copy(java.lang.Object poDestination,
                        int piDestinationStartIndex,
                        java.lang.Object poSource,
                        int piSourceStartIndex,
                        int piHowMany)
Generic copy() routine based on System.arraycopy(). TODO: should I just keep this copy() to be consistent with our API?

Parameters:
poDestination - destination array of copy
piDestinationStartIndex - where in the destination array start placing the values
poSource - source of elements
piSourceStartIndex - where in the source array start copying the values from
piHowMany - how many elements should be copied from the source to destination

copy

public static void copy(java.lang.Object[] paoDestination,
                        int piDestinationStartIndex,
                        java.lang.Object[] paoSource,
                        int piSourceStartIndex,
                        int piHowMany)
Generic copy() routine based on System.arraycopy(). TODO: is it very much redundant?

Parameters:
paoDestination - destination array of objects to copy to
piDestinationStartIndex - where in the destination array start placing the values
paoSource - source of Object elements
piSourceStartIndex - where in the source array start copying the values from
piHowMany - how many elements should be copied from the source to destination

copy

public static void copy(double[] padDestination,
                        int piDestinationStartIndex,
                        double[] padSource,
                        int piSourceStartIndex,
                        int piHowMany)
Copies N double elements from source to destination starting at certain index in the destination. A wrapper call to System.arraycopy().

Parameters:
padDestination - array to copy to
piDestinationStartIndex - starting index in the destination to start copying to
padSource - array of doubles to copy from
piSourceStartIndex - starting index in the source to start copying from
piHowMany - N; the number of elements to copy from the source to the destination

copy

public static void copy(double[] padDestination,
                        int piStartIndex,
                        double[] padSource,
                        int piHowMany)
Copies N double elements from source to destination starting at certain index in the destination.

Parameters:
padDestination - array to copy to
piStartIndex - starting index in the destination to start copying to
padSource - array of doubles to copy from
piHowMany - N; the number of elements to copy from the source to the destination

copy

public static void copy(double[] padDestination,
                        int piStartIndex,
                        double[] padSource)
Copies source to destination starting at certain index in the destination.

Parameters:
padDestination - array to copy to
piStartIndex - starting index in the destination to start copying to
padSource - array of doubles to copy from

copy

public static void copy(double[] padDestination,
                        double[] padSource,
                        int piHowMany)
Copies N double elements from source to destination.

Parameters:
padDestination - array to copy to
padSource - array of doubles to copy from
piHowMany - N; the number of elements to copy from the source to the destination

copy

public static void copy(int[] paiDestination,
                        int[] paiSource,
                        int piHowMany)
Copies N int elements from source to destination.

Parameters:
paiDestination - array to copy to
paiSource - array of ints to copy from
piHowMany - N; the number of elements to copy from the source to the destination

equals

public static boolean equals(boolean[] a,
                             boolean[] a2)

equals

public static boolean equals(byte[] a,
                             byte[] a2)

equals

public static boolean equals(char[] a,
                             char[] a2)

equals

public static boolean equals(double[] a,
                             double[] a2)

equals

public static boolean equals(float[] a,
                             float[] a2)

equals

public static boolean equals(int[] a,
                             int[] a2)

equals

public static boolean equals(long[] a,
                             long[] a2)

equals

public static boolean equals(java.lang.Object[] a,
                             java.lang.Object[] a2)

equals

public static boolean equals(short[] a,
                             short[] a2)

fill

public static void fill(boolean[] a,
                        boolean val)

fill

public static void fill(boolean[] a,
                        int fromIndex,
                        int toIndex,
                        boolean val)

fill

public static void fill(byte[] a,
                        byte val)

fill

public static void fill(byte[] a,
                        int fromIndex,
                        int toIndex,
                        byte val)

fill

public static void fill(char[] a,
                        char val)

fill

public static void fill(char[] a,
                        int fromIndex,
                        int toIndex,
                        char val)

fill

public static void fill(double[] a,
                        double val)

fill

public static void fill(double[] a,
                        int fromIndex,
                        int toIndex,
                        double val)

fill

public static void fill(float[] a,
                        float val)

fill

public static void fill(float[] a,
                        int fromIndex,
                        int toIndex,
                        float val)

fill

public static void fill(int[] a,
                        int val)

fill

public static void fill(int[] a,
                        int fromIndex,
                        int toIndex,
                        int val)

fill

public static void fill(long[] a,
                        int fromIndex,
                        int toIndex,
                        long val)

fill

public static void fill(long[] a,
                        long val)

fill

public static void fill(java.lang.Object[] a,
                        int fromIndex,
                        int toIndex,
                        java.lang.Object val)

fill

public static void fill(java.lang.Object[] a,
                        java.lang.Object val)

fill

public static void fill(short[] a,
                        int fromIndex,
                        int toIndex,
                        short val)

fill

public static void fill(short[] a,
                        short val)

sort

public static void sort(java.lang.Object[] paoArrayToSort,
                        java.util.Comparator poComparator)
A wrapper of java.util.Arrays.sort(Object[], Comparator).

Parameters:
paoArrayToSort - array of objects to sort
poComparator - comparator object to use while sorting

sort

public static void sort(double[] padArrayToSort)
A wrapper of java.util.Arrays.sort(double[]).

Parameters:
padArrayToSort - array of doubles to sort

arrayToVector

public static java.util.Vector arrayToVector(double[] padData)
Converts array of doubles to Vector.

Parameters:
padData - array of double data
Returns:
equivalent collection of Double objects

arrayToVector

public static java.util.Vector arrayToVector(int[] paiData)
Converts array of ints to Vector.

Parameters:
paiData - array of int data
Returns:
equivalent collection of Integer objects

asList

public static java.util.List asList(java.lang.Object[] paoObjects)
Provides an array-of-objects-to-List bridge. Wraps java.util.Arrays.asList().

Parameters:
paoObjects - array of objects
Returns:
corresponding List collection

getRevision

public static java.lang.String getRevision()
Returns source code revision information.

Returns:
revision string