Class Vector.Pick
- All Implemented Interfaces:
Serializable
,Iterable<Number>
,Collection<Number>
,List<Number>
,RandomAccess
- Enclosing class:
- Vector
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final int[]
The pre-selected indexes.private static final long
For cross-version compatibility.Fields inherited from class java.util.AbstractList
modCount
-
Constructor Summary
ConstructorsConstructorDescriptionPick
(int[] indices) Creates a new view over the values at the given indexes. -
Method Summary
Modifier and TypeMethodDescription(package private) Vector
Returns the backing vector.byte
byteValue
(int i) Returns the value at the given index as abyte
.compress
(double tolerance) If the vector cannot be compressed, copies data in a new vector in order to have a smaller vector than the one backing this view.(package private) Vector
createConcatenate
(Vector toAppend) Concatenates the indexes if possible.(package private) Vector
createSubSampling
(int first, int step, int length) Delegates to the enclosing vector.(package private) Vector
createTransform
(double scale, double offset) Delegates to the enclosing vector.double
doubleValue
(int i) Returns the value at the given index as adouble
.float
floatValue
(int i) Returns the value at the given index as afloat
.get
(int i) Returns the number at the given index, ornull
if none.Returns the type of elements in this vector.int
intValue
(int i) Returns the value at the given index as anint
.boolean
isNaN
(int i) Returnstrue
if the value at the given index isnull
orNaN
.boolean
Returns whether values are convertible tofloat
type.boolean
Returnstrue
if integer values shall be interpreted as unsigned values.long
longValue
(int i) Returns the value at the given index as along
.(package private) NumberRange<?>
range
(IntSupplier supplier, int n) Delegates to the enclosing vector.Delegates to the enclosing vector.short
shortValue
(int i) Returns the value at the given index as ashort
.int
size()
Delegates to the enclosing vector.stringValue
(int i) Returns a string representation of the value at the given index.(package private) int[]
toBacking
(int[] i) Returns the indexes where to look for the value in the enclosing vector.Methods inherited from class org.apache.sis.math.Vector
buffer, concatenate, copy, create, create, createForDecimal, createSequence, createSequence, doubleValues, equals, equals, fill, floatValues, hashCode, increment, indexOf, isEmptyOrNaN, isInteger, pick, range, repeat, repetitions, reverse, subList, subSampling, subtract, 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:
-
indices
private final int[] indicesThe pre-selected indexes.
-
-
Constructor Details
-
Pick
Pick(int[] indices) Creates a new view over the values at the given indexes. This constructor does not clone the array; it is caller responsibility to clone it if needed.
-
-
Method Details
-
backingVector
Vector backingVector()Returns the backing vector.- Overrides:
backingVector
in classVector
-
toBacking
int[] toBacking(int[] i) Returns the indexes where to look for the value in the enclosing vector. -
getElementType
Returns the type of elements in this vector.- 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 int size()Delegates to the enclosing vector. -
isUnsigned
public boolean isUnsigned()Description copied from class:Vector
Returnstrue
if integer values shall be interpreted as unsigned values. This method may returntrue
for data stored inbyte[]
,short[]
,int[]
orlong[]
arrays, but never for data stored infloat[]
anddouble[]
arrays. The default implementation returnsfalse
.Unless otherwise noticed in Javadoc, users do not need to care about this information since
Vector
methods will perform automatically the operations needed for unsigned integers.- Overrides:
isUnsigned
in classVector
- Returns:
true
if the integer values shall be interpreted as unsigned values.
-
isNaN
public boolean isNaN(int i) Description copied from class:Vector
Returnstrue
if the value at the given index isnull
orNaN
. -
doubleValue
public double doubleValue(int i) 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:
i
- the index in the [0 … size-1] range.- Returns:
- the value at the given index.
- See Also:
-
floatValue
public float floatValue(int i) 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:
i
- the index in the [0 … size-1] range.- Returns:
- the value at the given index.
- See Also:
-
longValue
public long longValue(int i) 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 i) 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 i) 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:
i
- the index in the [0 … size-1] range.- Returns:
- the value at the given index.
-
byteValue
public byte byteValue(int i) 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. -
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:
i
- the index in the [0 … size-1] range.- Returns:
- a string representation of the value at the given index (may be
null
). - 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
Delegates to the enclosing vector. -
createTransform
Delegates to the enclosing vector.- Overrides:
createTransform
in classVector
-
createSubSampling
Delegates to the enclosing vector.- Overrides:
createSubSampling
in classVector
-
createConcatenate
Concatenates the indexes if possible.- Overrides:
createConcatenate
in classVector
-
range
Delegates to the enclosing vector. -
compress
If the vector cannot be compressed, copies data in a new vector in order to have a smaller vector than the one backing this view. This is advantageous only on the assumption that user do not keep a reference to the original vector afterVector.compress(double)
call.
-