Class ExtendedArray<T>
- java.lang.Object
-
- elki.utilities.datastructures.arraylike.ExtendedArray<T>
-
- Type Parameters:
T
- Object type
- All Implemented Interfaces:
ArrayAdapter<T,ExtendedArray<T>>
public class ExtendedArray<T> extends java.lang.Object implements ArrayAdapter<T,ExtendedArray<T>>
Class to extend an array with a single element virtually.- Since:
- 0.5.0
- Author:
- Erich Schubert
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
ExtendedArray(java.lang.Object array, ArrayAdapter<T,java.lang.Object> getter, T extra)
Constructor.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static <T,A>
ExtendedArray<T>extend(A array, ArrayAdapter<T,A> getter, T extra)
Static wrapper that has a nicer generics signature.T
get(ExtendedArray<T> array, int off)
Get the off'th item from the array.int
size(ExtendedArray<T> array)
Get the size of the array.
-
-
-
Field Detail
-
array
final java.lang.Object array
The array
-
getter
final ArrayAdapter<T,java.lang.Object> getter
The array adapter
-
extra
final T extra
The extra element
-
size
final int size
Our size
-
-
Constructor Detail
-
ExtendedArray
protected ExtendedArray(java.lang.Object array, ArrayAdapter<T,java.lang.Object> getter, T extra)
Constructor.- Parameters:
array
- Original arraygetter
- Adapter for arrayextra
- Extra element
-
-
Method Detail
-
size
public int size(ExtendedArray<T> array)
Description copied from interface:ArrayAdapter
Get the size of the array.- Specified by:
size
in interfaceArrayAdapter<T,ExtendedArray<T>>
- Parameters:
array
- Array-like thing- Returns:
- Size
-
get
public T get(ExtendedArray<T> array, int off)
Description copied from interface:ArrayAdapter
Get the off'th item from the array.- Specified by:
get
in interfaceArrayAdapter<T,ExtendedArray<T>>
- Parameters:
array
- Array to get fromoff
- Offset- Returns:
- Item at offset off
-
extend
public static <T,A> ExtendedArray<T> extend(A array, ArrayAdapter<T,A> getter, T extra)
Static wrapper that has a nicer generics signature.- Parameters:
array
- Array to extendgetter
- Getter for arrayextra
- Extra element- Returns:
- Extended array
-
-