Package org.apache.sis.math
Class ArrayVector.Floats
java.lang.Object
- All Implemented Interfaces:
Serializable
,Iterable<Number>
,Collection<Number>
,List<Number>
,RandomAccess
,CheckedContainer<Float>
- Direct Known Subclasses:
ArrayVector.Decimal
- Enclosing class:
- ArrayVector<E extends Number>
A vector backed by an array of type
float[]
. In this class, conversions to the double
type
use the standard Java cast operator (i.e. the double
value is padded with zero fraction digits in
its base 2 representation). The ArrayVector.Decimal
subclass overrides this behavior with a more
costly cast that tries to preserve the representation in base 10.-
Nested Class Summary
Nested classes/interfaces inherited from class org.apache.sis.math.ArrayVector
ArrayVector.Decimal, ArrayVector.Doubles
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final float[]
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 TypeMethodDescriptionbuffer()
Wraps this vector in a buffer.(package private) NumberRange<?>
createRange
(float min, float max) Creates a range from the given minimum and maximum values, inclusive.double
doubleValue
(int index) Returns the value at the given index.(package private) final boolean
Returns whether this vector in the given range is equal to the specified vector.void
Sets the value of all elements in the given range.final float
floatValue
(int index) Returns the value at the given index as afloat
.final float[]
Returns a copy of current data as a floating point array.get
(int index) Returns the number at the given index, ornull
if none.Returns the type of elements in the backing array.int
hashCode()
Applies hash code contract specifiedVector.hashCode()
.(package private) final int
indexOf
(int toSearch, int index, boolean equality) Finds index of a match or mismatch (depending onequality
).final boolean
Returnstrue
if this vector is empty or contains onlyNaN
values.final boolean
isNaN
(int index) Returnstrue
if the value at the given index isNaN
.boolean
Returns whether values are convertible tofloat
type.(package private) final NumberRange<?>
range
(IntSupplier indices, int n) Finds the minimum and maximum values in the array or in a subset of the array.final Number
Sets the value at the given index.final int
size()
Returns the length of the backing array.final String
stringValue
(int index) Returns the string representation 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, byteValue, compress, concatenate, copy, create, create, createConcatenate, createForDecimal, createSequence, createSequence, createSubSampling, createTransform, doubleValues, equals, increment, intValue, isInteger, isUnsigned, longValue, pick, range, repeat, repetitions, reverse, shortValue, 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
private final float[] arrayThe backing array.
-
-
Constructor Details
-
Floats
Floats(float[] 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<Float>
- Specified by:
getElementType
in classVector
- Returns:
- the type of elements in this vector.
- See Also:
-
isSinglePrecision
public 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:
-
size
public final int size()Returns the length of the backing array. -
isNaN
public final boolean isNaN(int index) Returnstrue
if the value at the given index isNaN
.- Overrides:
isNaN
in classArrayVector<Float>
- Parameters:
index
- the index in the [0 … size-1] range.- Returns:
true
if the value at the given index isNaN
.
-
stringValue
Returns the string representation at the given index.- 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) Returns the value at the given index.- 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 final 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:
-
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
Sets the value at the given index. -
fill
Sets the value of all elements in the given range. -
indexOf
final int indexOf(int toSearch, int index, boolean equality) Finds index of a match or mismatch (depending onequality
).- Overrides:
indexOf
in classVector
- Parameters:
toSearch
- index of the value to search.index
- index of the first value where to start the search.equality
- whether we search the first equal value, or the first different value.- Returns:
- index of the value found, or the vector size if the value has not been found.
-
isEmptyOrNaN
public final boolean isEmptyOrNaN()Returnstrue
if this vector is empty or contains onlyNaN
values.- Overrides:
isEmptyOrNaN
in classVector
- Returns:
- whether this vector is empty or contains only
NaN
values.
-
equals
Returns whether this vector in the given range is equal to the specified vector.- Overrides:
equals
in classVector
- Parameters:
lower
- index of the first value to compare in this vector, inclusive.upper
- index after the last value to compare in this vector.other
- the other vector to compare values with this vector. May bethis
.otherOffset
- index of the first element to compare in the other vector.- Returns:
- whether values over the specified range of the two vectors are equal.
-
range
Finds the minimum and maximum values in the array or in a subset of the array. -
createRange
Creates a range from the given minimum and maximum values, inclusive. The default implementation creates a range offloat
, but this method is overridden byArrayVector.Decimal
which create a range ofdouble
. -
buffer
Wraps this vector in a buffer. -
floatValues
public final float[] floatValues()Returns a copy of current data as a floating point array.- Overrides:
floatValues
in classVector
- Returns:
- a copy of all floating point values in this vector.
- See Also:
-
hashCode
public int hashCode()Applies hash code contract specifiedVector.hashCode()
.
-