Interface IntervalMap<K,​V>

  • Type Parameters:
    K - the key type
    V - the value type
    All Known Implementing Classes:
    IntervalTree

    public interface IntervalMap<K,​V>
    A map that uses intervals (specified as an upper and lower bound) as keys.
    • Method Detail

      • get

        default Optional<V> get​(K key)
        Get the value of the first interval matching the supplied key.
        Parameters:
        key - the key
        Returns:
        the value
      • get

        Optional<V> get​(K lower,
                        K upper)
        Get the first value falling into the interval.
        Parameters:
        lower - the lower bound
        upper - the upper bound
        Returns:
        the value
      • getOrDefault

        default V getOrDefault​(K key,
                               V value)
        Get the first value for the specified key or the supplied default.
        Parameters:
        key - the key
        value - the default value
        Returns:
        the value
      • getOrDefault

        default V getOrDefault​(K lower,
                               K upper,
                               V value)
        Get the first value falling into the interval or the supplied default.
        Parameters:
        lower - the lower bound
        upper - the upper bound
        value - the default value
        Returns:
        the value
      • search

        default Set<V> search​(K key)
        Get the values for all intervals matching the supplied key.
        Parameters:
        key - the key
        Returns:
        the values
      • search

        Set<V> search​(K lower,
                      K upper)
        Get all values falling into the specified interval.
        Parameters:
        lower - the upper bound
        upper - the lower bound
        Returns:
        the values
      • universal

        static <K,​V> IntervalMap<K,​V> universal​(V value)
        Creates a IntervalMap that returns the same value for each key.
        Type Parameters:
        K - the key type
        V - the value type
        Parameters:
        value - the value
        Returns:
        the IntervalMap