Package org.neo4j.graphalgo.core.utils
Class ArrayUtil
- java.lang.Object
-
- org.neo4j.graphalgo.core.utils.ArrayUtil
-
public final class ArrayUtil extends java.lang.Object
-
-
Field Summary
Fields Modifier and Type Field Description static int
LINEAR_SEARCH_LIMIT
static int
MAX_ARRAY_LENGTH
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static int
binaryLookup(int id, int[] ids)
Find the index where(ids[idx] <= id) && (ids[idx + 1] > id)
.static int
binaryLookup(long id, long[] ids)
Find the index where(ids[idx] <= id) && (ids[idx + 1] > id)
.static boolean
binarySearch(int[] arr, int length, int key)
static int
binarySearchIndex(int[] arr, int length, int key)
static boolean
linearSearch(int[] arr, int length, int key)
static boolean
linearSearch2(int[] arr, int low, int high, int key)
static int
linearSearch2index(int[] arr, int low, int high, int key)
static int
linearSearchIndex(int[] arr, int length, int key)
-
-
-
Field Detail
-
MAX_ARRAY_LENGTH
public static final int MAX_ARRAY_LENGTH
-
LINEAR_SEARCH_LIMIT
public static final int LINEAR_SEARCH_LIMIT
- See Also:
- Constant Field Values
-
-
Method Detail
-
binarySearch
public static boolean binarySearch(int[] arr, int length, int key)
-
binarySearchIndex
public static int binarySearchIndex(int[] arr, int length, int key)
-
linearSearch2
public static boolean linearSearch2(int[] arr, int low, int high, int key)
-
linearSearch2index
public static int linearSearch2index(int[] arr, int low, int high, int key)
-
linearSearch
public static boolean linearSearch(int[] arr, int length, int key)
-
linearSearchIndex
public static int linearSearchIndex(int[] arr, int length, int key)
-
binaryLookup
public static int binaryLookup(long id, long[] ids)
Find the index where(ids[idx] <= id) && (ids[idx + 1] > id)
. The result differs from that ofArrays.binarySearch(long[], long)
in that this method returns a positive index even if the array does not directly contain the searched value. It returns -1 iff the value is smaller than the smallest one in the array.
-
binaryLookup
public static int binaryLookup(int id, int[] ids)
Find the index where(ids[idx] <= id) && (ids[idx + 1] > id)
. The result differs from that ofArrays.binarySearch(long[], long)
in that this method returns a positive index even if the array does not directly contain the searched value. It returns -1 iff the value is smaller than the smallest one in the array.
-
-