Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.basex.util
Class Array

    java.lang.Object
      org.basex.util.Array

    public final class Array

extends java.lang.Object

This class provides convenience methods for handling arrays.

Author:
  Workgroup DBIS, University of Konstanz 2005-09, ISC License, Christian Gruen

Field Summary
`static int[]` | `NOINTS` Empty integer array.
`static int[][]` | `NOINTS2` Empty integer array.

Method Summary
`static byte[][]` | `add(byte[][] ar, byte[] e)` Resizes an array and adds an entry at the end.
`static byte[]` | `add(byte[] ar, byte[] e, int s0, int s1)` Resizes an array and adds an entry at the end.
`static int[]` | `add(int[] ar, int e)` Resizes an array and adds an entry at the end.
`static
`<T> T[]`
` | `add(T[] ar, T e)` Resizes an array and adds an entry at the end.
`static
`<T> T[]`
` | `check(T[] ar, int s)` Doubles the array size if necessary.
`static void` | `copy(byte[] src, byte[] trg, int s)` Copies the source token into the target token.
`static void` | `copy(java.lang.Object[] src, java.lang.Object[] trg, int s)` Copies the source array into the target array, starting from the specified offset.
`static byte[]` | `create(byte[] src, int pos, int len)` Creates a new array from the source array and with the specified length.
`static int[]` | `createOrder(byte[][] tok, boolean num, boolean asc)` Sorts the specified tokens and returns an integer array with offsets to of the sorted tokens.
`static int[]` | `createOrder(double[] tok, boolean asc)` Sorts the specified numeric tokens and returns an integer array with offsets to of the sorted tokens.
`static
`<T> T[]`
` | `delete(T[] ar, int p)` Removes an array entry at the specified position.
`static boolean` | `eq(byte[] i1, byte[] i2)` Checks two byte arrays for equality.
`static boolean` | `eq(int[] i1, int[] i2)` Checks two int arrays for equality.
`static boolean[]` | `extend(boolean[] ar)` Doubles the array size.
`static byte[]` | `extend(byte[] ar)` Doubles the array size.
`static byte[][]` | `extend(byte[][] ar)` Doubles the array size.
`static int[]` | `extend(int[] ar)` Doubles the array size.
`static int[][]` | `extend(int[][] ar)` Doubles the array size.
`static long[]` | `extend(long[] ar)` Doubles the array size.
`static java.lang.String[]` | `extend(java.lang.String[] ar)` Doubles the array size.
`static
`<T> T[]`
` | `extend(T[] ar)` Doubles the array size.
`static boolean[]` | `finish(boolean[] ar, int size)` Optimizes the array size.
`static byte[][]` | `finish(byte[][] ar, int size)` Optimizes the array size.
`static byte[]` | `finish(byte[] ar, int size)` Optimizes the array size.
`static double[]` | `finish(double[] ar, int size)` Optimizes the array size.
`static int[]` | `finish(int[] ar, int size)` Optimizes the array size.
`static java.lang.String[]` | `finish(java.lang.String[] ar, int size)` Optimizes the array size.
`static
`<T> T[]`
` | `finish(T[] ar, int size)` Optimizes the array size.
`static void` | `move(java.lang.Object ar, int pos, int off, int l)` Moves entries inside an array.
`static boolean[]` | `resize(boolean[] ar, int os, int ns)` Convenience method for resizing a boolean array.
`static byte[][]` | `resize(byte[][] ar, int os, int ns)` Convenience method for resizing a two-dimensional byte array.
`static byte[]` | `resize(byte[] ar, int os, int ns)` Convenience method for resizing a byte array.
`static double[]` | `resize(double[] ar, int os, int ns)` Convenience method for resizing a double array.
`static int[][]` | `resize(int[][] ar, int os, int ns)` Convenience method for resizing an integer array.
`static int[]` | `resize(int[] ar, int os, int ns)` Convenience method for resizing an integer array.
`static long[]` | `resize(long[] ar, int os, int ns)` Convenience method for resizing an integer array.
`static java.lang.String[]` | `resize(java.lang.String[] ar, int os, int ns)` Convenience method for resizing a String array.
`static
`<T> T[]`
` | `resize(T[] ar, int os, int ns)` Convenience method for resizing a generic array.

