com.sun.javatest.util
public final class DynamicArray extends java.lang.Object
Constructor and Description |
---|
DynamicArray() |
Modifier and Type | Method and Description |
---|---|
static java.lang.Object[] |
append(java.lang.Object[] oldArr,
java.lang.Object newObj)
Append an object to the end of the array.
|
static java.lang.Object[] |
append(java.lang.Object[] oldArr,
java.lang.Object newObj,
java.lang.Class arrayClass)
Append an object to the end of the array.
|
static int |
find(java.lang.Object[] arr,
java.lang.Object target)
Find the first index of the object that is equal (reference) to the
target.
|
protected static java.lang.Class |
getArrayClass(java.lang.Object[] arr)
Get the type of objects that the array is declared to hold.
|
static java.lang.Object[] |
insert(java.lang.Object[] oldArr,
java.lang.Object newObj,
int location)
Insert an object into the array at the specified index.
|
static java.lang.Object[] |
join(java.lang.Object[] array1,
java.lang.Object[] array2)
Join two arrays.
|
static java.lang.Object[] |
remove(java.lang.Object[] oldArr,
int index)
Remove the object at the specified index.
|
static java.lang.Object[] |
remove(java.lang.Object[] oldArr,
java.lang.Object victim)
Remove the object from the array.
|
public static java.lang.Object[] append(java.lang.Object[] oldArr, java.lang.Object newObj)
oldArr
- The original array which we are appending to. May be zero length or null.newObj
- The new value to append to the oldArr. Null is not a legal value.java.lang.IllegalArgumentException
- If newObj is null.java.lang.ArrayStoreException
- If there is a type mismatch between oldArr and newObj.public static java.lang.Object[] append(java.lang.Object[] oldArr, java.lang.Object newObj, java.lang.Class arrayClass)
oldArr
- The original array which we are appending to. May be zero length or null.newObj
- The new value to append to the oldArr.arrayClass
- If the oldArr is null, a new array of arrayClass will be created.
If arrayClass is null, the type of newObj will be used to create the array.java.lang.IllegalArgumentException
- If newObj is null.java.lang.ArrayStoreException
- If there is a type mismatch between oldArr and newObj.public static java.lang.Object[] join(java.lang.Object[] array1, java.lang.Object[] array2)
array1
- The first array to be joined.array2
- The second array to be joined.public static java.lang.Object[] insert(java.lang.Object[] oldArr, java.lang.Object newObj, int location)
oldArr
- The array to insert into. May be null, in which case a new array
will be created using the type of newObj
.newObj
- The object to insert.location
- The index at which to insert the item. An exception will occur
if the location in out of range. This location can be equal to
oldArr.length
, in which case this becomes an append
operation.public static java.lang.Object[] remove(java.lang.Object[] oldArr, int index)
oldArr
- The original array which we are removing from. May not be
null or zero length.index
- The index to remove from oldArr
. Exception
will be thrown if it is out of range.java.lang.IllegalArgumentException
- Will occur if the given index is out of range,
or the given array is null.java.lang.NullPointerException
- May occur if the source array has null
values, particularly in the first array position.java.lang.ArrayStoreException
- May occur if all the objects in the
array do not match.public static java.lang.Object[] remove(java.lang.Object[] oldArr, java.lang.Object victim)
oldArr
- The array to remove from.victim
- The object to remove from the array. May be null.public static int find(java.lang.Object[] arr, java.lang.Object target)
arr
- The data to search; should not be null.target
- The reference to search for; can be null.protected static java.lang.Class getArrayClass(java.lang.Object[] arr)
arr
- The array to examine.Copyright (c) 1996, 2010, Oracle and/or its affiliates. All rights reserved.