public class PiecewiseUtilities extends Object
DomainElement1D
and Domain1D
implmentations.Modifier and Type | Method and Description |
---|---|
static int |
binarySearch(double[] array,
double val)
Array binary search taking into account the fact that the input value to search can be NaN
Note: This method is not private in order to allows testing by
. |
static int |
compare(double v1,
double v2)
Comparison between two double values
|
static MathTransformation |
createLinearTransform1D(double scale,
double offset)
Returns a linear transform with the supplied scale and offset values.
|
static MathTransformation |
createLinearTransform1D(Range sourceRange,
Range destinationRange)
Create a linear transform mapping values from
sampleValueRange to geophysicsValueRange . |
static int |
deepHashCode(Object object)
Returns a hash code for the specified object, which may be an array.
|
static void |
domainElementsOverlap(DomainElement1D[] domainElements,
int idx)
Checks whether or not two DomainElement1Ds input range overlaps
|
static double |
doubleValue(Class<? extends Number> type,
Number number,
int direction)
Returns a
double value for the specified number. |
static void |
ensureNonNull(String name,
Object object)
Makes sure that an argument is non-null.
|
static boolean |
equals(double o1,
double o2)
Returns
true if the given doubles are equals. |
static boolean |
equals(Object object1,
Object object2) |
static boolean |
equals(Range outputRange,
Range outputRange2) |
static int |
hash(double value,
int seed)
Alters the given seed with the hash code value computed from the given value.
|
static int |
hash(long value,
int seed)
Alters the given seed with the hash code value computed from the given value.
|
static int |
hash(Object value,
int seed)
Alters the given seed with the hash code value computed from the given value.
|
static boolean |
isSorted(DefaultDomainElement1D[] domains)
Checks if the array is sorted
|
public static void domainElementsOverlap(DomainElement1D[] domainElements, int idx)
domainElements
- to be checkedidx
- index to start withpublic static void ensureNonNull(String name, Object object) throws IllegalArgumentException
name
- Argument name.object
- User argument.IllegalArgumentException
- if object
is null.public static int binarySearch(double[] array, double val)
.public static int compare(double v1, double v2)
public static boolean isSorted(DefaultDomainElement1D[] domains)
public static double doubleValue(Class<? extends Number> type, Number number, int direction)
double
value for the specified number. If direction
is non-zero, then this method will returns the closest
representable number of type type
before or after the double value.type
- The range element class. number
must be an instance of this class (this will not be checked).number
- The number to transform to a double
value.direction
- -1 to return the previous representable number, +1 to return the next representable number, or 0 to return the number with no
change.public static MathTransformation createLinearTransform1D(double scale, double offset)
scale
- The scale factor. May be 0 for a constant transform.offset
- The offset value. May be NaN.public static MathTransformation createLinearTransform1D(Range sourceRange, Range destinationRange)
sampleValueRange
to geophysicsValueRange
.public static int deepHashCode(Object object)
null
, then this method returns 0.Arrays.deepHashCode(Object[])
is invoked.Arrays.hashCode(...)
method
is invoked.Object.hashCode()
is invoked.
This method should be invoked only if the object type is declared exactly as Object
, not as some subtype like
Object[]
, String
or float[]
. In the later cases, use the appropriate Arrays
method instead.
object
- The object to compute hash code. May be null
.public static int hash(Object value, int seed) throws AssertionError
Arrays
method or deepHashCode
instead.
Note on assertions: There is no way to ensure at compile time that this method is not invoked with an array argument, while doing so
would usually be a program error. Performing a systematic argument check would impose a useless overhead for correctly implemented
Object.hashCode()
methods. As a compromise we perform this check at runtime only if assertions are enabled. Using assertions for argument
check in a public API is usually a deprecated practice, but we make an exception for this particular method.
value
- The value whose hash code to compute, or null
.seed
- The hash code value computed so far. If this method is invoked for the first field, then any arbitrary value (preferably different
for each class) is okay.AssertionError
- If assertions are enabled and the given value is an array.public static int hash(double value, int seed)
value
- The value whose hash code to compute.seed
- The hash code value computed so far. If this method is invoked for the first field, then any arbitrary value (preferably different
for each class) is okay.public static int hash(long value, int seed)
byte
and short
primitive types are handled by
this method as well through implicit widening conversion.value
- The value whose hash code to compute.seed
- The hash code value computed so far. If this method is invoked for the first field, then any arbitrary value (preferably different
for each class) is okay.public static boolean equals(double o1, double o2)
true
if the given doubles are equals. Positive and negative zero are considered different, while a NaN value is considered
equal to other NaN values.o1
- The first value to compare.o2
- The second value to compare.true
if both values are equal.Double.equals(java.lang.Object)
Copyright © 2006–2016 GeoSolutions. All rights reserved.