Package net.hydromatic.morel.type
Class RangeExtent
java.lang.Object
net.hydromatic.morel.type.RangeExtent
A type and a range set.
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionRangeExtent(TypeSystem typeSystem, Type type, Map<String, com.google.common.collect.ImmutableRangeSet> rangeSetMap) Creates a RangeExtent. -
Method Summary
Modifier and TypeMethodDescriptionbooleanWhether this extent returns all, or an unbounded number of, the values of its type.private <E extends Comparable<E>>
booleanpopulate(TypeSystem typeSystem, Type type, String path, Map<String, com.google.common.collect.ImmutableRangeSet> rangeSetMap, Consumer<E> consumer) Populates a list (or other consumer) with all values of this type.private <E extends Comparable<E>>
Iterable<E> toList(Type type, TypeSystem typeSystem) Derives the collection of values in the range, or returns empty if the range is infinite.toString()
-
Field Details
-
rangeSetMap
Map from path to range set.The path designates the item within the type.
For example, consider the type
int option list.- "/" relates to the
int option list - "/0/" relates to each
int optionwithin the list - "/0/SOME/" relates to each
intwithin a "SOME" element of the list - "/0/NONE/" relates to each "NONE" element of the list
Using a map
["/O/SOME/" "[0, 3], [6]"]we can generateSOME 0, SOME 1, SOME 2, SOME 3, SOME 6, NONE - "/" relates to the
-
type
-
iterable
-
-
Constructor Details
-
RangeExtent
public RangeExtent(TypeSystem typeSystem, Type type, Map<String, com.google.common.collect.ImmutableRangeSet> rangeSetMap) Creates a RangeExtent.
-
-
Method Details
-
toString
-
isUnbounded
public boolean isUnbounded()Whether this extent returns all, or an unbounded number of, the values of its type.Examples: "(-inf,+inf)" (true), "(-inf,0]" (x ≤ 0), "{(-inf,3),(10,+inf)}" (x < 3 or x > 10) are unbounded; "{}" (false), "{3, 10}" (x in [3, 10]), "(3, 10)" (x ≥ 3 andalso x ≤ 10) are bounded.
-
toList
Derives the collection of values in the range, or returns empty if the range is infinite. -
populate
private <E extends Comparable<E>> boolean populate(TypeSystem typeSystem, Type type, String path, Map<String, com.google.common.collect.ImmutableRangeSet> rangeSetMap, Consumer<E> consumer) Populates a list (or other consumer) with all values of this type. Returns false if this type is not finite and the range is open above or below.
-