: Class Arrays

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

## weiss.util
Class Arrays

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

public class Arrays
extends java.lang.Object

Instanceless class that contains static methods to manipulate arrays.

Method Summary
`static int` | `binarySearch(java.lang.Object[] arr, java.lang.Object x)` Performs a search on sorted array arr.
`static int` | `binarySearch(java.lang.Object[] arr, java.lang.Object x, Comparator cmp)` Performs a search on sorted array arr using a comparator.

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

Method Detail

### binarySearch

    public static int binarySearch(java.lang.Object[] arr,
                                   java.lang.Object x)

  Performs a search on sorted array arr. If arr is not sorted, results are undefined. Implicitly, this assumes that all objects are Comparable.
  Parameters:
    `arr` - the array to search.
    `x` - the object to search for.
  Returns:
    if x is found, returns the index where it is found. otherwise, x is not found. In that case, a negative number is always returned, and this number is equal to -( p + 1 ), which p is the first position greater than x. This can range from -1 down to -(arr.length+1).
  Throws:
    `java.lang.ClassCastException` - if comparsions cannot be performed.

### binarySearch

    public static int binarySearch(java.lang.Object[] arr,
                                   java.lang.Object x,
                                   Comparator cmp)

  Performs a search on sorted array arr using a comparator. If arr is not sorted, results are undefined.
  Parameters:
    `arr` - the array to search.
    `x` - the object to search for.
    `cmp` - the comparator.
  Returns:
    if x is found, returns the index where it is found. otherwise, x is not found. In that case, a negative number is always returned, and this number is equal to -( p + 1 ), which p is the first position greater than x. This can range from -1 down to -(arr.length+1).
  Throws:
    `java.lang.ClassCastException` - if comparsions cannot be performed.

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