Package net.algart.arrays
Interface ObjectInPlaceArray<E>
- All Superinterfaces:
Array
,ObjectArray<E>
- All Known Subinterfaces:
MutableObjectInPlaceArray<E>
,UpdatableObjectInPlaceArray<E>
Special version of ObjectArray
allowing
to load an element without creating new Java object.
The arrays of object created via some memory models
may not implement this interface.
You may check, is this interface implemented, by intstanceof operator.
- Author:
- Daniel Alievsky
-
Method Summary
Modifier and TypeMethodDescriptionCreates one instance ofObjectArray.elementType()
class in some state.getInPlace
(long index, Object resultValue) Copies the content of element #index to the passed resultValue and returns resultValue.Methods inherited from interface net.algart.arrays.Array
asCopyOnNextWrite, byteOrder, capacity, checkUnallowedMutation, equals, flushResources, flushResources, freeResources, freeResources, getData, getData, getElement, hashCode, isCopyOnNextWrite, isEmpty, isImmutable, isLazy, isNew, isNewReadOnlyView, isUnresizable, length, length32, loadResources, newJavaArray, shallowClone, subArr, subArray, toString
Methods inherited from interface net.algart.arrays.ObjectArray
asImmutable, asTrustedImmutable, buffer, buffer, buffer, buffer, cast, elementType, get, indexOf, ja, lastIndexOf, matrix, mutableClone, mutableType, type, updatableClone, updatableType
-
Method Details
-
getInPlace
Copies the content of element #index to the passed resultValue and returns resultValue. Never returns null.This method may work much faster than
Array.getElement(long)
in long loops, because allows to avoid allocating Java objects in the heap.- Parameters:
index
- index of element to load.resultValue
- the object where the retrieved content will be stored.- Returns:
- a reference to resultValue.
- Throws:
IndexOutOfBoundsException
- if index out of range 0..length()-1.NullPointerException
- if resultValue is null.
-
allocateElement
E allocateElement()Creates one instance ofObjectArray.elementType()
class in some state. This method, for example, may be used before a loop of calls ofgetInPlace(long, Object)
.- Returns:
- some instance of
ObjectArray.elementType()
class
-