Package org.apache.sis.coverage
Class ToNaN
- All Implemented Interfaces:
Serializable
,Cloneable
,Iterable<Integer>
,Collection<Integer>
,DoubleToIntFunction
,Set<Integer>
Keep trace of allocated
Float.NaN
ordinal values for avoiding range collisions when building categories.
This is a temporary object used only at SampleDimension
construction time for producing values suitable
to MathFunctions.toNanFloat(int)
. Instances of this class are given for toNaN
argument in the
Category
constructor.- Since:
- 1.0
- Version:
- 1.1
-
Field Summary
FieldsModifier and TypeFieldDescription(package private) Number
The value which should be assigned ordinal 0 if that ordinal value is available. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionint
applyAsInt
(double value) Mapping from sample values to ordinal values to be supplied toMathFunctions.toNanFloat(int)
.void
clear()
Sets this function to the same state than after construction.private boolean
isBackground
(double value) Returnstrue
if the specified value is the background value.(package private) void
Removes the NaN value which has been reserved for a qualitative category.Methods inherited from class java.util.HashSet
add, clone, contains, isEmpty, iterator, newHashSet, remove, size, spliterator, toArray, toArray
Methods inherited from class java.util.AbstractSet
equals, hashCode, removeAll
Methods inherited from class java.util.AbstractCollection
addAll, containsAll, retainAll, toString
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.util.Collection
parallelStream, removeIf, stream, toArray
-
Field Details
-
background
Number backgroundThe value which should be assigned ordinal 0 if that ordinal value is available. For performance reason, the background value should be assigned ordinal 0 when possible. This isnull
if unspecified.
-
-
Constructor Details
-
ToNaN
ToNaN()To be constructed only from this package.
-
-
Method Details
-
clear
public void clear()Sets this function to the same state than after construction. This method is invoked when the same builder is reused for creating many sample dimensions. -
isBackground
private boolean isBackground(double value) Returnstrue
if the specified value is the background value. -
applyAsInt
public int applyAsInt(double value) Mapping from sample values to ordinal values to be supplied toMathFunctions.toNanFloat(int)
. That mapping shall ensure that there are no ordinal value collisions between different categories in the sameSampleDimension
.- Specified by:
applyAsInt
in interfaceDoubleToIntFunction
- Parameters:
value
- a real number in theCategory.range
sample value range.- Returns:
- a value between -2097152 and 2097151 inclusive.
-
remove
Removes the NaN value which has been reserved for a qualitative category. This method does nothing ifconverted
is not a NaN value, i.e. if the category is quantitative instead of qualitative.- Parameters:
c
- the presumed qualitative category.
-