org.hsqldb.lib
Class ArrayUtil

java.lang.Object
  extended byorg.hsqldb.lib.ArrayUtil

public class ArrayUtil
extends java.lang.Object

Collection of static methods for operations on arrays

Author:
fredt@users

Constructor Summary
ArrayUtil()
           
 
Method Summary
static void copyAdjustArray(java.lang.Object[] source, java.lang.Object[] dest, java.lang.Object addition, int colindex, int adjust)
          Copies elements of source to dest.
static void copyArray(int[] source, int[] dest, int count)
           
static void copyColumnValues(java.lang.Object[] row, int[] colindex, java.lang.Object[] colobject)
          Copies some elements of row into colobject by using colindex as the list of indexes into row.
static int[] getAdjustedColumnArray(int[] colarr, int size, int colindex, int adjust)
          Convenience wrapper for toAdjustedColumnArray() that creates the new array.
static boolean haveCommonElement(int[] a, int[] b, int lenb)
          Checks for any overlap between two arrays of column indexes.
static boolean haveEqualArrays(int[] a, int[] b, int count)
          Returns true if the first count elements of a and b are identical subarrays of integers
static boolean haveEquality(int[] a, int[] b, int count, boolean sets)
          For sets == true returns true if a and b are the same length and contain the same set of integers.
static boolean haveEqualSets(int[] a, int[] b, int count)
          Returns true if the first count elements of a and b are identical sets of integers
static void sortArray(int[] intarr)
          Basic sort for small arrays.
static int[] toAdjustedColumnArray(int[] colarr, int colindex, int adjust)
          Returns new array with the elements in collar ajusted to reflect changes at colindex.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ArrayUtil

public ArrayUtil()
Method Detail

sortArray

public static void sortArray(int[] intarr)
Basic sort for small arrays.


haveEquality

public static boolean haveEquality(int[] a,
                                   int[] b,
                                   int count,
                                   boolean sets)
For sets == true returns true if a and b are the same length and contain the same set of integers. For sets == false returns the result of haveEqualArrays(a,b,count)


haveEqualSets

public static boolean haveEqualSets(int[] a,
                                    int[] b,
                                    int count)
Returns true if the first count elements of a and b are identical sets of integers


haveEqualArrays

public static boolean haveEqualArrays(int[] a,
                                      int[] b,
                                      int count)
Returns true if the first count elements of a and b are identical subarrays of integers


haveCommonElement

public static boolean haveCommonElement(int[] a,
                                        int[] b,
                                        int lenb)
Checks for any overlap between two arrays of column indexes. Limit check to lenb elements of b


copyArray

public static void copyArray(int[] source,
                             int[] dest,
                             int count)

copyAdjustArray

public static void copyAdjustArray(java.lang.Object[] source,
                                   java.lang.Object[] dest,
                                   java.lang.Object addition,
                                   int colindex,
                                   int adjust)
Copies elements of source to dest. If adjust is -1 the element at colindex is not copied. If adjust is +1 that element is filled with the Object addition. All the rest of the elements in source are shifted left or right accordingly when they are copied. No checks are perfomed on array sizes and an exception is thrown if they are not consistent with the other arguments.

Parameters:
source -
dest -
addition -
colindex -
adjust - +1 or 0 or -1 return new, adjusted array or null if an element is removed

toAdjustedColumnArray

public static int[] toAdjustedColumnArray(int[] colarr,
                                          int colindex,
                                          int adjust)
Returns new array with the elements in collar ajusted to reflect changes at colindex. Each element in collarr represents an index into another array otherarr. colindex is the index at which an element is added or removed form otherarr. Each element in the result array represents the new, adjusted index to otherarr. For each element of collarr that represents an index equal to colindex and adjust is -1, the result will not contain that element and will be shorter than collar by one element.

Parameters:
colarr -
colindex -
adjust - +1 or 0 or -1 return new, adjusted array

getAdjustedColumnArray

public static int[] getAdjustedColumnArray(int[] colarr,
                                           int size,
                                           int colindex,
                                           int adjust)
Convenience wrapper for toAdjustedColumnArray() that creates the new array.


copyColumnValues

public static void copyColumnValues(java.lang.Object[] row,
                                    int[] colindex,
                                    java.lang.Object[] colobject)
Copies some elements of row into colobject by using colindex as the list of indexes into row. colindex and colobject are of equal length and normally shorter than row;



Copyright © 2001 - 2002 HSQL Development Group. All Rights Reserved.