Methods inherited from class java.lang.Object
`equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### NOINTS

    public static final int[] NOINTS

  Empty integer array.

### NOINTS2

    public static final int[][] NOINTS2

  Empty integer array.

Method Detail

### extend

    public static boolean[] extend(boolean[] ar)

  Doubles the array size.

  Parameters:
    `ar` - array to be resized
  Returns:
    finished array

### extend

    public static int[] extend(int[] ar)

  Doubles the array size.

  Parameters:
    `ar` - array to be resized
  Returns:
    finished array

### extend

    public static int[][] extend(int[][] ar)

  Doubles the array size.

  Parameters:
    `ar` - array to be resized
  Returns:
    finished array

### extend

    public static long[] extend(long[] ar)

  Doubles the array size.

  Parameters:
    `ar` - array to be resized
  Returns:
    finished array

### extend

    public static byte[] extend(byte[] ar)

  Doubles the array size.

  Parameters:
    `ar` - array to be resized
  Returns:
    finished array

### extend

    public static byte[][] extend(byte[][] ar)

  Doubles the array size.

  Parameters:
    `ar` - array to be resized
  Returns:
    finished array

### extend

    public static java.lang.String[] extend(java.lang.String[] ar)

  Doubles the array size.

  Parameters:
    `ar` - array to be resized
  Returns:
    finished array

### extend

    public static <T> T[] extend(T[] ar)

  Doubles the array size.

  Type Parameters:
    `T` - array type
  Parameters:
    `ar` - array to be resized
  Returns:
    array

### check

    public static <T> T[] check(T[] ar,
                                int s)

  Doubles the array size if necessary.

  Type Parameters:
    `T` - array type
  Parameters:
    `ar` - array to be resized
    `s` - array size
  Returns:
    array

### add

    public static byte[][] add(byte[][] ar,
                               byte[] e)

  Resizes an array and adds an entry at the end.

  Parameters:
    `ar` - array to be resized
    `e` - entry to be added
  Returns:
    finished array

### add

    public static byte[] add(byte[] ar,
                             byte[] e,
                             int s0,
                             int s1)

  Resizes an array and adds an entry at the end.

  Parameters:
    `ar` - array to be resized
    `e` - entry to be added
    `s0` - start position in e
    `s1` - end position in e
  Returns:
    finished array

### add

    public static int[] add(int[] ar,
                            int e)

  Resizes an array and adds an entry at the end.

  Parameters:
    `ar` - array to be resized
    `e` - entry to be added
  Returns:
    finished array

### add

    public static <T> T[] add(T[] ar,
                              T e)

  Resizes an array and adds an entry at the end.

  Type Parameters:
    `T` - array type
  Parameters:
    `ar` - array to be resized
    `e` - entry to be added
  Returns:
    array

### finish

    public static int[] finish(int[] ar,
                               int size)

  Optimizes the array size.

  Parameters:
    `ar` - array to be resized
    `size` - final size
  Returns:
    finished array

### finish

    public static double[] finish(double[] ar,
                                  int size)

  Optimizes the array size.

  Parameters:
    `ar` - array to be resized
    `size` - final size
  Returns:
    finished array

### finish

    public static java.lang.String[] finish(java.lang.String[] ar,
                                            int size)

  Optimizes the array size.

  Parameters:
    `ar` - array to be resized
    `size` - final size
  Returns:
    finished array

### finish

    public static boolean[] finish(boolean[] ar,
                                   int size)

  Optimizes the array size.

  Parameters:
    `ar` - array to be resized
    `size` - final size
  Returns:
    finished array

### finish

    public static byte[] finish(byte[] ar,
                                int size)

  Optimizes the array size.

  Parameters:
    `ar` - array to be resized
    `size` - final size
  Returns:
    finished array

### finish

    public static byte[][] finish(byte[][] ar,
                                  int size)

  Optimizes the array size.

  Parameters:
    `ar` - array to be resized
    `size` - final size
  Returns:
    finished array

### finish

    public static <T> T[] finish(T[] ar,
                                 int size)

  Optimizes the array size.

  Type Parameters:
    `T` - array type
  Parameters:
    `ar` - array to be resized
    `size` - final size
  Returns:
    array

### resize

    public static java.lang.String[] resize(java.lang.String[] ar,
                                            int os,
                                            int ns)

  Convenience method for resizing a String array.

  Parameters:
    `ar` - array to be resized
    `os` - old size
    `ns` - new size
  Returns:
    resized array

### resize

    public static int[] resize(int[] ar,
                               int os,
                               int ns)

  Convenience method for resizing an integer array.

  Parameters:
    `ar` - array to be resized
    `os` - old size
    `ns` - new size
  Returns:
    resized array

### resize

    public static double[] resize(double[] ar,
                                  int os,
                                  int ns)

  Convenience method for resizing a double array.

  Parameters:
    `ar` - array to be resized
    `os` - old size
    `ns` - new size
  Returns:
    resized array

### resize

    public static int[][] resize(int[][] ar,
                                 int os,
                                 int ns)

  Convenience method for resizing an integer array.

  Parameters:
    `ar` - array to be resized
    `os` - old size
    `ns` - new size
  Returns:
    resized array

### resize

    public static long[] resize(long[] ar,
                                int os,
                                int ns)

  Convenience method for resizing an integer array.

  Parameters:
    `ar` - array to be resized
    `os` - old size
    `ns` - new size
  Returns:
    resized array

### resize

    public static boolean[] resize(boolean[] ar,
                                   int os,
                                   int ns)

  Convenience method for resizing a boolean array.

  Parameters:
    `ar` - array to be resized
    `os` - old size
    `ns` - new size
  Returns:
    resized array

### resize

    public static byte[] resize(byte[] ar,
                                int os,
                                int ns)

  Convenience method for resizing a byte array.

  Parameters:
    `ar` - array to be resized
    `os` - old size
    `ns` - new size
  Returns:
    resized array

### resize

    public static byte[][] resize(byte[][] ar,
                                  int os,
                                  int ns)

  Convenience method for resizing a two-dimensional byte array.

  Parameters:
    `ar` - array to be resized
    `os` - old size
    `ns` - new size
  Returns:
    resized array

### resize

    public static <T> T[] resize(T[] ar,
                                 int os,
                                 int ns)

  Convenience method for resizing a generic array.

  Type Parameters:
    `T` - array type
  Parameters:
    `ar` - array to be resized
    `os` - old size
    `ns` - new size
  Returns:
    array

### copy

    public static void copy(byte[] src,
                            byte[] trg,
                            int s)

  Copies the source token into the target token.

  Parameters:
    `src` - source array
    `trg` - target array
    `s` - start position

### copy

    public static void copy(java.lang.Object[] src,
                            java.lang.Object[] trg,
                            int s)

  Copies the source array into the target array, starting from the specified offset.

  Parameters:
    `src` - source array
    `trg` - target array
    `s` - start position

### eq

    public static boolean eq(int[] i1,
                             int[] i2)

  Checks two int arrays for equality.

  Parameters:
    `i1` - first array
    `i2` - second array
  Returns:
    result of check

### eq

    public static boolean eq(byte[] i1,
                             byte[] i2)

  Checks two byte arrays for equality.

  Parameters:
    `i1` - first array
    `i2` - second array
  Returns:
    result of check

### create

    public static byte[] create(byte[] src,
                                int pos,
                                int len)

  Creates a new array from the source array and with the specified length.

  Parameters:
    `src` - source array
    `pos` - array position
    `len` - array length
  Returns:
    new array

### move

    public static void move(java.lang.Object ar,
                            int pos,
                            int off,
                            int l)

  Moves entries inside an array.

  Parameters:
    `ar` - array
    `pos` - position
    `off` - move offset
    `l` - length

### delete

    public static <T> T[] delete(T[] ar,
                                 int p)

  Removes an array entry at the specified position.

  Type Parameters:
    `T` - array type
  Parameters:
    `ar` - array to be resized
    `p` - position
  Returns:
    array

### createOrder

    public static int[] createOrder(byte[][] tok,
                                    boolean num,
                                    boolean asc)

  Sorts the specified tokens and returns an integer array with offsets to of the sorted tokens.

  Parameters:
    `tok` - token array to sort by
    `num` - numeric sort
    `asc` - ascending
  Returns:
    sorted integer array

### createOrder

    public static int[] createOrder(double[] tok,
                                    boolean asc)

  Sorts the specified numeric tokens and returns an integer array with offsets to of the sorted tokens.

  Parameters:
    `tok` - token array to sort by
    `asc` - ascending
  Returns:
    sorted integer array

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD