|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.lucene.util.ArrayUtil
public final class ArrayUtil
Methods for manipulating arrays.
Constructor Summary | |
---|---|
ArrayUtil()
Deprecated. This constructor was not intended to be public and should not be used. This class contains solely a static utility methods. It will be made private in Lucene 4.0 |
Method Summary | ||
---|---|---|
static boolean |
equals(char[] left,
int offsetLeft,
char[] right,
int offsetRight,
int length)
See if two array slices are the same. |
|
static boolean |
equals(int[] left,
int offsetLeft,
int[] right,
int offsetRight,
int length)
See if two array slices are the same. |
|
static int |
getShrinkSize(int currentSize,
int targetSize,
int bytesPerElement)
|
|
static boolean[] |
grow(boolean[] array)
|
|
static boolean[] |
grow(boolean[] array,
int minSize)
|
|
static byte[] |
grow(byte[] array)
|
|
static byte[] |
grow(byte[] array,
int minSize)
|
|
static char[] |
grow(char[] array)
|
|
static char[] |
grow(char[] array,
int minSize)
|
|
static float[] |
grow(float[] array)
|
|
static float[] |
grow(float[] array,
int minSize)
|
|
static int[] |
grow(int[] array)
|
|
static int[] |
grow(int[] array,
int minSize)
|
|
static long[] |
grow(long[] array)
|
|
static long[] |
grow(long[] array,
int minSize)
|
|
static short[] |
grow(short[] array)
|
|
static short[] |
grow(short[] array,
int minSize)
|
|
static int |
hashCode(byte[] array,
int start,
int end)
Returns hash of bytes in range start (inclusive) to end (inclusive) |
|
static int |
hashCode(char[] array,
int start,
int end)
Returns hash of chars in range start (inclusive) to end (inclusive) |
|
static
|
insertionSort(T[] a)
Sorts the given array in natural order. |
|
static
|
insertionSort(T[] a,
Comparator<? super T> comp)
Sorts the given array using the Comparator . |
|
static
|
insertionSort(T[] a,
int fromIndex,
int toIndex)
Sorts the given array slice in natural order. |
|
static
|
insertionSort(T[] a,
int fromIndex,
int toIndex,
Comparator<? super T> comp)
Sorts the given array slice using the Comparator . |
|
static
|
mergeSort(T[] a)
Sorts the given array in natural order. |
|
static
|
mergeSort(T[] a,
Comparator<? super T> comp)
Sorts the given array using the Comparator . |
|
static
|
mergeSort(T[] a,
int fromIndex,
int toIndex)
Sorts the given array slice in natural order. |
|
static
|
mergeSort(T[] a,
int fromIndex,
int toIndex,
Comparator<? super T> comp)
Sorts the given array slice using the Comparator . |
|
static int |
oversize(int minTargetSize,
int bytesPerElement)
Returns an array size >= minTargetSize, generally over-allocating exponentially to achieve amortized linear-time cost as the array grows. |
|
static int |
parseInt(char[] chars)
Parses the string argument as if it was an int value and returns the result. |
|
static int |
parseInt(char[] chars,
int offset,
int len)
Parses a char array into an int. |
|
static int |
parseInt(char[] chars,
int offset,
int len,
int radix)
Parses the string argument as if it was an int value and returns the result. |
|
static
|
quickSort(T[] a)
Sorts the given array in natural order. |
|
static
|
quickSort(T[] a,
Comparator<? super T> comp)
Sorts the given array using the Comparator . |
|
static
|
quickSort(T[] a,
int fromIndex,
int toIndex)
Sorts the given array slice in natural order. |
|
static
|
quickSort(T[] a,
int fromIndex,
int toIndex,
Comparator<? super T> comp)
Sorts the given array slice using the Comparator . |
|
static boolean[] |
shrink(boolean[] array,
int targetSize)
|
|
static byte[] |
shrink(byte[] array,
int targetSize)
|
|
static char[] |
shrink(char[] array,
int targetSize)
|
|
static int[] |
shrink(int[] array,
int targetSize)
|
|
static long[] |
shrink(long[] array,
int targetSize)
|
|
static short[] |
shrink(short[] array,
int targetSize)
|
|
static int[] |
toIntArray(Collection<Integer> ints)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
@Deprecated public ArrayUtil()
Method Detail |
---|
public static int parseInt(char[] chars) throws NumberFormatException
chars
- a string representation of an int quantity.
NumberFormatException
- if the argument could not be parsed as an int quantity.public static int parseInt(char[] chars, int offset, int len) throws NumberFormatException
chars
- the character arrayoffset
- The offset into the arraylen
- The length
NumberFormatException
- if it can't parsepublic static int parseInt(char[] chars, int offset, int len, int radix) throws NumberFormatException
chars
- a string representation of an int quantity.radix
- the base to use for conversion.
NumberFormatException
- if the argument could not be parsed as an int quantity.public static int oversize(int minTargetSize, int bytesPerElement)
minTargetSize
- Minimum required value to be returned.bytesPerElement
- Bytes used by each element of
the array. See constants in RamUsageEstimator
.public static int getShrinkSize(int currentSize, int targetSize, int bytesPerElement)
public static short[] grow(short[] array, int minSize)
public static short[] grow(short[] array)
public static float[] grow(float[] array, int minSize)
public static float[] grow(float[] array)
public static short[] shrink(short[] array, int targetSize)
public static int[] grow(int[] array, int minSize)
public static int[] grow(int[] array)
public static int[] shrink(int[] array, int targetSize)
public static long[] grow(long[] array, int minSize)
public static long[] grow(long[] array)
public static long[] shrink(long[] array, int targetSize)
public static byte[] grow(byte[] array, int minSize)
public static byte[] grow(byte[] array)
public static byte[] shrink(byte[] array, int targetSize)
public static boolean[] grow(boolean[] array, int minSize)
public static boolean[] grow(boolean[] array)
public static boolean[] shrink(boolean[] array, int targetSize)
public static char[] grow(char[] array, int minSize)
public static char[] grow(char[] array)
public static char[] shrink(char[] array, int targetSize)
public static int hashCode(char[] array, int start, int end)
public static int hashCode(byte[] array, int start, int end)
public static boolean equals(char[] left, int offsetLeft, char[] right, int offsetRight, int length)
left
- The left array to compareoffsetLeft
- The offset into the array. Must be positiveright
- The right array to compareoffsetRight
- the offset into the right array. Must be positivelength
- The length of the section of the array to compare
Arrays.equals(char[], char[])
public static boolean equals(int[] left, int offsetLeft, int[] right, int offsetRight, int length)
left
- The left array to compareoffsetLeft
- The offset into the array. Must be positiveright
- The right array to compareoffsetRight
- the offset into the right array. Must be positivelength
- The length of the section of the array to compare
Arrays.equals(char[], char[])
public static int[] toIntArray(Collection<Integer> ints)
public static <T> void quickSort(T[] a, int fromIndex, int toIndex, Comparator<? super T> comp)
Comparator
. This method uses the quick sort
algorithm, but falls back to insertion sort for small arrays.
fromIndex
- start index (inclusive)toIndex
- end index (exclusive)public static <T> void quickSort(T[] a, Comparator<? super T> comp)
Comparator
. This method uses the quick sort
algorithm, but falls back to insertion sort for small arrays.
public static <T extends Comparable<? super T>> void quickSort(T[] a, int fromIndex, int toIndex)
fromIndex
- start index (inclusive)toIndex
- end index (exclusive)public static <T extends Comparable<? super T>> void quickSort(T[] a)
public static <T> void mergeSort(T[] a, int fromIndex, int toIndex, Comparator<? super T> comp)
Comparator
. This method uses the merge sort
algorithm, but falls back to insertion sort for small arrays.
fromIndex
- start index (inclusive)toIndex
- end index (exclusive)public static <T> void mergeSort(T[] a, Comparator<? super T> comp)
Comparator
. This method uses the merge sort
algorithm, but falls back to insertion sort for small arrays.
public static <T extends Comparable<? super T>> void mergeSort(T[] a, int fromIndex, int toIndex)
fromIndex
- start index (inclusive)toIndex
- end index (exclusive)public static <T extends Comparable<? super T>> void mergeSort(T[] a)
public static <T> void insertionSort(T[] a, int fromIndex, int toIndex, Comparator<? super T> comp)
Comparator
. This method uses the insertion sort
algorithm. It is only recommended to use this algorithm for partially sorted small arrays!
fromIndex
- start index (inclusive)toIndex
- end index (exclusive)public static <T> void insertionSort(T[] a, Comparator<? super T> comp)
Comparator
. This method uses the insertion sort
algorithm. It is only recommended to use this algorithm for partially sorted small arrays!
public static <T extends Comparable<? super T>> void insertionSort(T[] a, int fromIndex, int toIndex)
fromIndex
- start index (inclusive)toIndex
- end index (exclusive)public static <T extends Comparable<? super T>> void insertionSort(T[] a)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |