Remove redundant boxing
This commit is contained in:
parent
7b88cb468e
commit
29a737f38b
@ -82,7 +82,7 @@ public class LinearInterpolator implements Cloneable {
|
|||||||
|
|
||||||
if ( y1 != null ) {
|
if ( y1 != null ) {
|
||||||
// Wow, x was a key in the map. Such luck.
|
// Wow, x was a key in the map. Such luck.
|
||||||
return y1.doubleValue();
|
return y1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// we now know that x is not in the map, so we need to find the lower and higher keys.
|
// we now know that x is not in the map, so we need to find the lower and higher keys.
|
||||||
@ -96,16 +96,16 @@ public class LinearInterpolator implements Cloneable {
|
|||||||
Double firstKey = sortMap.firstKey();
|
Double firstKey = sortMap.firstKey();
|
||||||
|
|
||||||
// x is smaller than the first entry in the map.
|
// x is smaller than the first entry in the map.
|
||||||
if ( x < firstKey.doubleValue() ) {
|
if ( x < firstKey) {
|
||||||
y1 = sortMap.get(firstKey);
|
y1 = sortMap.get(firstKey);
|
||||||
return y1.doubleValue();
|
return y1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// floor key is the largest key smaller than x - since we have at least one key,
|
// floor key is the largest key smaller than x - since we have at least one key,
|
||||||
// and x>=firstKey, we know that floorKey != null.
|
// and x>=firstKey, we know that floorKey != null.
|
||||||
Double floorKey = sortMap.subMap(firstKey, x).lastKey();
|
Double floorKey = sortMap.subMap(firstKey, x).lastKey();
|
||||||
|
|
||||||
x1 = floorKey.doubleValue();
|
x1 = floorKey;
|
||||||
y1 = sortMap.get(floorKey);
|
y1 = sortMap.get(floorKey);
|
||||||
|
|
||||||
// Now we need to find the key that is greater or equal to x
|
// Now we need to find the key that is greater or equal to x
|
||||||
@ -113,16 +113,16 @@ public class LinearInterpolator implements Cloneable {
|
|||||||
|
|
||||||
// Check if x is bigger than all the entries.
|
// Check if x is bigger than all the entries.
|
||||||
if ( tailMap.isEmpty() ) {
|
if ( tailMap.isEmpty() ) {
|
||||||
return y1.doubleValue();
|
return y1;
|
||||||
}
|
}
|
||||||
Double ceilKey = tailMap.firstKey();
|
Double ceilKey = tailMap.firstKey();
|
||||||
|
|
||||||
// Check if x is bigger than all the entries.
|
// Check if x is bigger than all the entries.
|
||||||
if ( ceilKey == null ) {
|
if ( ceilKey == null ) {
|
||||||
return y1.doubleValue();
|
return y1;
|
||||||
}
|
}
|
||||||
|
|
||||||
x2 = ceilKey.doubleValue();
|
x2 = ceilKey;
|
||||||
y2 = sortMap.get(ceilKey);
|
y2 = sortMap.get(ceilKey);
|
||||||
|
|
||||||
return (x - x1)/(x2-x1) * (y2-y1) + y1;
|
return (x - x1)/(x2-x1) * (y2-y1) + y1;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user