-class SubrangeEnumerator : public TypeEnumeratorBase<SubrangeEnumerator> {
- Integer d_int;
- SubrangeBounds d_bounds;
- bool d_direction;// true == +, false == -
-
-public:
-
- SubrangeEnumerator(TypeNode type, TypeEnumeratorProperties * tep = NULL) throw(AssertionException) :
- TypeEnumeratorBase<SubrangeEnumerator>(type),
- d_int(0),
- d_bounds(type.getConst<SubrangeBounds>()),
- d_direction(d_bounds.lower.hasBound()) {
-
- d_int = d_direction ? d_bounds.lower.getBound() : d_bounds.upper.getBound();
-
- Assert(type.getKind() == kind::SUBRANGE_TYPE);
-
- // if we're counting down, there's no lower bound
- Assert(d_direction || !d_bounds.lower.hasBound());
- }
-
- Node operator*() throw(NoMoreValuesException) {
- if(isFinished()) {
- throw NoMoreValuesException(getType());
- }
- return NodeManager::currentNM()->mkConst(Rational(d_int));
- }
-
- SubrangeEnumerator& operator++() throw() {
- if(d_direction) {
- if(!d_bounds.upper.hasBound() || d_int <= d_bounds.upper.getBound()) {
- d_int += 1;
- }
- } else {
- // if we're counting down, there's no lower bound
- d_int -= 1;
- }
- return *this;
- }
-
- bool isFinished() throw() {
- // if we're counting down, there's no lower bound
- return d_direction &&
- d_bounds.upper.hasBound() &&
- d_int > d_bounds.upper.getBound();
- }
-
-};/* class SubrangeEnumerator */
-
-}/* CVC4::theory::arith namespace */
-}/* CVC4::theory namespace */
-}/* CVC4 namespace */