Class IntegerIntervalSet

  • All Implemented Interfaces:
    java.lang.Iterable<java.lang.Integer>, java.util.Collection<java.lang.Integer>, java.util.Set<java.lang.Integer>

    public class IntegerIntervalSet
    extends java.util.AbstractSet<java.lang.Integer>
    A set of non-negative integers defined by a sequence of points, intervals, and exclusions.
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      private static interface  IntegerIntervalSet.Handler
      A callback.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private java.lang.String s  
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      private IntegerIntervalSet​(java.lang.String s)  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean contains​(int n)  
      boolean contains​(java.lang.Object o)  
      private Enumerator<java.lang.Integer> enumerator()  
      java.util.Iterator<java.lang.Integer> iterator()  
      static java.util.Set<java.lang.Integer> of​(java.lang.String s)
      Parses a range of integers expressed as a string.
      int size()  
      private static void visit​(java.lang.String s, IntegerIntervalSet.Handler handler)  
      • Methods inherited from class java.util.AbstractSet

        equals, hashCode, removeAll
      • Methods inherited from class java.util.AbstractCollection

        add, addAll, clear, containsAll, isEmpty, remove, retainAll, toArray, toArray, toString
      • Methods inherited from class java.lang.Object

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

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

        forEach
      • Methods inherited from interface java.util.Set

        add, addAll, clear, containsAll, isEmpty, remove, retainAll, spliterator, toArray, toArray
    • Field Detail

      • s

        private final java.lang.String s
    • Constructor Detail

      • IntegerIntervalSet

        private IntegerIntervalSet​(java.lang.String s)
    • Method Detail

      • of

        public static java.util.Set<java.lang.Integer> of​(java.lang.String s)
        Parses a range of integers expressed as a string. The string can contain non-negative integers separated by commas, ranges (represented by a hyphen between two integers), and exclusions (represented by a preceding hyphen). For example, "1,2,3-20,-7,-10-15,12".

        Inclusions and exclusions are performed in the order that they are seen. For example, "1-10,-2-9,3-7,-4-6"

        does contain 3, because it is included by "1-10", excluded by "-2-9" and last included by "3-7". But it does not include 4.
        Parameters:
        s - Range set
      • iterator

        public 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>
        Specified by:
        iterator in interface java.util.Set<java.lang.Integer>
        Specified by:
        iterator in class java.util.AbstractCollection<java.lang.Integer>
      • size

        public int size()
        Specified by:
        size in interface java.util.Collection<java.lang.Integer>
        Specified by:
        size in interface java.util.Set<java.lang.Integer>
        Specified by:
        size in class java.util.AbstractCollection<java.lang.Integer>
      • enumerator

        private Enumerator<java.lang.Integer> enumerator()
      • contains

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

        public boolean contains​(int n)