Class IntArrayUtils

java.lang.Object
org.apache.uima.internal.util.IntArrayUtils

public final class IntArrayUtils extends Object
Utilities used by some of the IntX classes.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static int
    binarySearch(int[] array, int ele, int start, int end)
    Binary search on a span of a sorted integer array.
    static boolean[]
    ensure_size(boolean[] array, int req, int growth_factor, int multiplication_limit)
     
    static char[]
    ensure_size(char[] array, int req, int growth_factor, int multiplication_limit)
     
    static int[]
    ensure_size(int[] array, int req)
     
    static int[]
    ensure_size(int[] array, int req, int growth_factor, int multiplication_limit)
     
    static int
    find(int x, int[] a)
    Find an int in an (unsorted) array.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • IntArrayUtils

      public IntArrayUtils()
  • Method Details

    • ensure_size

      public static int[] ensure_size(int[] array, int req)
    • ensure_size

      public static int[] ensure_size(int[] array, int req, int growth_factor, int multiplication_limit)
    • ensure_size

      public static boolean[] ensure_size(boolean[] array, int req, int growth_factor, int multiplication_limit)
    • ensure_size

      public static char[] ensure_size(char[] array, int req, int growth_factor, int multiplication_limit)
    • binarySearch

      public static int binarySearch(int[] array, int ele, int start, int end)
      Binary search on a span of a sorted integer array. If array is not sorted, results are unpredictable. If you want to search the whole array, use the version in java.util.Arrays instead; it's probably faster.
      Parameters:
      array - The input array.
      ele - The int we're looking for.
      start - Start looking at this position, where 0 ≤= start ≤= end ≤= array.length.
      end - Look up to this point (non-inclusive).
      Returns:
      The position of ele, if found; -insertPos-1, if not. insertPos is the position where ele would be inserted. Note that the return value is >= start iff ele was found; see java.util.Arrays.
    • find

      public static int find(int x, int[] a)
      Find an int in an (unsorted) array.
      Parameters:
      x - The int to find.
      a - The array.
      Returns:
      The position (first occurence) where x was found; -1 if not found.