Package org.apache.calcite.util
Class IntegerIntervalSet
- java.lang.Object
-
- java.util.AbstractCollection<E>
-
- java.util.AbstractSet<java.lang.Integer>
-
- org.apache.calcite.util.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.AbstractCollection
add, addAll, clear, containsAll, isEmpty, remove, retainAll, toArray, toArray, toString
-
-
-
-
Method Detail
-
visit
private static void visit(java.lang.String s, IntegerIntervalSet.Handler handler)
-
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 interfacejava.util.Collection<java.lang.Integer>
- Specified by:
iterator
in interfacejava.lang.Iterable<java.lang.Integer>
- Specified by:
iterator
in interfacejava.util.Set<java.lang.Integer>
- Specified by:
iterator
in classjava.util.AbstractCollection<java.lang.Integer>
-
size
public int size()
- Specified by:
size
in interfacejava.util.Collection<java.lang.Integer>
- Specified by:
size
in interfacejava.util.Set<java.lang.Integer>
- Specified by:
size
in classjava.util.AbstractCollection<java.lang.Integer>
-
enumerator
private Enumerator<java.lang.Integer> enumerator()
-
contains
public boolean contains(java.lang.Object o)
- Specified by:
contains
in interfacejava.util.Collection<java.lang.Integer>
- Specified by:
contains
in interfacejava.util.Set<java.lang.Integer>
- Overrides:
contains
in classjava.util.AbstractCollection<java.lang.Integer>
-
contains
public boolean contains(int n)
-
-