|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.croftsoft.core.util.ArrayLib2
public final class ArrayLib2
Array manipulation for Java 1.2+.
Java 1.2 compatible.
ArrayLib
Method Summary | |
---|---|
static Comparable[] |
insertSorted(Comparable[] sortedComparableArray,
Comparable comparable,
boolean allowDuplicates)
Inserts, in sort order, a Comparable into a presorted array. |
static int[] |
insertSorted(int[] sortedIntArray,
int i,
boolean allowDuplicates)
Inserts, in sort order, an integer into a presorted integer array. |
static void |
main(String[] args)
|
static boolean |
test(String[] args)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public static void main(String[] args)
public static boolean test(String[] args)
public static int[] insertSorted(int[] sortedIntArray, int i, boolean allowDuplicates)
As this function uses Arrays.binarySearch() and ArrayLib.insert(), it should be more efficient than growing a sorted array by appending an element and calling Arrays.sort() each time, especially as the array grows larger.
sortedIntArray
- The array argument must be presorted. If the array was built up
one element at a time using this method, the array will always be
in a sorted state.
If this parameter is null, a new integer array will be created.comparable
- The int value to be inserted.allowDuplicates
- If false, the original array argument may be returned unchanged.
Arrays.binarySearch(int[],int)
public static Comparable[] insertSorted(Comparable[] sortedComparableArray, Comparable comparable, boolean allowDuplicates)
As this function uses Arrays.binarySearch(), it should be more efficient than growing a sorted array by appending an element and calling Arrays.sort() each time, especially as the array grows larger.
sortedComparableArray
- The array argument must be presorted. If the array was built up
one element at a time using this method, the array will always be
in a sorted state.comparable
- The Comparable object to be inserted.allowDuplicates
- If false, the original array argument may be returned unchanged.
NullArgumentException
- If sortedComparableArray or comparable is null.Arrays.binarySearch(java.lang.Object[],java.lang.Object)
|
CroftSoft Javadoc | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |