plugins.adufour.vars.lang
Class VarArray<T>
java.lang.Object
plugins.adufour.vars.lang.Var<A>
plugins.adufour.vars.lang.VarGenericArray<T[]>
plugins.adufour.vars.lang.VarArray<T>
- Type Parameters:
T
- the inner type of the array
- All Implemented Interfaces:
- icy.file.xml.XMLPersistent, java.lang.Iterable<T>, ArrayType, VarListener<T[]>
- Direct Known Subclasses:
- VarDoubleArray, VarFloatArray, VarIntegerArray, VarROIArray
public class VarArray<T>
- extends VarGenericArray<T[]>
- implements java.lang.Iterable<T>
Convenience class defining a generic array of elements based on the specified inner type.
The type of the underlying array cannot be changed. To creates arrays of changeable types, use
VarMutableArray
instead.
NOTE: this class provides convenience methods to add elements (similarly to the ArrayList
class, however performance on large arrays is not optimal. For performance-critical applications,
use the VarArray
instead
- Author:
- Alexandre Dufour
Constructor Summary |
VarArray(java.lang.String name,
java.lang.Class<T[]> type,
T[] defaultValue)
Creates a new array variable |
Method Summary |
void |
add(T... elements)
Inserts the specified elements at the end of this array. |
java.util.Iterator<T> |
iterator()
|
Methods inherited from class plugins.adufour.vars.lang.Var |
addListener, createVarEditor, createVarViewer, fireVariableChanged, fireVariableChanged, getDefaultEditorModel, getDefaultValue, getIterableReferrers, getName, getReference, getReferencingPolicy, getReferrers, getType, getTypeAsString, getValue, getValueAsString, getValueAsString, isEnabled, isOptional, isReferenced, loadFromXML, prettyPrint, referenceChanged, removeListener, removeListeners, saveToXML, setDefaultEditorModel, setEnabled, setOptional, setReference, setReferencingPolicy, setValue, toString, valueChanged |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
VarArray
public VarArray(java.lang.String name,
java.lang.Class<T[]> type,
T[] defaultValue)
- Creates a new array variable
- Parameters:
name
- the variable nametype
- the data type of the array (including the []
)defaultValue
- the initial array
add
public void add(T... elements)
- Inserts the specified elements at the end of this array. This methods acts similarly to
ArrayList.add(Object)
: a old array is replaced by a new array where the contents of
the old array is copied and the specified element is added last
- Parameters:
elements
- the elements to add
iterator
public java.util.Iterator<T> iterator()
- Specified by:
iterator
in interface java.lang.Iterable<T>