Class IntervalSet

    • Constructor Detail

      • IntervalSet

        public IntervalSet()
        Default constructor.

        The set is empty with zero capacity.

      • IntervalSet

        public IntervalSet​(int capacity)
        Constructor with capacity.

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

        Parameters:
        capacity - interval capacity
      • IntervalSet

        public IntervalSet​(double[] arr)
        Constructor with an initial interval set.

        The given array must be sorted and containing an even number of elements.

        Parameters:
        arr - initial set content
    • Method Detail

      • add

        public boolean add​(Interval interval)
        Description copied from interface: TimeSet
        Adds key to this set.
        Specified by:
        add in interface TimeSet<Interval>
        Parameters:
        interval - key
        Returns:
        true if added, false otherwise
      • remove

        public boolean remove​(Interval interval)
        Description copied from interface: TimeSet
        Removes key from this set.
        Specified by:
        remove in interface TimeSet<Interval>
        Parameters:
        interval - key
        Returns:
        true if removed, false otherwise
      • size

        public int size()
        Description copied from interface: TimeSet
        Returns the size of this set.
        Specified by:
        size in interface TimeSet<Interval>
        Returns:
        the number of elements in this set
      • isEmpty

        public boolean isEmpty()
        Description copied from interface: TimeSet
        Returns true if this set is empty.
        Specified by:
        isEmpty in interface TimeSet<Interval>
        Returns:
        true if empty, false otherwise
      • getMax

        public Interval getMax()
        Description copied from interface: TimeSet
        Returns the maximum key in the set
        Specified by:
        getMax in interface TimeSet<Interval>
        Returns:
        maximum key, or null if the set is empty.
      • getMin

        public Interval getMin()
        Description copied from interface: TimeSet
        Returns the minimum key in the set
        Specified by:
        getMin in interface TimeSet<Interval>
        Returns:
        minimum key, or null if the set is empty.
      • getMaxDouble

        public Double getMaxDouble()
        Description copied from interface: TimeSet
        Returns the maximum timestamp in the set
        Specified by:
        getMaxDouble in interface TimeSet<Interval>
        Returns:
        maximum timestamp, or null if the set is empty.
      • getMinDouble

        public Double getMinDouble()
        Description copied from interface: TimeSet
        Returns the minimum timestamp in the set
        Specified by:
        getMinDouble in interface TimeSet<Interval>
        Returns:
        minimum timestamp, or null if the set is empty.
      • contains

        public boolean contains​(double timestamp)
        Returns true if this set 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: TimeSet
        Returns true if this set contains key.
        Specified by:
        contains in interface TimeSet<Interval>
        Parameters:
        interval - key
        Returns:
        true if contains, false otherwise
      • getIntervals

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

        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
      • toArray

        public Interval[] toArray()
        Description copied from interface: TimeSet
        Returns an array of all keys in this set.

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

        Specified by:
        toArray in interface TimeSet<Interval>
        Returns:
        array of all keys
      • toPrimitiveArray

        public Object toPrimitiveArray()
        Description copied from interface: TimeSet
        Returns the same result as TimeSet.toArray() but in a primitive array if the underlying storage is in a primitive form.
        Specified by:
        toPrimitiveArray in interface TimeSet<Interval>
        Returns:
        array of all keys
      • clear

        public void clear()
        Description copied from interface: TimeSet
        Empties this set.
        Specified by:
        clear in interface TimeSet<Interval>
      • hashCode

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

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

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