public class ObjectArrayUtilities extends Object
Modifier and Type | Method and Description |
---|---|
static int |
binarySearch(ObjectArray objectArray,
Object key)
Searches the specified object array for the specified object using the binary
search algorithm.
|
static int |
binarySearch(ObjectArray objectArray,
Object key,
Comparator c)
Perform binary search with the specified comparator.
|
static void |
copyItems(ObjectArray srcObjectArray,
int srcStartIndex,
int srcEndIndex,
Object[] dest,
int destIndex)
Copy items from the given object array into destination array.
|
static void |
copyItems(ObjectArray srcObjectArray,
Object[] dest)
Copy all items from the given object array into destination array.
|
static int |
findIndex(ObjectArray objectArray,
Object item)
Get index of the occurrence of the given item in the object array
by using binary search and scanning the adjacent items
that are equal copmared to the searched item.
|
static int |
findIndex(ObjectArray objectArray,
Object item,
Comparator c)
Get index of the occurrence of the given item in the object array
by using binary search and scanning the adjacent items
that are equal copmared to the searched item.
|
static ObjectArray.Modification |
mergeModifications(ObjectArray.Modification[] mods) |
static ObjectArray.Modification |
mergeModifications(ObjectArray.Modification mod1,
ObjectArray.Modification mod2) |
static void |
reverse(Object[] array)
Utility method to reverse order of the elements in the given array.
|
static Object[] |
toArray(ObjectArray objectArray)
Create array and fill it with all the items from the given objectArray.
|
static Object[] |
toArray(ObjectArray objectArray,
int startIndex,
int endIndex)
Create array and fill it with the items from the given objectArray.
|
public static int binarySearch(ObjectArray objectArray, Object key)
objectArray
- object array to be searched.key
- the key to be searched for.ClassCastException
- if the object array contains elements that are not
mutually comparable (for example, strings and
integers), or the search key in not mutually comparable
with the elements of the object array.Comparable
public static int binarySearch(ObjectArray objectArray, Object key, Comparator c)
ObjectArrayUtilities.binarySearch(ObjectArray, Object)
.objectArray
- object array to be searched.key
- key to search for.c
- comparator to be used to compare the items.ObjectArrayUtilities.binarySearch(ObjectArray, Object)
public static int findIndex(ObjectArray objectArray, Object item)
objectArray
- object array containing the item.item
- object to be found.public static int findIndex(ObjectArray objectArray, Object item, Comparator c)
objectArray
- object array containing the item.item
- object to be found.c
- comparator to use to compare the items.public static Object[] toArray(ObjectArray objectArray)
objectArray
- objectArray containing items to copy.public static Object[] toArray(ObjectArray objectArray, int startIndex, int endIndex)
objectArray
- objectArray containing items to copy.startIndex
- index of the first item to copy.endIndex
- index that follows the last item to copy.public static void copyItems(ObjectArray srcObjectArray, Object[] dest)
srcObjectArray
- objectArray containing items to copy.dest
- array into which the items will be copied (at index zero).public static void copyItems(ObjectArray srcObjectArray, int srcStartIndex, int srcEndIndex, Object[] dest, int destIndex)
srcObjectArray
- objectArray containing items to copy.srcStartIndex
- index of the first item in the objectArray to copy.srcEndIndex
- index that follows the last item in the objectArray to copy.dest
- array into which the items will be copied.destIndex
- index in the destination array at which the placing
of the copied items will be started.public static void reverse(Object[] array)
array
- array to be reversed.public static ObjectArray.Modification mergeModifications(ObjectArray.Modification mod1, ObjectArray.Modification mod2)
public static ObjectArray.Modification mergeModifications(ObjectArray.Modification[] mods)