Class IntervalMap<T>

    • Constructor Detail

      • IntervalMap

        public IntervalMap()
        Default constructor.

        The map is empty with zero capacity.

      • IntervalMap

        public IntervalMap​(int capacity)
        Constructor with capacity.

        Using this constructor can improve performances if the number of timestamps is known in advance as it minimizes array resizes.

        Parameters:
        capacity - timestamp capacity
    • Method Detail

      • put

        public boolean put​(Interval interval,
                           T value)
        Description copied from interface: TimeMap
        Put the value at the given key.
        Specified by:
        put in interface TimeMap<Interval,​T>
        Parameters:
        interval - key
        value - value
        Returns:
        true if key is a new key, false otherwise
      • remove

        public boolean remove​(Interval interval)
        Description copied from interface: TimeMap
        Remove the value at the given key.
        Specified by:
        remove in interface TimeMap<Interval,​T>
        Parameters:
        interval - key
        Returns:
        true if the key existed, false otherwise
      • get

        public Object get​(Interval interval,
                          Estimator estimator)
        Description copied from interface: TimeMap
        Get the estimated value for the given interval.

        The estimator is used to determine the way multiple interval values are merged together (e.g average, first, median).

        Specified by:
        get in interface TimeMap<Interval,​T>
        Parameters:
        interval - interval query
        estimator - estimator used
        Returns:
        estimated value
      • get

        public T get​(Interval interval,
                     T defaultValue)
        Description copied from interface: TimeMap
        Get the value for the given key.

        Return defaultValue if the value is not found.

        Specified by:
        get in interface TimeMap<Interval,​T>
        Parameters:
        interval - key
        defaultValue - default value
        Returns:
        found value or the default value if not found
      • toValuesArray

        public T[] toValuesArray()
        Description copied from interface: TimeMap
        Returns all the values as an array.
        Specified by:
        toValuesArray in interface TimeMap<Interval,​T>
        Returns:
        values array
      • size

        public int size()
        Description copied from interface: TimeMap
        Returns the size.
        Specified by:
        size in interface TimeMap<Interval,​T>
        Returns:
        the number of elements in this map
      • isEmpty

        public boolean isEmpty()
        Description copied from interface: TimeMap
        Returns true if this map is empty.
        Specified by:
        isEmpty in interface TimeMap<Interval,​T>
        Returns:
        true if empty, false otherwise
      • contains

        public boolean contains​(double timestamp)
        Returns true if this map contains an interval that starts or ends at timestamp.
        Parameters:
        timestamp - timestamp
        Returns:
        true if contains, false otherwise
      • contains

        public boolean contains​(Interval interval)
        Description copied from interface: TimeMap
        Returns true if this map contains the given key.
        Specified by:
        contains in interface TimeMap<Interval,​T>
        Parameters:
        interval - key
        Returns:
        true if contains, false otherwise
      • getIntervals

        public double[] getIntervals()
        Returns an array of all intervals in this set.

        The intervals are represented in a flat and sorted array (e.g. {[1.0,2.0], [5.0,6.0]}) returns [1.0,2.0,5.0,6.0]).

        This method may return a reference to the underlying array so clients should make a copy if the array is written to.

        Returns:
        array of all intervals
      • clear

        public void clear()
        Description copied from interface: TimeMap
        Empties this map.
        Specified by:
        clear in interface TimeMap<Interval,​T>
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object
      • toString

        public String toString​(TimeFormat timeFormat,
                               org.joda.time.DateTimeZone timeZone)
        Description copied from interface: TimeMap
        Returns this map as a string.
        Specified by:
        toString in interface TimeMap<Interval,​T>
        Parameters:
        timeFormat - time format
        timeZone - time zone
        Returns:
        map as string
      • toString

        public String toString​(TimeFormat timeFormat)
        Description copied from interface: TimeMap
        Returns this map as a string.
        Specified by:
        toString in interface TimeMap<Interval,​T>
        Parameters:
        timeFormat - time format
        Returns:
        map as string