AlgART Home

net.algart.arrays
Interface UpdatableShortArray

All Superinterfaces:
Array, ArrayExchanger, PArray, PFixedArray, PIntegerArray, PNumberArray, ShortArray, UpdatableArray, UpdatablePArray, UpdatablePFixedArray, UpdatablePIntegerArray, UpdatablePNumberArray
All Known Subinterfaces:
MutableShortArray
All Known Implementing Classes:
AbstractUpdatableShortArray

public interface UpdatableShortArray
extends ShortArray, UpdatablePIntegerArray

AlgART array of short values, read/write access, no resizing.

AlgART Laboratory 2007-2013

Since:
JDK 1.5
Version:
1.2
Author:
Daniel Alievsky

Method Summary
Modifier and Type Method and Description
 UpdatableShortArray asUnresizable()
          Returns an unresizable view of this array.
 UpdatableShortArray fill(long position, long count, short value)
          Fills count elements of this array, starting from position index, by the specified value.
 UpdatableShortArray fill(short value)
          Fills all elements of this array by the specified value.
 void setShort(long index, short value)
          Sets the element #index to specified value.
 UpdatableShortArray subArr(long position, long count)
          Equivalent to subArray(position, position + count).
 UpdatableShortArray subArray(long fromIndex, long toIndex)
          Returns a view of the portion of this array between fromIndex, inclusive, and toIndex, exclusive.
 
Methods inherited from interface net.algart.arrays.ShortArray
asImmutable, asTrustedImmutable, buffer, buffer, buffer, buffer, getShort, indexOf, lastIndexOf, mutableClone, mutableType, type, updatableClone, updatableType
 
Methods inherited from interface net.algart.arrays.PFixedArray
getInt, getLong, indexOf, lastIndexOf, maxPossibleValue, minPossibleValue
 
Methods inherited from interface net.algart.arrays.UpdatablePArray
fill, fill, fill, fill, setDouble, setInt, setLong
 
Methods inherited from interface net.algart.arrays.PArray
bitsPerElement, getDouble, indexOf, isZeroFilled, lastIndexOf, maxPossibleValue, minPossibleValue
 
Methods inherited from interface net.algart.arrays.UpdatableArray
asCopyOnNextWrite, copy, copy, copy, setData, setData, setElement, setNonNew, shallowClone, swap, swap, swap
 
Methods inherited from interface net.algart.arrays.Array
byteOrder, capacity, checkUnallowedMutation, elementType, equals, flushResources, flushResources, freeResources, freeResources, getData, getData, getElement, hashCode, isCopyOnNextWrite, isImmutable, isLazy, isNew, isNewReadOnlyView, isUnresizable, length, loadResources, newJavaArray, toString
 

Method Detail

setShort

void setShort(long index,
              short value)
Sets the element #index to specified value.

Parameters:
index - index of element to replace.
value - element to be stored at the specified position.
Throws:
java.lang.IndexOutOfBoundsException - if index is out of range 0..length()-1.

fill

UpdatableShortArray fill(short value)
Fills all elements of this array by the specified value. Equivalent to fill(0, thisArray.length(), value).

Parameters:
value - the value to be stored in all elements of the array.
Returns:
a reference to this array.
See Also:
fill(long, long, short), Arrays.zeroFill(UpdatableArray)

fill

UpdatableShortArray fill(long position,
                         long count,
                         short value)
Fills count elements of this array, starting from position index, by the specified value. Equivalent to the following loop:
 for (long k = 0; k < count; k++) {
     setShort(position + k, value);
 }
but works much faster and checks indexes (and throws possible IndexOutOfBoundsException) in the very beginning.

Parameters:
position - start index (inclusive) to be filled.
count - number of filled elements.
value - the value to be stored in the elements of the array.
Returns:
a reference to this array.
Throws:
java.lang.IndexOutOfBoundsException - for illegal position and count (position < 0 || count < 0 || position + count > length()).
See Also:
fill(short), Arrays.zeroFill(UpdatableArray)

subArray

UpdatableShortArray subArray(long fromIndex,
                             long toIndex)
Description copied from interface: Array
Returns a view of the portion of this array between fromIndex, inclusive, and toIndex, exclusive.

Like List.subList method, this method eliminates the need for explicit range operations. For example, you may use Arrays.sort(UpdatableArray, ArrayComparator) method for sorting a fragment of the array.

Unlike List.subList, the semantics of the array returned by this method is well-defined in any case, even in case of resizing of the source array. Namely, if the internal storage of this or returned array is reallocated, then the returned array will cease to be a view of this array. The only possible reasons for reallocation are the following: calling MutableArray.length(long), MutableArray.ensureCapacity(long) or MutableArray.trim() methods for this array, or any modification of this or returned array in a case when this array is copy-on-next-write. Also, if the length of this array will be reduced, it can lead to clearing some elements in returned array: see comments to MutableArray.length(long) method.

Specified by:
subArray in interface Array
Specified by:
subArray in interface UpdatableArray
Specified by:
subArray in interface UpdatablePArray
Specified by:
subArray in interface UpdatablePFixedArray
Specified by:
subArray in interface UpdatablePIntegerArray
Parameters:
fromIndex - low endpoint (inclusive) of the subarray.
toIndex - high endpoint (exclusive) of the subarray.
Returns:
a view of the specified range within this array.
See Also:
Array.subArr(long, long)

subArr

UpdatableShortArray subArr(long position,
                           long count)
Description copied from interface: Array
Equivalent to subArray(position, position + count). The only possible difference is other exception messages. If position+count>Long.MAX_VALUE (overflow), an exception message is allowed to be not fully correct (maximal speed is more important than absolutely correct exception messages for such exotic situations).

Specified by:
subArr in interface Array
Specified by:
subArr in interface UpdatableArray
Specified by:
subArr in interface UpdatablePArray
Specified by:
subArr in interface UpdatablePFixedArray
Specified by:
subArr in interface UpdatablePIntegerArray
Parameters:
position - start position (inclusive) of the subarray.
count - number of elements in the subarray.
Returns:
a view of the specified range within this array.
See Also:
Array.subArray(long, long)

asUnresizable

UpdatableShortArray asUnresizable()
Description copied from interface: UpdatableArray
Returns an unresizable view of this array. If this array is not resizable already, returns a reference to this object. Query operations on the returned array "read through" and "write through" to this array.

The returned view (when it is not a reference to this object) contains the same elements as this array, but independent length, start offset, capacity, copy-on-next-write and possible other information about array characteristics besides its elements, as for UpdatableArray.shallowClone() method. If modifications of this or returned array characteristics lead to reallocation of the internal storage, then the returned array ceases to be a view of this array. The only possible reasons for reallocation are the following: calling MutableArray.length(long), MutableArray.ensureCapacity(long) or MutableArray.trim() methods for this array, or any modification of this or returned array in a case when this array is copy-on-next-write.

Resizable arrays, created by this package, implement full MutableArray interface, but unresizable ones implement only its UpdatableArray superinterface.

Specified by:
asUnresizable in interface UpdatableArray
Specified by:
asUnresizable in interface UpdatablePArray
Specified by:
asUnresizable in interface UpdatablePFixedArray
Specified by:
asUnresizable in interface UpdatablePIntegerArray
Returns:
an unresizable view of this array.
See Also:
Array.isUnresizable()