Class RangeSet<T extends Comparable<? super T>>

    • Method Detail

      • add

        public boolean add​(Range<T> range)
        Add a range to this set. Range may be added in any order. If the specified range overlap an existing range, the two range will be merged as of Range.union(org.geotools.util.Range<?>).

        Note: current version do not support open interval (i.e. Range.is[Min/Max]Included() must return true).

        Specified by:
        add in interface Collection<T extends Comparable<? super T>>
        Specified by:
        add in interface Set<T extends Comparable<? super T>>
        Overrides:
        add in class AbstractCollection<Range<T extends Comparable<? super T>>>
        Parameters:
        range - The range to add.
        Returns:
        true if this set changed as a result of the call.
      • add

        public <N> boolean add​(Comparable<? super N> min,
                               Comparable<? super N> max)
                        throws IllegalArgumentException
        Adds a range of values to this set. Range may be added in any order. If the specified range overlap an existing range, the two ranges will be merged.
        Parameters:
        min - The lower value, inclusive.
        max - The upper value, inclusive.
        Returns:
        true if this set changed as a result of the call.
        Throws:
        IllegalArgumentException - if lower is greater than upper.
      • add

        public boolean add​(byte lower,
                           byte upper)
                    throws IllegalArgumentException
        Add a range of values to this set. Range may be added in any order. If the specified range overlap an existing range, the two ranges will be merged.
        Parameters:
        lower - The lower value, inclusive.
        upper - The upper value, inclusive.
        Returns:
        true if this set changed as a result of the call.
        Throws:
        IllegalArgumentException - if lower is greater than upper.
      • add

        public boolean add​(short lower,
                           short upper)
                    throws IllegalArgumentException
        Add a range of values to this set. Range may be added in any order. If the specified range overlap an existing range, the two ranges will be merged.
        Parameters:
        lower - The lower value, inclusive.
        upper - The upper value, inclusive.
        Returns:
        true if this set changed as a result of the call.
        Throws:
        IllegalArgumentException - if lower is greater than upper.
      • add

        public boolean add​(int lower,
                           int upper)
                    throws IllegalArgumentException
        Add a range of values to this set. Range may be added in any order. If the specified range overlap an existing range, the two ranges will be merged.
        Parameters:
        lower - The lower value, inclusive.
        upper - The upper value, inclusive.
        Returns:
        true if this set changed as a result of the call.
        Throws:
        IllegalArgumentException - if lower is greater than upper.
      • add

        public boolean add​(long lower,
                           long upper)
                    throws IllegalArgumentException
        Add a range of values to this set. Range may be added in any order. If the specified range overlap an existing range, the two ranges will be merged.
        Parameters:
        lower - The lower value, inclusive.
        upper - The upper value, inclusive.
        Returns:
        true if this set changed as a result of the call.
        Throws:
        IllegalArgumentException - if lower is greater than upper.
      • add

        public boolean add​(float lower,
                           float upper)
                    throws IllegalArgumentException
        Add a range of values to this set. Range may be added in any order. If the specified range overlap an existing range, the two ranges will be merged.
        Parameters:
        lower - The lower value, inclusive.
        upper - The upper value, inclusive.
        Returns:
        true if this set changed as a result of the call.
        Throws:
        IllegalArgumentException - if lower is greater than upper.
      • add

        public boolean add​(double lower,
                           double upper)
                    throws IllegalArgumentException
        Add a range of values to this set. Range may be added in any order. If the specified range overlap an existing range, the two ranges will be merged.
        Parameters:
        lower - The lower value, inclusive.
        upper - The upper value, inclusive.
        Returns:
        true if this set changed as a result of the call.
        Throws:
        IllegalArgumentException - if lower is greater than upper.
      • remove

        public <N> boolean remove​(Comparable<? super N> min,
                                  Comparable<? super N> max)
                           throws IllegalArgumentException
        Remove a range of values from this set. Range may be removed in any order.
        Parameters:
        min - The lower value to remove, exclusive.
        max - The upper value to remove, exclusive.
        Returns:
        true if this set changed as a result of the call.
        Throws:
        IllegalArgumentException - if lower is greater than upper.
      • remove

        public boolean remove​(byte lower,
                              byte upper)
                       throws IllegalArgumentException
        Remove a range of values from this set. Range may be removed in any order.
        Parameters:
        lower - The lower value to remove, exclusive.
        upper - The upper value to remove, exclusive.
        Returns:
        true if this set changed as a result of the call.
        Throws:
        IllegalArgumentException - if lower is greater than upper.
      • remove

        public boolean remove​(short lower,
                              short upper)
                       throws IllegalArgumentException
        Remove a range of values from this set. Range may be removed in any order.
        Parameters:
        lower - The lower value to remove, exclusive.
        upper - The upper value to remove, exclusive.
        Returns:
        true if this set changed as a result of the call.
        Throws:
        IllegalArgumentException - if lower is greater than upper.
      • remove

        public boolean remove​(int lower,
                              int upper)
                       throws IllegalArgumentException
        Remove a range of values from this set. Range may be removed in any order.
        Parameters:
        lower - The lower value to remove, exclusive.
        upper - The upper value to remove, exclusive.
        Returns:
        true if this set changed as a result of the call.
        Throws:
        IllegalArgumentException - if lower is greater than upper.
      • remove

        public boolean remove​(long lower,
                              long upper)
                       throws IllegalArgumentException
        Remove a range of values from this set. Range may be removed in any order.
        Parameters:
        lower - The lower value to remove, exclusive.
        upper - The upper value to remove, exclusive.
        Returns:
        true if this set changed as a result of the call.
        Throws:
        IllegalArgumentException - if lower is greater than upper.
      • remove

        public boolean remove​(float lower,
                              float upper)
                       throws IllegalArgumentException
        Remove a range of values from this set. Range may be removed in any order.
        Parameters:
        lower - The lower value to remove, exclusive.
        upper - The upper value to remove, exclusive.
        Returns:
        true if this set changed as a result of the call.
        Throws:
        IllegalArgumentException - if lower is greater than upper.
      • remove

        public boolean remove​(double lower,
                              double upper)
                       throws IllegalArgumentException
        Remove a range of values from this set. Range may be removed in any order.
        Parameters:
        lower - The lower value to remove, exclusive.
        upper - The upper value to remove, exclusive.
        Returns:
        true if this set changed as a result of the call.
        Throws:
        IllegalArgumentException - if lower is greater than upper.
      • indexOfRange

        public <T> int indexOfRange​(Comparable<T> value)
        If the specified value is inside a range, returns the index of this range. Otherwise, returns -1.
        Parameters:
        value - The value to search.
        Returns:
        The index of the range which contains this value, or -1 if there is no such range.
      • subSet

        public SortedSet<Range<T>> subSet​(Range<T> lower,
                                          Range<T> upper)
        Returns a view of the portion of this sorted set whose elements range from lower, inclusive, to upper, exclusive.
        Specified by:
        subSet in interface SortedSet<T extends Comparable<? super T>>
        Parameters:
        lower - Low endpoint (inclusive) of the sub set.
        upper - High endpoint (exclusive) of the sub set.
        Returns:
        A view of the specified range within this sorted set.
      • headSet

        public SortedSet<Range<T>> headSet​(Range<T> upper)
        Returns a view of the portion of this sorted set whose elements are strictly less than upper.
        Specified by:
        headSet in interface SortedSet<T extends Comparable<? super T>>
        Parameters:
        upper - High endpoint (exclusive) of the headSet.
        Returns:
        A view of the specified initial range of this sorted set.
      • tailSet

        public SortedSet<Range<T>> tailSet​(Range<T> lower)
        Returns a view of the portion of this sorted set whose elements are greater than or equal to lower.
        Specified by:
        tailSet in interface SortedSet<T extends Comparable<? super T>>
        Parameters:
        lower - Low endpoint (inclusive) of the tailSet.
        Returns:
        A view of the specified final range of this sorted set.
      • equals

        public boolean equals​(Object object)
        Compares the specified object with this set of ranges for equality.
        Specified by:
        equals in interface Collection<T extends Comparable<? super T>>
        Specified by:
        equals in interface Set<T extends Comparable<? super T>>
        Overrides:
        equals in class AbstractSet<Range<T extends Comparable<? super T>>>
        Parameters:
        object - The object to compare with this range.
        Returns:
        true if the given object is equals to this range.
      • toString

        public String toString()
        Returns a string representation of this set of ranges. The returned string is implementation dependent. It is usually provided for debugging purposes.
        Overrides:
        toString in class AbstractCollection<Range<T extends Comparable<? super T>>>