mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-21 01:01:43 +00:00
[wpimath] Add InterpolatingDoubleTreeMap.ofEntries() (#6635)
Co-authored-by: David Vo <auscompgeek@users.noreply.github.com>
This commit is contained in:
@@ -4,6 +4,8 @@
|
||||
|
||||
package edu.wpi.first.math.interpolation;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Interpolating Tree Maps are used to get values at points that are not defined by making a guess
|
||||
* from points that are defined. This uses linear interpolation.
|
||||
@@ -13,4 +15,19 @@ public class InterpolatingDoubleTreeMap extends InterpolatingTreeMap<Double, Dou
|
||||
public InterpolatingDoubleTreeMap() {
|
||||
super(InverseInterpolator.forDouble(), Interpolator.forDouble());
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an {@link InterpolatingDoubleTreeMap} from the given entries.
|
||||
*
|
||||
* @param entries The entries to add to the map.
|
||||
* @return The map filled with the {@code entries}.
|
||||
*/
|
||||
@SafeVarargs
|
||||
public static InterpolatingDoubleTreeMap ofEntries(Map.Entry<Double, Double>... entries) {
|
||||
InterpolatingDoubleTreeMap map = new InterpolatingDoubleTreeMap();
|
||||
for (var entry : entries) {
|
||||
map.put(entry.getKey(), entry.getValue());
|
||||
}
|
||||
return map;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user