Class InterpolatingTreeMap<K,V>

java.lang.Object
edu.wpi.first.math.interpolation.InterpolatingTreeMap<K,V>
Type Parameters:
K - The type of keys held in this map.
V - The type of values held in this map.
Direct Known Subclasses:
InterpolatingDoubleTreeMap

public class InterpolatingTreeMap<K,V> extends Object
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.

K must implement Comparable, or a Comparator on K can be provided.

  • Constructor Details

    • InterpolatingTreeMap

      public InterpolatingTreeMap(InverseInterpolator<K> inverseInterpolator, Interpolator<V> interpolator)
      Constructs an InterpolatingTreeMap.
      Parameters:
      inverseInterpolator - Function to use for inverse interpolation of the keys.
      interpolator - Function to use for interpolation of the values.
    • InterpolatingTreeMap

      public InterpolatingTreeMap(InverseInterpolator<K> inverseInterpolator, Interpolator<V> interpolator, Comparator<K> comparator)
      Constructs an InterpolatingTreeMap using comparator.
      Parameters:
      inverseInterpolator - Function to use for inverse interpolation of the keys.
      interpolator - Function to use for interpolation of the values.
      comparator - Comparator to use on keys.
  • Method Details

    • put

      public void put(K key, V value)
      Inserts a key-value pair.
      Parameters:
      key - The key.
      value - The value.
    • get

      public V get(K key)
      Returns the value associated with a given key.

      If there's no matching key, the value returned will be an interpolation between the keys before and after the provided one, using the Interpolator and InverseInterpolator provided.

      Parameters:
      key - The key.
      Returns:
      The value associated with the given key.
    • clear

      public void clear()
      Clears the contents.