Class IntegerRange

  • All Implemented Interfaces:
    java.lang.Iterable<java.lang.Integer>, java.util.Collection<java.lang.Integer>
    Direct Known Subclasses:
    IntegerRange.Ascending, IntegerRange.Descending

    public abstract class IntegerRange
    extends java.lang.Object
    implements java.util.Collection<java.lang.Integer>
    A range of integers.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected int max
      The upper boundary.
      protected int min
      The lower boundary.
    • Constructor Summary

      Constructors 
      Constructor Description
      IntegerRange​(int from, int to)
      Creates a new range.
    • Method Summary

      All Methods Static Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      boolean add​(java.lang.Integer e)  
      boolean addAll​(java.util.Collection<? extends java.lang.Integer> c)  
      void clear()  
      boolean contains​(java.lang.Object o)  
      boolean containsAll​(java.util.Collection<?> c)  
      static IntegerRange create​(int from, int to)
      Creates a range, ascending or descending depending on boundaries order.
      boolean equals​(java.lang.Object obj)  
      int getMax()
      Gets the interval maximum value.
      int getMin()
      Gets the interval minimum value.
      int hashCode()  
      boolean isEmpty()  
      abstract java.util.Iterator<java.lang.Integer> iterator()  
      boolean remove​(java.lang.Object o)  
      boolean removeAll​(java.util.Collection<?> c)  
      boolean retainAll​(java.util.Collection<?> c)  
      int size()  
      java.lang.Object[] toArray()  
      <T> T[] toArray​(T[] array)  
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
      • Methods inherited from interface java.util.Collection

        parallelStream, removeIf, spliterator, stream
      • Methods inherited from interface java.lang.Iterable

        forEach
    • Field Detail

      • min

        protected final int min
        The lower boundary.
      • max

        protected final int max
        The upper boundary.
    • Constructor Detail

      • IntegerRange

        public IntegerRange​(int from,
                            int to)
        Creates a new range.
        Parameters:
        from - the lower inclusive boundary
        to - the higher inclusive boundary
    • Method Detail

      • create

        public static IntegerRange create​(int from,
                                          int to)
        Creates a range, ascending or descending depending on boundaries order.
        Parameters:
        from - the lower inclusive boundary
        to - the higher inclusive boundary
        Returns:
        a range
      • add

        public boolean add​(java.lang.Integer e)
        Specified by:
        add in interface java.util.Collection<java.lang.Integer>
      • addAll

        public boolean addAll​(java.util.Collection<? extends java.lang.Integer> c)
        Specified by:
        addAll in interface java.util.Collection<java.lang.Integer>
      • clear

        public void clear()
        Specified by:
        clear in interface java.util.Collection<java.lang.Integer>
      • contains

        public boolean contains​(java.lang.Object o)
        Specified by:
        contains in interface java.util.Collection<java.lang.Integer>
      • containsAll

        public boolean containsAll​(java.util.Collection<?> c)
        Specified by:
        containsAll in interface java.util.Collection<java.lang.Integer>
      • equals

        public boolean equals​(java.lang.Object obj)
        Specified by:
        equals in interface java.util.Collection<java.lang.Integer>
        Overrides:
        equals in class java.lang.Object
      • getMax

        public int getMax()
        Gets the interval maximum value.
        Returns:
        the high boundary
      • getMin

        public int getMin()
        Gets the interval minimum value.
        Returns:
        the low boundary
      • hashCode

        public int hashCode()
        Specified by:
        hashCode in interface java.util.Collection<java.lang.Integer>
        Overrides:
        hashCode in class java.lang.Object
      • isEmpty

        public boolean isEmpty()
        Specified by:
        isEmpty in interface java.util.Collection<java.lang.Integer>
      • iterator

        public abstract java.util.Iterator<java.lang.Integer> iterator()
        Specified by:
        iterator in interface java.util.Collection<java.lang.Integer>
        Specified by:
        iterator in interface java.lang.Iterable<java.lang.Integer>
      • remove

        public boolean remove​(java.lang.Object o)
        Specified by:
        remove in interface java.util.Collection<java.lang.Integer>
      • removeAll

        public boolean removeAll​(java.util.Collection<?> c)
        Specified by:
        removeAll in interface java.util.Collection<java.lang.Integer>
      • retainAll

        public boolean retainAll​(java.util.Collection<?> c)
        Specified by:
        retainAll in interface java.util.Collection<java.lang.Integer>
      • size

        public int size()
        Specified by:
        size in interface java.util.Collection<java.lang.Integer>
      • toArray

        public java.lang.Object[] toArray()
        Specified by:
        toArray in interface java.util.Collection<java.lang.Integer>
      • toArray

        public <T> T[] toArray​(T[] array)
        Specified by:
        toArray in interface java.util.Collection<java.lang.Integer>