Class ArrayUtil
Methods for manipulating arrays.
This is a Lucene.NET INTERNAL API, use at your own risk
Inheritance
System.Object
ArrayUtil
Inherited Members
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.ToString()
Assembly: Lucene.Net.dll
Syntax
public sealed class ArrayUtil
Fields
|
Improve this Doc
View Source
MAX_ARRAY_LENGTH
Maximum length for an array; we set this to "a
bit" below System.Int32.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 |
System.Int32 |
|
Methods
|
Improve this Doc
View Source
Equals(Byte[], Int32, Byte[], Int32, Int32)
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 |
System.Byte[] |
left |
The left array to compare
|
System.Int32 |
offsetLeft |
The offset into the array. Must be positive
|
System.Byte[] |
right |
The right array to compare
|
System.Int32 |
offsetRight |
the offset into the right array. Must be positive
|
System.Int32 |
length |
The length of the section of the array to compare
|
Returns
Type |
Description |
System.Boolean |
true if the two arrays, starting at their respective offsets, are equal
|
See Also
Lucene.Net.Support.Arrays.Equals``1(``0[],``0[])
|
Improve this Doc
View Source
Equals(Char[], Int32, Char[], Int32, Int32)
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 |
System.Char[] |
left |
The left array to compare
|
System.Int32 |
offsetLeft |
The offset into the array. Must be positive
|
System.Char[] |
right |
The right array to compare
|
System.Int32 |
offsetRight |
the offset into the right array. Must be positive
|
System.Int32 |
length |
The length of the section of the array to compare
|
Returns
Type |
Description |
System.Boolean |
true if the two arrays, starting at their respective offsets, are equal
|
See Also
Lucene.Net.Support.Arrays.Equals``1(``0[],``0[])
|
Improve this Doc
View Source
Equals(Int32[], Int32, Int32[], Int32, Int32)
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 |
System.Int32[] |
left |
The left array to compare
|
System.Int32 |
offsetLeft |
The offset into the array. Must be positive
|
System.Int32[] |
right |
The right array to compare
|
System.Int32 |
offsetRight |
the offset into the right array. Must be positive
|
System.Int32 |
length |
The length of the section of the array to compare
|
Returns
Type |
Description |
System.Boolean |
true if the two arrays, starting at their respective offsets, are equal
|
See Also
Lucene.Net.Support.Arrays.Equals``1(``0[],``0[])
|
Improve this Doc
View Source
GetHashCode(Byte[], Int32, Int32)
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 |
System.Byte[] |
array |
|
System.Int32 |
start |
|
System.Int32 |
end |
|
Returns
Type |
Description |
System.Int32 |
|
|
Improve this Doc
View Source
GetHashCode(Char[], Int32, Int32)
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 |
System.Char[] |
array |
|
System.Int32 |
start |
|
System.Int32 |
end |
|
Returns
Type |
Description |
System.Int32 |
|
|
Improve this Doc
View Source
GetNaturalComparer<T>()
Get the natural System.Collections.Generic.IComparer<T> for the provided object class.
The comparer returned depends on the argument:
- If the type is System.String, the comparer returned uses
the System.String.CompareOrdinal(System.String,System.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 System.IComparable<T>, the comparer uses
System.IComparable<T>.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 System.Collections.Generic.Comparer`1.Default.
NOTE: This was naturalComparer() in Lucene
Declaration
public static IComparer<T> GetNaturalComparer<T>()
Returns
Type |
Description |
System.Collections.Generic.IComparer<T> |
|
Type Parameters
|
Improve this Doc
View Source
GetShrinkSize(Int32, Int32, Int32)
Declaration
public static int GetShrinkSize(int currentSize, int targetSize, int bytesPerElement)
Parameters
Type |
Name |
Description |
System.Int32 |
currentSize |
|
System.Int32 |
targetSize |
|
System.Int32 |
bytesPerElement |
|
Returns
Type |
Description |
System.Int32 |
|
|
Improve this Doc
View Source
Grow(Boolean[])
Declaration
public static bool[] Grow(bool[] array)
Parameters
Type |
Name |
Description |
System.Boolean[] |
array |
|
Returns
Type |
Description |
System.Boolean[] |
|
|
Improve this Doc
View Source
Grow(Boolean[], Int32)
Declaration
public static bool[] Grow(bool[] array, int minSize)
Parameters
Type |
Name |
Description |
System.Boolean[] |
array |
|
System.Int32 |
minSize |
|
Returns
Type |
Description |
System.Boolean[] |
|
|
Improve this Doc
View Source
Grow(Byte[])
Declaration
public static byte[] Grow(byte[] array)
Parameters
Type |
Name |
Description |
System.Byte[] |
array |
|
Returns
Type |
Description |
System.Byte[] |
|
|
Improve this Doc
View Source
Grow(Byte[], Int32)
Declaration
public static byte[] Grow(byte[] array, int minSize)
Parameters
Type |
Name |
Description |
System.Byte[] |
array |
|
System.Int32 |
minSize |
|
Returns
Type |
Description |
System.Byte[] |
|
|
Improve this Doc
View Source
Grow(Char[])
Declaration
public static char[] Grow(char[] array)
Parameters
Type |
Name |
Description |
System.Char[] |
array |
|
Returns
Type |
Description |
System.Char[] |
|
|
Improve this Doc
View Source
Grow(Char[], Int32)
Declaration
public static char[] Grow(char[] array, int minSize)
Parameters
Type |
Name |
Description |
System.Char[] |
array |
|
System.Int32 |
minSize |
|
Returns
Type |
Description |
System.Char[] |
|
|
Improve this Doc
View Source
Grow(Double[])
Declaration
public static double[] Grow(double[] array)
Parameters
Type |
Name |
Description |
System.Double[] |
array |
|
Returns
Type |
Description |
System.Double[] |
|
|
Improve this Doc
View Source
Grow(Double[], Int32)
Declaration
public static double[] Grow(double[] array, int minSize)
Parameters
Type |
Name |
Description |
System.Double[] |
array |
|
System.Int32 |
minSize |
|
Returns
Type |
Description |
System.Double[] |
|
|
Improve this Doc
View Source
Grow(Int16[])
Declaration
public static short[] Grow(short[] array)
Parameters
Type |
Name |
Description |
System.Int16[] |
array |
|
Returns
Type |
Description |
System.Int16[] |
|
|
Improve this Doc
View Source
Grow(Int16[], Int32)
Declaration
public static short[] Grow(short[] array, int minSize)
Parameters
Type |
Name |
Description |
System.Int16[] |
array |
|
System.Int32 |
minSize |
|
Returns
Type |
Description |
System.Int16[] |
|
|
Improve this Doc
View Source
Grow(Int32[])
Declaration
public static int[] Grow(int[] array)
Parameters
Type |
Name |
Description |
System.Int32[] |
array |
|
Returns
Type |
Description |
System.Int32[] |
|
|
Improve this Doc
View Source
Grow(Int32[], Int32)
Declaration
public static int[] Grow(int[] array, int minSize)
Parameters
Type |
Name |
Description |
System.Int32[] |
array |
|
System.Int32 |
minSize |
|
Returns
Type |
Description |
System.Int32[] |
|
|
Improve this Doc
View Source
Grow(Int32[][])
Declaration
[CLSCompliant(false)]
public static int[][] Grow(int[][] array)
Parameters
Type |
Name |
Description |
System.Int32[][] |
array |
|
Returns
Type |
Description |
System.Int32[][] |
|
|
Improve this Doc
View Source
Grow(Int32[][], Int32)
Declaration
[CLSCompliant(false)]
public static int[][] Grow(int[][] array, int minSize)
Parameters
Type |
Name |
Description |
System.Int32[][] |
array |
|
System.Int32 |
minSize |
|
Returns
Type |
Description |
System.Int32[][] |
|
|
Improve this Doc
View Source
Grow(Int64[])
Declaration
public static long[] Grow(long[] array)
Parameters
Type |
Name |
Description |
System.Int64[] |
array |
|
Returns
Type |
Description |
System.Int64[] |
|
|
Improve this Doc
View Source
Grow(Int64[], Int32)
Declaration
public static long[] Grow(long[] array, int minSize)
Parameters
Type |
Name |
Description |
System.Int64[] |
array |
|
System.Int32 |
minSize |
|
Returns
Type |
Description |
System.Int64[] |
|
|
Improve this Doc
View Source
Grow(SByte[], Int32)
Declaration
[CLSCompliant(false)]
public static sbyte[] Grow(sbyte[] array, int minSize)
Parameters
Type |
Name |
Description |
System.SByte[] |
array |
|
System.Int32 |
minSize |
|
Returns
Type |
Description |
System.SByte[] |
|
|
Improve this Doc
View Source
Grow(Single[])
Declaration
public static float[] Grow(float[] array)
Parameters
Type |
Name |
Description |
System.Single[] |
array |
|
Returns
Type |
Description |
System.Single[] |
|
|
Improve this Doc
View Source
Grow(Single[], Int32)
Declaration
public static float[] Grow(float[] array, int minSize)
Parameters
Type |
Name |
Description |
System.Single[] |
array |
|
System.Int32 |
minSize |
|
Returns
Type |
Description |
System.Single[] |
|
|
Improve this Doc
View Source
Grow(Single[][])
Declaration
[CLSCompliant(false)]
public static float[][] Grow(float[][] array)
Parameters
Type |
Name |
Description |
System.Single[][] |
array |
|
Returns
Type |
Description |
System.Single[][] |
|
|
Improve this Doc
View Source
Grow(Single[][], Int32)
Declaration
[CLSCompliant(false)]
public static float[][] Grow(float[][] array, int minSize)
Parameters
Type |
Name |
Description |
System.Single[][] |
array |
|
System.Int32 |
minSize |
|
Returns
Type |
Description |
System.Single[][] |
|
|
Improve this Doc
View Source
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
|
Improve this Doc
View Source
IntroSort<T>(T[], IComparer<T>)
Sorts the given array using the System.Collections.Generic.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 |
|
System.Collections.Generic.IComparer<T> |
comp |
|
Type Parameters
|
Improve this Doc
View Source
IntroSort<T>(T[], Int32, Int32)
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 |
|
System.Int32 |
fromIndex |
Start index (inclusive)
|
System.Int32 |
toIndex |
End index (exclusive)
|
Type Parameters
|
Improve this Doc
View Source
IntroSort<T>(T[], Int32, Int32, IComparer<T>)
Sorts the given array slice using the System.Collections.Generic.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 |
|
System.Int32 |
fromIndex |
Start index (inclusive)
|
System.Int32 |
toIndex |
End index (exclusive)
|
System.Collections.Generic.IComparer<T> |
comp |
|
Type Parameters
|
Improve this Doc
View Source
Oversize(Int32, Int32)
Returns an array size >= minTargetSize
, generally
over-allocating exponentially to achieve amortized
linear-time cost as the array grows.
NOTE: this was originally borrowed from Python 2.4.2
listobject.c sources (attribution in LICENSE.txt), but
has now been substantially changed based on
discussions from java-dev thread with subject "Dynamic
array reallocation algorithms", started on Jan 12
2010.
This is a Lucene.NET INTERNAL API, use at your own risk
Declaration
public static int Oversize(int minTargetSize, int bytesPerElement)
Parameters
Type |
Name |
Description |
System.Int32 |
minTargetSize |
Minimum required value to be returned.
|
System.Int32 |
bytesPerElement |
Bytes used by each element of
the array. See constants in RamUsageEstimator.
|
Returns
Type |
Description |
System.Int32 |
|
|
Improve this Doc
View Source
ParseInt32(Char[])
Parses the string argument as if it was an System.Int32 value and returns the
result. Throws System.FormatException if the string does not represent an
int quantity.
NOTE: This was parseInt() in Lucene
Declaration
public static int ParseInt32(char[] chars)
Parameters
Type |
Name |
Description |
System.Char[] |
chars |
A string representation of an int quantity.
|
Returns
Type |
Description |
System.Int32 |
The value represented by the argument
|
Exceptions
Type |
Condition |
System.FormatException |
If the argument could not be parsed as an int quantity.
|
|
Improve this Doc
View Source
ParseInt32(Char[], Int32, Int32)
Parses a char array into an System.Int32.
NOTE: This was parseInt() in Lucene
Declaration
public static int ParseInt32(char[] chars, int offset, int len)
Parameters
Type |
Name |
Description |
System.Char[] |
chars |
The character array
|
System.Int32 |
offset |
The offset into the array
|
System.Int32 |
len |
The length
|
Returns
Type |
Description |
System.Int32 |
the System.Int32
|
Exceptions
Type |
Condition |
System.FormatException |
If it can't parse
|
|
Improve this Doc
View Source
ParseInt32(Char[], Int32, Int32, Int32)
Parses the string argument as if it was an System.Int32 value and returns the
result. Throws System.FormatException if the string does not represent an
System.Int32 quantity. The second argument specifies the radix to use when parsing
the value.
NOTE: This was parseInt() in Lucene
Declaration
public static int ParseInt32(char[] chars, int offset, int len, int radix)
Parameters
Type |
Name |
Description |
System.Char[] |
chars |
A string representation of an int quantity.
|
System.Int32 |
offset |
|
System.Int32 |
len |
|
System.Int32 |
radix |
The base to use for conversion.
|
Returns
Type |
Description |
System.Int32 |
The value represented by the argument
|
Exceptions
Type |
Condition |
System.FormatException |
If the argument could not be parsed as an int quantity.
|
|
Improve this Doc
View Source
Shrink(Boolean[], Int32)
Declaration
public static bool[] Shrink(bool[] array, int targetSize)
Parameters
Type |
Name |
Description |
System.Boolean[] |
array |
|
System.Int32 |
targetSize |
|
Returns
Type |
Description |
System.Boolean[] |
|
|
Improve this Doc
View Source
Shrink(Byte[], Int32)
Declaration
public static byte[] Shrink(byte[] array, int targetSize)
Parameters
Type |
Name |
Description |
System.Byte[] |
array |
|
System.Int32 |
targetSize |
|
Returns
Type |
Description |
System.Byte[] |
|
|
Improve this Doc
View Source
Shrink(Char[], Int32)
Declaration
public static char[] Shrink(char[] array, int targetSize)
Parameters
Type |
Name |
Description |
System.Char[] |
array |
|
System.Int32 |
targetSize |
|
Returns
Type |
Description |
System.Char[] |
|
|
Improve this Doc
View Source
Shrink(Int16[], Int32)
Declaration
public static short[] Shrink(short[] array, int targetSize)
Parameters
Type |
Name |
Description |
System.Int16[] |
array |
|
System.Int32 |
targetSize |
|
Returns
Type |
Description |
System.Int16[] |
|
|
Improve this Doc
View Source
Shrink(Int32[], Int32)
Declaration
public static int[] Shrink(int[] array, int targetSize)
Parameters
Type |
Name |
Description |
System.Int32[] |
array |
|
System.Int32 |
targetSize |
|
Returns
Type |
Description |
System.Int32[] |
|
|
Improve this Doc
View Source
Shrink(Int32[][], Int32)
Declaration
[CLSCompliant(false)]
public static int[][] Shrink(int[][] array, int targetSize)
Parameters
Type |
Name |
Description |
System.Int32[][] |
array |
|
System.Int32 |
targetSize |
|
Returns
Type |
Description |
System.Int32[][] |
|
|
Improve this Doc
View Source
Shrink(Int64[], Int32)
Declaration
public static long[] Shrink(long[] array, int targetSize)
Parameters
Type |
Name |
Description |
System.Int64[] |
array |
|
System.Int32 |
targetSize |
|
Returns
Type |
Description |
System.Int64[] |
|
|
Improve this Doc
View Source
Shrink(Single[][], Int32)
Declaration
[CLSCompliant(false)]
public static float[][] Shrink(float[][] array, int targetSize)
Parameters
Type |
Name |
Description |
System.Single[][] |
array |
|
System.Int32 |
targetSize |
|
Returns
Type |
Description |
System.Single[][] |
|
|
Improve this Doc
View Source
Swap<T>(T[], Int32, Int32)
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 |
|
System.Int32 |
i |
|
System.Int32 |
j |
|
Type Parameters
|
Improve this Doc
View Source
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
|
Improve this Doc
View Source
TimSort<T>(T[], IComparer<T>)
Sorts the given array using the System.Collections.Generic.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 |
|
System.Collections.Generic.IComparer<T> |
comp |
|
Type Parameters
|
Improve this Doc
View Source
TimSort<T>(T[], Int32, Int32)
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 |
|
System.Int32 |
fromIndex |
Start index (inclusive)
|
System.Int32 |
toIndex |
End index (exclusive)
|
Type Parameters
|
Improve this Doc
View Source
TimSort<T>(T[], Int32, Int32, IComparer<T>)
Sorts the given array slice using the System.Collections.Generic.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 |
|
System.Int32 |
fromIndex |
Start index (inclusive)
|
System.Int32 |
toIndex |
End index (exclusive)
|
System.Collections.Generic.IComparer<T> |
comp |
|
Type Parameters
|
Improve this Doc
View Source
ToInt32Array(ICollection<Nullable<Int32>>)
NOTE: This was toIntArray() in Lucene
Declaration
public static int[] ToInt32Array(ICollection<int?> ints)
Parameters
Type |
Name |
Description |
System.Collections.Generic.ICollection<System.Nullable<System.Int32>> |
ints |
|
Returns
Type |
Description |
System.Int32[] |
|