Class Vector.SubSampling
- All Implemented Interfaces:
Serializable,Iterable<Number>,Collection<Number>,List<Number>,RandomAccess
- Enclosing class:
- Vector
-
Field Summary
FieldsModifier and TypeFieldDescription(package private) final intIndex of the first element in the enclosing vector.(package private) final intThe length of this vector.private static final longFor cross-version compatibility.(package private) final intThe index increment.Fields inherited from class java.util.AbstractList
modCount -
Constructor Summary
ConstructorsConstructorDescriptionSubSampling(int first, int step, int length) Creates a new view over the given range. -
Method Summary
Modifier and TypeMethodDescription(package private) VectorReturns the backing vector.buffer()Returns a buffer over the sub-section represented by thisSubSamplinginstance.bytebyteValue(int index) 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) VectorcreateConcatenate(Vector toAppend) Delegates to the enclosing vector if possible.(package private) VectorcreateSubSampling(int first, int step, int length) Delegates to the enclosing vector.(package private) VectorcreateTransform(double scale, double offset) Delegates to the enclosing vector.doubledoubleValue(int index) Returns the value at the given index as adouble.floatfloatValue(int index) Returns the value at the given index as afloat.get(int index) Returns the number at the given index, ornullif none.Returns the type of elements in this vector.intintValue(int index) Returns the value at the given index as anint.booleanisNaN(int index) Returnstrueif the value at the given index isnullorNaN.booleanReturns whether values are convertible tofloattype.booleanDelegates to the enclosing vector.longlongValue(int index) Returns the value at the given index as along.(package private) NumberRange<?>range(IntSupplier indices, int n) Delegates to the enclosing vectorDelegates to the enclosing vector.shortshortValue(int index) Returns the value at the given index as ashort.intsize()Returns the length of this subvector.stringValue(int index) Returns a string representation of the value at the given index.(package private) final inttoBacking(int index) Returns the index where to look for the value in the enclosing vector.(package private) int[]toBacking(int[] index) Returns the index where to look for the value in the enclosing vector.Methods inherited from class org.apache.sis.math.Vector
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, warningMethods inherited from class java.util.AbstractList
add, add, addAll, clear, indexOf, iterator, lastIndexOf, listIterator, listIterator, remove, removeRangeMethods inherited from class java.util.AbstractCollection
addAll, contains, containsAll, isEmpty, remove, removeAll, retainAll, toArray, toArrayMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface java.util.Collection
parallelStream, removeIf, streamMethods 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:
-
first
final int firstIndex of the first element in the enclosing vector. -
step
final int stepThe index increment. May be negative but not zero. -
length
final int lengthThe length of this vector.
-
-
Constructor Details
-
SubSampling
SubSampling(int first, int step, int length) Creates a new view over the given range.
-
-
Method Details
-
backingVector
Vector backingVector()Returns the backing vector.- Overrides:
backingVectorin classVector
-
toBacking
final int toBacking(int index) Returns the index where to look for the value in the enclosing vector. -
toBacking
int[] toBacking(int[] index) Returns the index where to look for the value in the enclosing vector. -
getElementType
Returns the type of elements in this vector.- Specified by:
getElementTypein classVector- Returns:
- the type of elements in this vector.
- See Also:
-
isSinglePrecision
public boolean isSinglePrecision()Returns whether values are convertible tofloattype.- Overrides:
isSinglePrecisionin classVector- Returns:
- whether values in this vector can be casted to
floatprimitive type. - See Also:
-
size
public int size()Returns the length of this subvector. -
isUnsigned
public boolean isUnsigned()Delegates to the enclosing vector.- Overrides:
isUnsignedin classVector- Returns:
trueif the integer values shall be interpreted as unsigned values.
-
isNaN
public boolean isNaN(int index) Description copied from class:VectorReturnstrueif the value at the given index isnullorNaN. -
doubleValue
public double doubleValue(int index) Description copied from class:VectorReturns the value at the given index as adouble. This is the safest method since all primitive types supported byVectorare convertible to thedoubletype.- Specified by:
doubleValuein 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:VectorReturns 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 thedoubletype.The default implementation delegates to
Vector.doubleValue(int)and cast the result tofloat.- Overrides:
floatValuein 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:VectorReturns 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 alongwith 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:VectorReturns 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 theinttype. Subclasses that store or compute their values with theint,shortorbytetype should override this method. -
shortValue
public short shortValue(int index) Description copied from class:VectorReturns 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 theshorttype. Subclasses that store or compute their values with theshortorbytetype should override this method.- Overrides:
shortValuein 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:VectorReturns 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 thebytetype. Subclasses that store or compute their values with thebytetype should override this method. -
stringValue
Description copied from class:VectorReturns 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:
stringValuein 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:
-
get
Description copied from class:VectorReturns the number at the given index, ornullif 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.classbutVector.isUnsigned()returnstrue, then this method will rather return instances ofShortbecause 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 validShortvalues.Vectorcan also wrap arbitraryNumber[]arrays. -
set
Delegates to the enclosing vector. -
createTransform
Delegates to the enclosing vector.- Overrides:
createTransformin classVector
-
createSubSampling
Delegates to the enclosing vector.- Overrides:
createSubSamplingin classVector
-
createConcatenate
Delegates to the enclosing vector if possible.- Overrides:
createConcatenatein 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. -
buffer
Returns a buffer over the sub-section represented by thisSubSamplinginstance.
-