Class ArrayVector.ASCII
- All Implemented Interfaces:
Serializable
,Iterable<Number>
,Collection<Number>
,List<Number>
,RandomAccess
,CheckedContainer<Double>
- Enclosing class:
- ArrayVector<E extends Number>
String[]
.
This is not recommended, but happen for example in GDAL extensions for GeoTIFF files.-
Nested Class Summary
Nested classes/interfaces inherited from class org.apache.sis.math.ArrayVector
ArrayVector.Decimal, ArrayVector.Doubles
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final String[]
The backing array.private static final long
For cross-version compatibility.Fields inherited from class java.util.AbstractList
modCount
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbyte
byteValue
(int index) Returns the value at the given index as abyte
.double
doubleValue
(int index) Returns the value at the given index as adouble
.void
Sets the value of all elements in the given range.float
floatValue
(int index) Returns the value at the given index as afloat
.get
(int index) Returns the number at the given index, ornull
if none.Returns the type of elements in the backing array.int
intValue
(int index) Returns the value at the given index as anint
.boolean
isNaN
(int index) Returnstrue
if the element at the given index is null or NaN.final boolean
Returns whether values are convertible tofloat
type.long
longValue
(int index) Returns the value at the given index as along
.final Number
Stores the given value in this vector and returns the previous value.short
shortValue
(int index) Returns the value at the given index as ashort
.int
size()
Returns the number of elements in this vector.stringValue
(int index) Returns a string representation of the value at the given index.Methods inherited from class org.apache.sis.math.ArrayVector
compress, compress, newInstance, verifyType
Methods inherited from class org.apache.sis.math.Vector
backingVector, buffer, compress, concatenate, copy, create, create, createConcatenate, createForDecimal, createSequence, createSequence, createSubSampling, createTransform, doubleValues, equals, equals, floatValues, hashCode, increment, indexOf, isEmptyOrNaN, isInteger, isUnsigned, pick, range, range, repeat, repetitions, reverse, subList, subSampling, subtract, toBacking, toString, transform, warning
Methods inherited from class java.util.AbstractList
add, add, addAll, clear, indexOf, iterator, lastIndexOf, listIterator, listIterator, remove, removeRange
Methods inherited from class java.util.AbstractCollection
addAll, contains, containsAll, isEmpty, remove, removeAll, retainAll, toArray, toArray
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.util.Collection
parallelStream, removeIf, stream, toArray
Methods inherited from interface java.util.List
addAll, contains, containsAll, isEmpty, remove, removeAll, replaceAll, retainAll, sort, spliterator, toArray, toArray
-
Field Details
-
serialVersionUID
private static final long serialVersionUIDFor cross-version compatibility.- See Also:
-
array
The backing array.
-
-
Constructor Details
-
ASCII
ASCII(String[] array) Creates a new vector for the given array.
-
-
Method Details
-
getElementType
Returns the type of elements in the backing array.- Specified by:
getElementType
in interfaceCheckedContainer<Double>
- Specified by:
getElementType
in classVector
- Returns:
- the type of elements in this vector.
- See Also:
-
isSinglePrecision
public final boolean isSinglePrecision()Returns whether values are convertible tofloat
type.- Overrides:
isSinglePrecision
in classVector
- Returns:
- whether values in this vector can be casted to
float
primitive type. - See Also:
-
isNaN
public boolean isNaN(int index) Returnstrue
if the element at the given index is null or NaN.- Overrides:
isNaN
in classArrayVector<Double>
- Parameters:
index
- the index in the [0 … size-1] range.- Returns:
true
if the value at the given index isNaN
.
-
size
public int size()Description copied from class:Vector
Returns the number of elements in this vector. -
stringValue
Description copied from class:Vector
Returns a string representation of the value at the given index. Invoking this method is generally equivalent to invokingString.valueOf(get(index))
except if the values are unsigned integers.- Specified by:
stringValue
in classVector
- Parameters:
index
- the index in the [0 … size-1] range.- Returns:
- a string representation of the value at the given index (may be
null
). - See Also:
-
doubleValue
public double doubleValue(int index) Description copied from class:Vector
Returns the value at the given index as adouble
. This is the safest method since all primitive types supported byVector
are convertible to thedouble
type.- Specified by:
doubleValue
in classVector
- Parameters:
index
- the index in the [0 … size-1] range.- Returns:
- the value at the given index.
- See Also:
-
floatValue
public float floatValue(int index) Description copied from class:Vector
Returns the value at the given index as afloat
. This method may result in a lost of precision if this vector stores or computes its values with thedouble
type.The default implementation delegates to
Vector.doubleValue(int)
and cast the result tofloat
.- Overrides:
floatValue
in classVector
- Parameters:
index
- the index in the [0 … size-1] range.- Returns:
- the value at the given index.
- See Also:
-
longValue
public long longValue(int index) Description copied from class:Vector
Returns the value at the given index as along
. If this vector uses floating point values, the value is rounded to the nearest integer.The default implementation delegates to
Vector.doubleValue(int)
and verifies if the result can be rounded to along
with an error not greater than 0.5. Subclasses that store or compute their values with an integer type should override this method. -
intValue
public int intValue(int index) Description copied from class:Vector
Returns the value at the given index as anint
. If this vector uses floating point values, the value is rounded to the nearest integer.The default implementation delegates to
Vector.longValue(int)
and verifies if the result fits in theint
type. Subclasses that store or compute their values with theint
,short
orbyte
type should override this method. -
shortValue
public short shortValue(int index) Description copied from class:Vector
Returns the value at the given index as ashort
. If this vector uses floating point values, the value is rounded to the nearest integer.The default implementation delegates to
Vector.longValue(int)
and verifies if the result fits in theshort
type. Subclasses that store or compute their values with theshort
orbyte
type should override this method.- Overrides:
shortValue
in classVector
- Parameters:
index
- the index in the [0 … size-1] range.- Returns:
- the value at the given index.
-
byteValue
public byte byteValue(int index) Description copied from class:Vector
Returns the value at the given index as abyte
. If this vector uses floating point values, the value is rounded to the nearest integer.The default implementation delegates to
Vector.longValue(int)
and verifies if the result fits in thebyte
type. Subclasses that store or compute their values with thebyte
type should override this method. -
get
Description copied from class:Vector
Returns the number at the given index, ornull
if none. The object returned by this method is usually an instance of the class returned byVector.getElementType()
, but may also be an instance of a wider type if this is necessary for representing the values.Example: ifThe class of returned objects should be stable. For example, this method should not use different types for different range of values. This stability is recommended but not guaranteed becauseVector.getElementType()
returnsByte.class
butVector.isUnsigned()
returnstrue
, then this method will rather return instances ofShort
because that type is the smallest Java primitive type capable to hold byte values in the [0 … 255] range. But the elements are still stored internally asbyte
, and the vector cannot accept values outside the [0 … 255] range even if they are validShort
values.Vector
can also wrap arbitraryNumber[]
arrays. -
set
Stores the given value in this vector and returns the previous value. -
fill
Sets the value of all elements in the given range.
-