public class RangeSet extends EvalSet
EvalSet.SubsetIterator<E>
Modifier and Type | Field and Description |
---|---|
protected net.sourceforge.czt.z.util.Factory |
factory_ |
static RangeSet |
integers
The set of all integers.
|
protected BigInteger |
lower_
The exact value of the lower bound, or null if not known.
|
protected String |
name_
The name of this RangeSet ("" if not known)
|
protected BigInteger |
upper_
The exact value of the upper bound, or null if not known.
|
INFINITE_SIZE, UNKNOWN_SIZE
Constructor and Description |
---|
RangeSet(BigInteger lo,
BigInteger up) |
RangeSet(BigInteger lo,
BigInteger up,
String name) |
Modifier and Type | Method and Description |
---|---|
boolean |
contains(Object e) |
boolean |
equals(Object other)
This implementation of equals handles two RangeSets efficiently.
|
BigInteger |
getLower()
The lower bound on numeric elements, if any, else null.
|
static int |
getNumIterSize() |
BigInteger |
getUpper()
The upper bound on numeric elements, if any, else null.
|
RangeSet |
intersect(BigInteger lo,
BigInteger up)
Calculates the exact intersection of this range with (lo..up).
|
RangeSet |
intersect(RangeSet other)
Calculates the exact intersection of two ranges.
|
boolean |
isEmpty()
true iff this range is empty.
|
boolean |
isFinite()
true iff there is a lower bound and an upper bound.
|
Iterator<net.sourceforge.czt.z.ast.Expr> |
iterator()
Iterate through all members of the set.
|
static String |
LimitString(BigInteger limit)
Returns a possibly-null limit as a string.
|
ListIterator<net.sourceforge.czt.z.ast.Expr> |
listIterator()
Iterates from low to high if there is a lower bound,
otherwise it iterates from high to low.
|
static BigInteger |
maxNeg(BigInteger i1,
BigInteger i2)
Calculates the maximum of two optional numbers,
with null interpreted as being negative infinity.
|
static BigInteger |
maxPos(BigInteger i1,
BigInteger i2)
Calculates the maximum of two optional numbers,
with null interpreted as being positive infinity.
|
BigInteger |
maxSize()
Returns the exact size of the set, or
null if it is infinite.
|
static BigInteger |
minNeg(BigInteger i1,
BigInteger i2)
Calculates the minimum of two optional numbers,
with null interpreted as being negative infinity.
|
static BigInteger |
minPos(BigInteger i1,
BigInteger i2)
Calculates the minimum of two optional numbers,
with null interpreted as being positive infinity.
|
static void |
setNumIterSize(int size)
Set the maximum number of integer values we should iterate
through before throwing an EvalException.
|
static void |
setNumIterSize(String value) |
int |
size()
Returns the exact size of the set,
or MAX_VALUE if the set is infinite or
has cardinality greater than MAX_VALUE.
|
Iterator<net.sourceforge.czt.z.ast.Expr> |
sortedIterator()
Iterate through all members of the set in sorted order.
|
Iterator<net.sourceforge.czt.z.ast.Expr> |
subsetIterator(EvalSet otherSet)
Iterate through the intersection of this set
and the 'other' set.
|
String |
toString()
Each subclass should implement a nice toString.
|
RangeSet |
union(BigInteger lo,
BigInteger up)
Calculates the 'generous union' of this range with (lo..up).
|
RangeSet |
union(RangeSet other)
Calculates the 'generous union' of two ranges.
|
accept, add, addAll, clear, containsAll, estSize, estSubsetSize, getAnn, getAnns, hashCode, matchIterator, remove, removeAll, retainAll, toArray, toArray
create, getChildren
annsSize, getFactory, hasAnn, hasAnn, removeAnn, removeAnn
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
spliterator
parallelStream, removeIf, stream
protected BigInteger lower_
protected BigInteger upper_
protected String name_
protected net.sourceforge.czt.z.util.Factory factory_
public static final RangeSet integers
public RangeSet(BigInteger lo, BigInteger up)
public RangeSet(BigInteger lo, BigInteger up, String name)
public static int getNumIterSize()
public static void setNumIterSize(int size)
size
- The maximum number of integerspublic static void setNumIterSize(String value)
public boolean isFinite()
public boolean isEmpty()
public int size()
public BigInteger maxSize()
public boolean contains(Object e)
public Iterator<net.sourceforge.czt.z.ast.Expr> iterator()
EvalSet
iterator
in interface Iterable<net.sourceforge.czt.z.ast.Expr>
iterator
in interface Collection<net.sourceforge.czt.z.ast.Expr>
iterator
in interface Set<net.sourceforge.czt.z.ast.Expr>
iterator
in class EvalSet
public ListIterator<net.sourceforge.czt.z.ast.Expr> listIterator()
listIterator
in class EvalSet
public Iterator<net.sourceforge.czt.z.ast.Expr> sortedIterator()
EvalSet
sortedIterator
in class EvalSet
public Iterator<net.sourceforge.czt.z.ast.Expr> subsetIterator(EvalSet otherSet)
EvalSet
EvalSet provides a default implementation that it iterates through the smaller of the two sets and checks membership in the other. TODO: add unit tests for this.
subsetIterator
in class EvalSet
public BigInteger getLower()
EvalSet
FlatEvalSet provides a default implementation that always returns null.
public BigInteger getUpper()
EvalSet
EvalSet provides a default implementation that always returns null.
public boolean equals(Object other)
public static BigInteger minNeg(BigInteger i1, BigInteger i2)
i1
- null means negative infinityi2
- null means negative infinitypublic static BigInteger minPos(BigInteger i1, BigInteger i2)
i1
- null means positive infinityi2
- null means positive infinitypublic static BigInteger maxNeg(BigInteger i1, BigInteger i2)
i1
- null means negative infinityi2
- null means negative infinitypublic static BigInteger maxPos(BigInteger i1, BigInteger i2)
i1
- null means positive infinityi2
- null means positive infinitypublic RangeSet union(RangeSet other)
public RangeSet union(BigInteger lo, BigInteger up)
public RangeSet intersect(RangeSet other)
public RangeSet intersect(BigInteger lo, BigInteger up)
public static String LimitString(BigInteger limit)
Copyright © 2003–2016 Community Z Tools Project. All rights reserved.