T
- The reference typepublic class ReferenceArray<T> extends AbstractPrimitiveArray
Constructor and Description |
---|
ReferenceArray()
Default constructor
|
ReferenceArray(ReferenceArray<T> sourceArray)
Copy constructor
|
Modifier and Type | Method and Description |
---|---|
T[] |
asArray()
Get a reference to a T[] that represents the contents of this array.
|
static <T,A extends ReferenceArray<T>> |
copyInstance(A source)
Create a new <A extends
ReferenceArray <T>> instance, using a copy constructor to
replicate the contents of the given source array |
static <T,A extends ReferenceArray<T>> |
copyInstance(java.lang.invoke.MethodHandles.Lookup lookup,
A source)
Create a new <A extends
ReferenceArray <T>> instance, using a copy constructor to
replicate the contents of the given source array |
T |
get(int index)
Get the value of an element in the array.
|
T |
get(long index)
Get the value of an element in the array.
|
long |
getLength()
Get the length of the array
|
static <T,A extends ReferenceArray<T>> |
newInstance(java.lang.Class<A> arrayClass,
long length)
Create a new instance of <A extends
ReferenceArray <T>> with a given length. |
static <A extends ReferenceArray> |
newInstance(CtorAndArgs<A> arrayCtorAndArgs,
long length)
Create a new instance of <A extends
ReferenceArray > with a given length,
array constructor, and array constructor arguments. |
static <T> ReferenceArray<T> |
newInstance(long length)
Create a new instance of ReferenceArray<T> with a given length.
|
static <T,A extends ReferenceArray<T>> |
newInstance(long length,
java.lang.reflect.Constructor<A> arrayConstructor,
java.lang.Object... arrayConstructorArgs)
Create a new instance of <A extends
ReferenceArray <T>> with a given length,
array constructor, and array constructor arguments. |
static <T,A extends ReferenceArray<T>> |
newInstance(java.lang.invoke.MethodHandles.Lookup lookup,
java.lang.Class<A> arrayClass,
long length)
Create a new instance of <A extends
ReferenceArray <T>> with a given length. |
void |
set(int index,
T value)
set the value of an element in the array.
|
void |
set(long index,
T value)
set the value of an element in the array.
|
public ReferenceArray()
public ReferenceArray(ReferenceArray<T> sourceArray)
sourceArray
- the array to copypublic T[] asArray() throws java.lang.IllegalStateException
java.lang.IllegalStateException
- if array is too long to represent as a T[]public long getLength()
public T get(int index)
index
- the index of the elementpublic T get(long index)
index
- the index of the elementpublic void set(int index, T value)
index
- the index of the element to setvalue
- the value to assign to the elementpublic void set(long index, T value)
index
- the index of the element to setvalue
- the value to assign to the elementpublic static <T> ReferenceArray<T> newInstance(long length)
T
- the reference typelength
- the length of the arraypublic static <T,A extends ReferenceArray<T>> A newInstance(java.lang.Class<A> arrayClass, long length)
ReferenceArray
<T>> with a given length.T
- the reference typeA
- The class of the array to be created (extends ReferenceArray<T>)arrayClass
- The class of the array to be created (extends ReferenceArray<T>)length
- the length of the array.ReferenceArray
<T>> with a given lengthpublic static <T,A extends ReferenceArray<T>> A newInstance(java.lang.invoke.MethodHandles.Lookup lookup, java.lang.Class<A> arrayClass, long length)
ReferenceArray
<T>> with a given length.T
- the reference typeA
- The class of the array to be created (extends ReferenceArray<T>)lookup
- The lookup object to use for accessing the array's constructorarrayClass
- The class of the array to be created (extends ReferenceArray<T>)length
- the length of the array.ReferenceArray
<T>> with a given lengthpublic static <A extends ReferenceArray> A newInstance(CtorAndArgs<A> arrayCtorAndArgs, long length)
ReferenceArray
> with a given length,
array constructor, and array constructor arguments.A
- The class of the array to be created (extends ReferenceArray)length
- The length of the array.arrayCtorAndArgs
- for creating the arrayReferenceArray
>public static <T,A extends ReferenceArray<T>> A newInstance(long length, java.lang.reflect.Constructor<A> arrayConstructor, java.lang.Object... arrayConstructorArgs)
ReferenceArray
<T>> with a given length,
array constructor, and array constructor arguments.T
- the reference typeA
- The class of the array to be created (extends ReferenceArray<T>)length
- The length of the array.arrayConstructor
- The array constructor to usearrayConstructorArgs
- The arguments to pass to the array constructorReferenceArray
<T>>public static <T,A extends ReferenceArray<T>> A copyInstance(A source) throws java.lang.NoSuchMethodException
ReferenceArray
<T>> instance, using a copy constructor to
replicate the contents of the given source arrayA
- The class of the array to be created (extends ReferenceArray<T>)T
- The class of the element in the array to be createdsource
- The array to replicateReferenceArray
<T>> copied from the source arrayjava.lang.NoSuchMethodException
- if <A> does not have a copy constructorpublic static <T,A extends ReferenceArray<T>> A copyInstance(java.lang.invoke.MethodHandles.Lookup lookup, A source) throws java.lang.NoSuchMethodException
ReferenceArray
<T>> instance, using a copy constructor to
replicate the contents of the given source arrayA
- The class of the array to be created (extends ReferenceArray<T>)T
- The class of the element in the array to be createdlookup
- The lookup object to use for accessing the array's constructorsource
- The array to replicateReferenceArray
<T>> copied from the source arrayjava.lang.NoSuchMethodException
- if <A> does not have a copy constructor