package com.sri.ai.util.graph2d.core.values;

import static com.sri.ai.util.collect.FunctionIterator.functionIterator;
import static com.sri.ai.util.graph2d.api.variables.Value.value;

import java.util.Iterator;

import com.sri.ai.util.collect.IntegerIterator;
import com.sri.ai.util.graph2d.api.variables.SetOfValues;
import com.sri.ai.util.graph2d.api.variables.Value;

public class SetOfIntegerValues implements SetOfValues {
	
	private int first;
	private int last;
	
	public SetOfIntegerValues(int first, int last) {
		this.first = first;
		this.last = last;
	}
	
	public static SetOfIntegerValues setOfIntegerValues(int first, int last) {
		return new SetOfIntegerValues(first, last);
	}

	public int getFirst() {
		return first;
	}
	
	public int getLast() {
		return last;
	}
	
	@Override
	public Iterator<Value> iterator() {
		return functionIterator(new IntegerIterator(first, last - 1), i -> value(i));
	}

}

@@ -37,19 +37,17 @@
 .values;
-%0D%0A%0D
+%0A
 %0Aimport 
@@ -115,77 +115,9 @@
 tor;
-%0D%0Aimport static com.sri.ai.util.graph2d.api.variables.Value.value;%0D%0A%0D
+%0A
 %0Aimp
@@ -139,19 +139,17 @@
 terator;
-%0D%0A%0D
+%0A
 %0Aimport 
@@ -188,17 +188,16 @@
 terator;
-%0D
 %0Aimport 
@@ -246,17 +246,16 @@
 fValues;
-%0D
 %0Aimport 
@@ -298,19 +298,59 @@
 s.Value;
-%0D%0A%0D
+%0Aimport org.apache.commons.lang3.Validate;%0A
 %0Apublic 
@@ -398,20 +398,18 @@
 Values %7B
-%0D
 %0A%09
-%0D
 %0A%09privat
@@ -420,17 +420,16 @@
 t first;
-%0D
 %0A%09privat
@@ -443,63 +443,301 @@
 ast;
-%0D%0A%09%0D%0A%09public SetOfIntegerValues(int first, int last) %7B%0D
+%0A%0A%09/**%0A%09 * Construct a set of integer values%0A%09 * @param first starting integer%0A%09 * @param last ending integer - inclusive%0A%09 */%0A%09public SetOfIntegerValues(int first, int last) %7B%0A%09%09Validate.isTrue(first %3C= last,%0A%09%09%09%09String.format(%22first=%25d must be less than or equal to last=%25d%22, first, last));%0A
 %0A%09%09t
@@ -754,17 +754,16 @@
 = first;
-%0D
 %0A%09%09this.
@@ -774,24 +774,21 @@
  = last;
-%0D
 %0A%09%7D
-%0D
 %0A%09
-%0D
 %0A%09public
@@ -855,17 +855,16 @@
  last) %7B
-%0D
 %0A%09%09retur
@@ -901,23 +901,20 @@
 , last);
-%0D
 %0A%09%7D
-%0D%0A%0D
+%0A
 %0A%09public
@@ -926,25 +926,24 @@
 getFirst() %7B
-%0D
 %0A%09%09return fi
@@ -946,24 +946,21 @@
 n first;
-%0D
 %0A%09%7D
-%0D
 %0A%09
-%0D
 %0A%09public
@@ -971,25 +971,24 @@
  getLast() %7B
-%0D
 %0A%09%09return la
@@ -994,16 +994,13 @@
 ast;
-%0D
 %0A%09%7D
-%0D
 %0A%09
-%0D
 %0A%09@O
@@ -1006,17 +1006,16 @@
 Override
-%0D
 %0A%09public
@@ -1043,17 +1043,16 @@
 ator() %7B
-%0D
 %0A%09%09retur
@@ -1106,36 +1106,161 @@
 ast 
--
++
  1), 
-i -%3E value(i));%0D%0A%09%7D%0D%0A%0D
+Value::value);%0A%09%7D%0A%0A%09@Override%0A%09public String toString() %7B%0A%09%09return %22SetOfIntegerValues%7B%22 +%0A%09%09%09%09%22first=%22 + first +%0A%09%09%09%09%22, last=%22 + last +%0A%09%09%09%09'%7D';%0A%09%7D
 %0A%7D
-%0D
 %0A

add comments, validation, and fix IntegerIterator end value