Class ArrayUtil
Methods for manipulating arrays.
Note
This API is for internal purposes only and might change in incompatible ways in the next release.
Inherited Members
Namespace: Lucene.Net.Util
Assembly: Lucene.Net.dll
Syntax
public static class ArrayUtil
Fields
MAX_ARRAY_LENGTH
Maximum length for an array; we set this to "a bit" below MaxValue because the exact max allowed byte[] is JVM dependent, so we want to avoid a case where a large value worked during indexing on one JVM but failed later at search time with a different JVM.
Declaration
public static readonly int MAX_ARRAY_LENGTH
Field Value
| Type | Description |
|---|---|
| int |
Methods
Equals(byte[], int, byte[], int, int)
See if two array slices are the same.
Declaration
public static bool Equals(byte[] left, int offsetLeft, byte[] right, int offsetRight, int length)
Parameters
| Type | Name | Description |
|---|---|---|
| byte[] | left | The left array to compare |
| int | offsetLeft | The offset into the array. Must be positive |
| byte[] | right | The right array to compare |
| int | offsetRight | the offset into the right array. Must be positive |
| int | length | The length of the section of the array to compare |
Returns
| Type | Description |
|---|---|
| bool |
|
See Also
Equals(char[], int, char[], int, int)
See if two array slices are the same.
Declaration
public static bool Equals(char[] left, int offsetLeft, char[] right, int offsetRight, int length)
Parameters
| Type | Name | Description |
|---|---|---|
| char[] | left | The left array to compare |
| int | offsetLeft | The offset into the array. Must be positive |
| char[] | right | The right array to compare |
| int | offsetRight | the offset into the right array. Must be positive |
| int | length | The length of the section of the array to compare |
Returns
| Type | Description |
|---|---|
| bool |
|
See Also
Equals(int[], int, int[], int, int)
See if two array slices are the same.
Declaration
public static bool Equals(int[] left, int offsetLeft, int[] right, int offsetRight, int length)
Parameters
| Type | Name | Description |
|---|---|---|
| int[] | left | The left array to compare |
| int | offsetLeft | The offset into the array. Must be positive |
| int[] | right | The right array to compare |
| int | offsetRight | the offset into the right array. Must be positive |
| int | length | The length of the section of the array to compare |
Returns
| Type | Description |
|---|---|
| bool |
|
See Also
GetHashCode(byte[], int, int)
Returns hash of bytes in range start (inclusive) to end (inclusive)
Declaration
public static int GetHashCode(byte[] array, int start, int end)
Parameters
| Type | Name | Description |
|---|---|---|
| byte[] | array | |
| int | start | |
| int | end |
Returns
| Type | Description |
|---|---|
| int |
GetHashCode(char[], int, int)
Returns hash of chars in range start (inclusive) to end (inclusive)
Declaration
public static int GetHashCode(char[] array, int start, int end)
Parameters
| Type | Name | Description |
|---|---|---|
| char[] | array | |
| int | start | |
| int | end |
Returns
| Type | Description |
|---|---|
| int |
GetNaturalComparer<T>()
Get the natural IComparer<T> for the provided object class.
The comparer returned depends on the- If the type is string, the comparer returned uses the CompareOrdinal(string, string) to make the comparison to ensure that the current culture doesn't affect the results. This is the default string comparison used in Java, and what Lucene's design depends on.
- If the type implements IComparable<T>, the comparer uses CompareTo(T) for the comparison. This allows the use of types with custom comparison schemes.
- If neither of the above conditions are true, will default to Default.
Declaration
public static IComparer<T> GetNaturalComparer<T>()
Returns
| Type | Description |
|---|---|
| IComparer<T> |
Type Parameters
| Name | Description |
|---|---|
| T |
GetShrinkSize(int, int, int)
Methods for manipulating arrays.
Note
This API is for internal purposes only and might change in incompatible ways in the next release.
Declaration
public static int GetShrinkSize(int currentSize, int targetSize, int bytesPerElement)
Parameters
| Type | Name | Description |
|---|---|---|
| int | currentSize | |
| int | targetSize | |
| int | bytesPerElement |
Returns
| Type | Description |
|---|---|
| int |
Grow(bool[])
Methods for manipulating arrays.
Note
This API is for internal purposes only and might change in incompatible ways in the next release.
Declaration
public static bool[] Grow(bool[] array)
Parameters
| Type | Name | Description |
|---|---|---|
| bool[] | array |
Returns
| Type | Description |
|---|---|
| bool[] |
Grow(bool[], int)
Methods for manipulating arrays.
Note
This API is for internal purposes only and might change in incompatible ways in the next release.
Declaration
public static bool[] Grow(bool[] array, int minSize)
Parameters
| Type | Name | Description |
|---|---|---|
| bool[] | array | |
| int | minSize |
Returns
| Type | Description |
|---|---|
| bool[] |
Grow(byte[])
Methods for manipulating arrays.
Note
This API is for internal purposes only and might change in incompatible ways in the next release.
Declaration
public static byte[] Grow(byte[] array)
Parameters
| Type | Name | Description |
|---|---|---|
| byte[] | array |
Returns
| Type | Description |
|---|---|
| byte[] |
Grow(byte[], int)
Methods for manipulating arrays.
Note
This API is for internal purposes only and might change in incompatible ways in the next release.
Declaration
public static byte[] Grow(byte[] array, int minSize)
Parameters
| Type | Name | Description |
|---|---|---|
| byte[] | array | |
| int | minSize |
Returns
| Type | Description |
|---|---|
| byte[] |
Grow(char[])
Methods for manipulating arrays.
Note
This API is for internal purposes only and might change in incompatible ways in the next release.
Declaration
public static char[] Grow(char[] array)
Parameters
| Type | Name | Description |
|---|---|---|
| char[] | array |
Returns
| Type | Description |
|---|---|
| char[] |
Grow(char[], int)
Methods for manipulating arrays.
Note
This API is for internal purposes only and might change in incompatible ways in the next release.
Declaration
public static char[] Grow(char[] array, int minSize)
Parameters
| Type | Name | Description |
|---|---|---|
| char[] | array | |
| int | minSize |
Returns
| Type | Description |
|---|---|
| char[] |
Grow(double[])
Methods for manipulating arrays.
Note
This API is for internal purposes only and might change in incompatible ways in the next release.
Declaration
public static double[] Grow(double[] array)
Parameters
| Type | Name | Description |
|---|---|---|
| double[] | array |
Returns
| Type | Description |
|---|---|
| double[] |
Grow(double[], int)
Methods for manipulating arrays.
Note
This API is for internal purposes only and might change in incompatible ways in the next release.
Declaration
public static double[] Grow(double[] array, int minSize)
Parameters
| Type | Name | Description |
|---|---|---|
| double[] | array | |
| int | minSize |
Returns
| Type | Description |
|---|---|
| double[] |
Grow(short[])
Methods for manipulating arrays.
Note
This API is for internal purposes only and might change in incompatible ways in the next release.
Declaration
public static short[] Grow(short[] array)
Parameters
| Type | Name | Description |
|---|---|---|
| short[] | array |
Returns
| Type | Description |
|---|---|
| short[] |
Grow(short[], int)
Methods for manipulating arrays.
Note
This API is for internal purposes only and might change in incompatible ways in the next release.
Declaration
public static short[] Grow(short[] array, int minSize)
Parameters
| Type | Name | Description |
|---|---|---|
| short[] | array | |
| int | minSize |
Returns
| Type | Description |
|---|---|
| short[] |
Grow(int[])
Methods for manipulating arrays.
Note
This API is for internal purposes only and might change in incompatible ways in the next release.
Declaration
public static int[] Grow(int[] array)
Parameters
| Type | Name | Description |
|---|---|---|
| int[] | array |
Returns
| Type | Description |
|---|---|
| int[] |
Grow(int[], int)
Methods for manipulating arrays.
Note
This API is for internal purposes only and might change in incompatible ways in the next release.
Declaration
public static int[] Grow(int[] array, int minSize)
Parameters
| Type | Name | Description |
|---|---|---|
| int[] | array | |
| int | minSize |
Returns
| Type | Description |
|---|---|
| int[] |
Grow(int[][])
Methods for manipulating arrays.
Note
This API is for internal purposes only and might change in incompatible ways in the next release.
Declaration
[CLSCompliant(false)]
public static int[][] Grow(int[][] array)
Parameters
| Type | Name | Description |
|---|---|---|
| int[][] | array |
Returns
| Type | Description |
|---|---|
| int[][] |
Grow(int[][], int)
Methods for manipulating arrays.
Note
This API is for internal purposes only and might change in incompatible ways in the next release.
Declaration
[CLSCompliant(false)]
public static int[][] Grow(int[][] array, int minSize)
Parameters
| Type | Name | Description |
|---|---|---|
| int[][] | array | |
| int | minSize |
Returns
| Type | Description |
|---|---|
| int[][] |
Grow(long[])
Methods for manipulating arrays.
Note
This API is for internal purposes only and might change in incompatible ways in the next release.
Declaration
public static long[] Grow(long[] array)
Parameters
| Type | Name | Description |
|---|---|---|
| long[] | array |
Returns
| Type | Description |
|---|---|
| long[] |
Grow(long[], int)
Methods for manipulating arrays.
Note
This API is for internal purposes only and might change in incompatible ways in the next release.
Declaration
public static long[] Grow(long[] array, int minSize)
Parameters
| Type | Name | Description |
|---|---|---|
| long[] | array | |
| int | minSize |
Returns
| Type | Description |
|---|---|
| long[] |
Grow(sbyte[], int)
Methods for manipulating arrays.
Note
This API is for internal purposes only and might change in incompatible ways in the next release.
Declaration
[CLSCompliant(false)]
public static sbyte[] Grow(sbyte[] array, int minSize)
Parameters
| Type | Name | Description |
|---|---|---|
| sbyte[] | array | |
| int | minSize |
Returns
| Type | Description |
|---|---|
| sbyte[] |
Grow(float[])
Methods for manipulating arrays.
Note
This API is for internal purposes only and might change in incompatible ways in the next release.
Declaration
public static float[] Grow(float[] array)
Parameters
| Type | Name | Description |
|---|---|---|
| float[] | array |
Returns
| Type | Description |
|---|---|
| float[] |
Grow(float[], int)
Methods for manipulating arrays.
Note
This API is for internal purposes only and might change in incompatible ways in the next release.
Declaration
public static float[] Grow(float[] array, int minSize)
Parameters
| Type | Name | Description |
|---|---|---|
| float[] | array | |
| int | minSize |
Returns
| Type | Description |
|---|---|
| float[] |
Grow(float[][])
Methods for manipulating arrays.
Note
This API is for internal purposes only and might change in incompatible ways in the next release.
Declaration
[CLSCompliant(false)]
public static float[][] Grow(float[][] array)
Parameters
| Type | Name | Description |
|---|---|---|
| float[][] | array |
Returns
| Type | Description |
|---|---|
| float[][] |
Grow(float[][], int)
Methods for manipulating arrays.
Note
This API is for internal purposes only and might change in incompatible ways in the next release.
Declaration
[CLSCompliant(false)]
public static float[][] Grow(float[][] array, int minSize)
Parameters
| Type | Name | Description |
|---|---|---|
| float[][] | array | |
| int | minSize |
Returns
| Type | Description |
|---|---|
| float[][] |
IntroSort<T>(T[])
Sorts the given array in natural order. This method uses the intro sort algorithm, but falls back to insertion sort for small arrays.
Declaration
public static void IntroSort<T>(T[] a)
Parameters
| Type | Name | Description |
|---|---|---|
| T[] | a |
Type Parameters
| Name | Description |
|---|---|
| T |
IntroSort<T>(T[], IComparer<T>)
Sorts the given array using the IComparer<T>. This method uses the intro sort algorithm, but falls back to insertion sort for small arrays.
Declaration
public static void IntroSort<T>(T[] a, IComparer<T> comp)
Parameters
| Type | Name | Description |
|---|---|---|
| T[] | a | |
| IComparer<T> | comp |
Type Parameters
| Name | Description |
|---|---|
| T |
IntroSort<T>(T[], int, int)
Sorts the given array slice in natural order. This method uses the intro sort algorithm, but falls back to insertion sort for small arrays.
Declaration
public static void IntroSort<T>(T[] a, int fromIndex, int toIndex)
Parameters
| Type | Name | Description |
|---|---|---|
| T[] | a | |
| int | fromIndex | Start index (inclusive) |
| int | toIndex | End index (exclusive) |
Type Parameters
| Name | Description |
|---|---|
| T |
IntroSort<T>(T[], int, int, IComparer<T>)
Sorts the given array slice using the IComparer<T>. This method uses the intro sort algorithm, but falls back to insertion sort for small arrays.
Declaration
public static void IntroSort<T>(T[] a, int fromIndex, int toIndex, IComparer<T> comp)
Parameters
| Type | Name | Description |
|---|---|---|
| T[] | a | |
| int | fromIndex | Start index (inclusive) |
| int | toIndex | End index (exclusive) |
| IComparer<T> | comp |
Type Parameters
| Name | Description |
|---|---|
| T |
Oversize(int, int)
Returns an array size >= minTargetSize, generally
over-allocating exponentially to achieve amortized
linear-time cost as the array grows.
Note
This API is for internal purposes only and might change in incompatible ways in the next release.
Declaration
public static int Oversize(int minTargetSize, int bytesPerElement)
Parameters
| Type | Name | Description |
|---|---|---|
| int | minTargetSize | Minimum required value to be returned. |
| int | bytesPerElement | Bytes used by each element of the array. See constants in RamUsageEstimator. |
Returns
| Type | Description |
|---|---|
| int |
ParseInt32(char[])
Parses the string argument as if it was an int value and returns the result. Throws FormatException if the string does not represent an int quantity.
NOTE: This was parseInt() in LuceneDeclaration
public static int ParseInt32(char[] chars)
Parameters
| Type | Name | Description |
|---|---|---|
| char[] | chars | A string representation of an int quantity. |
Returns
| Type | Description |
|---|---|
| int | The value represented by the argument |
Exceptions
| Type | Condition |
|---|---|
| FormatException | If the argument could not be parsed as an int quantity. |
ParseInt32(char[], int, int)
Parses a char array into an int.
NOTE: This was parseInt() in LuceneDeclaration
public static int ParseInt32(char[] chars, int offset, int len)
Parameters
| Type | Name | Description |
|---|---|---|
| char[] | chars | The character array |
| int | offset | The offset into the array |
| int | len | The length |
Returns
| Type | Description |
|---|---|
| int | the int |
Exceptions
| Type | Condition |
|---|---|
| FormatException | If it can't parse |
ParseInt32(char[], int, int, int)
Parses the string argument as if it was an int value and returns the result. Throws FormatException if the string does not represent an int quantity. The second argument specifies the radix to use when parsing the value.
NOTE: This was parseInt() in LuceneDeclaration
public static int ParseInt32(char[] chars, int offset, int len, int radix)
Parameters
| Type | Name | Description |
|---|---|---|
| char[] | chars | A string representation of an int quantity. |
| int | offset | |
| int | len | |
| int | radix | The base to use for conversion. |
Returns
| Type | Description |
|---|---|
| int | The value represented by the argument |
Exceptions
| Type | Condition |
|---|---|
| FormatException | If the argument could not be parsed as an int quantity. |
Shrink(bool[], int)
Methods for manipulating arrays.
Note
This API is for internal purposes only and might change in incompatible ways in the next release.
Declaration
public static bool[] Shrink(bool[] array, int targetSize)
Parameters
| Type | Name | Description |
|---|---|---|
| bool[] | array | |
| int | targetSize |
Returns
| Type | Description |
|---|---|
| bool[] |
Shrink(byte[], int)
Methods for manipulating arrays.
Note
This API is for internal purposes only and might change in incompatible ways in the next release.
Declaration
public static byte[] Shrink(byte[] array, int targetSize)
Parameters
| Type | Name | Description |
|---|---|---|
| byte[] | array | |
| int | targetSize |
Returns
| Type | Description |
|---|---|
| byte[] |
Shrink(char[], int)
Methods for manipulating arrays.
Note
This API is for internal purposes only and might change in incompatible ways in the next release.
Declaration
public static char[] Shrink(char[] array, int targetSize)
Parameters
| Type | Name | Description |
|---|---|---|
| char[] | array | |
| int | targetSize |
Returns
| Type | Description |
|---|---|
| char[] |
Shrink(short[], int)
Methods for manipulating arrays.
Note
This API is for internal purposes only and might change in incompatible ways in the next release.
Declaration
public static short[] Shrink(short[] array, int targetSize)
Parameters
| Type | Name | Description |
|---|---|---|
| short[] | array | |
| int | targetSize |
Returns
| Type | Description |
|---|---|
| short[] |
Shrink(int[], int)
Methods for manipulating arrays.
Note
This API is for internal purposes only and might change in incompatible ways in the next release.
Declaration
public static int[] Shrink(int[] array, int targetSize)
Parameters
| Type | Name | Description |
|---|---|---|
| int[] | array | |
| int | targetSize |
Returns
| Type | Description |
|---|---|
| int[] |
Shrink(int[][], int)
Methods for manipulating arrays.
Note
This API is for internal purposes only and might change in incompatible ways in the next release.
Declaration
[CLSCompliant(false)]
public static int[][] Shrink(int[][] array, int targetSize)
Parameters
| Type | Name | Description |
|---|---|---|
| int[][] | array | |
| int | targetSize |
Returns
| Type | Description |
|---|---|
| int[][] |
Shrink(long[], int)
Methods for manipulating arrays.
Note
This API is for internal purposes only and might change in incompatible ways in the next release.
Declaration
public static long[] Shrink(long[] array, int targetSize)
Parameters
| Type | Name | Description |
|---|---|---|
| long[] | array | |
| int | targetSize |
Returns
| Type | Description |
|---|---|
| long[] |
Shrink(float[][], int)
Methods for manipulating arrays.
Note
This API is for internal purposes only and might change in incompatible ways in the next release.
Declaration
[CLSCompliant(false)]
public static float[][] Shrink(float[][] array, int targetSize)
Parameters
| Type | Name | Description |
|---|---|---|
| float[][] | array | |
| int | targetSize |
Returns
| Type | Description |
|---|---|
| float[][] |
Swap<T>(T[], int, int)
Swap values stored in slots i and j
Declaration
public static void Swap<T>(T[] arr, int i, int j)
Parameters
| Type | Name | Description |
|---|---|---|
| T[] | arr | |
| int | i | |
| int | j |
Type Parameters
| Name | Description |
|---|---|
| T |
TimSort<T>(T[])
Sorts the given array in natural order. this method uses the Tim sort algorithm, but falls back to binary sort for small arrays.
Declaration
public static void TimSort<T>(T[] a)
Parameters
| Type | Name | Description |
|---|---|---|
| T[] | a |
Type Parameters
| Name | Description |
|---|---|
| T |
TimSort<T>(T[], IComparer<T>)
Sorts the given array using the IComparer<T>. this method uses the Tim sort algorithm, but falls back to binary sort for small arrays.
Declaration
public static void TimSort<T>(T[] a, IComparer<T> comp)
Parameters
| Type | Name | Description |
|---|---|---|
| T[] | a | |
| IComparer<T> | comp |
Type Parameters
| Name | Description |
|---|---|
| T |
TimSort<T>(T[], int, int)
Sorts the given array slice in natural order. this method uses the Tim sort algorithm, but falls back to binary sort for small arrays.
Declaration
public static void TimSort<T>(T[] a, int fromIndex, int toIndex)
Parameters
| Type | Name | Description |
|---|---|---|
| T[] | a | |
| int | fromIndex | Start index (inclusive) |
| int | toIndex | End index (exclusive) |
Type Parameters
| Name | Description |
|---|---|
| T |
TimSort<T>(T[], int, int, IComparer<T>)
Sorts the given array slice using the IComparer<T>. This method uses the Tim sort algorithm, but falls back to binary sort for small arrays.
Declaration
public static void TimSort<T>(T[] a, int fromIndex, int toIndex, IComparer<T> comp)
Parameters
| Type | Name | Description |
|---|---|---|
| T[] | a | |
| int | fromIndex | Start index (inclusive) |
| int | toIndex | End index (exclusive) |
| IComparer<T> | comp |
Type Parameters
| Name | Description |
|---|---|
| T |