Fixed Bugs with Java Iterators not throwing the correct exception.
This commit is contained in:
+11
-10
@@ -34,7 +34,7 @@ public class ITERATORS
|
||||
/**
|
||||
* Empty Iterator Reference
|
||||
*/
|
||||
public static final EmptyIterator NO_GENERIC_TYPE EMPTY = new EmptyIteratorBRACES();
|
||||
private static final EmptyIterator NO_GENERIC_TYPE EMPTY = new EmptyIteratorBRACES();
|
||||
|
||||
/**
|
||||
* Returns a Immutable EmptyIterator instance that is automatically casted.
|
||||
@@ -735,7 +735,7 @@ public class ITERATORS
|
||||
|
||||
@Override
|
||||
public KEY_TYPE NEXT() {
|
||||
return EMPTY_KEY_VALUE;
|
||||
throw new NoSuchElementException();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -745,7 +745,7 @@ public class ITERATORS
|
||||
|
||||
@Override
|
||||
public KEY_TYPE PREVIOUS() {
|
||||
return EMPTY_KEY_VALUE;
|
||||
throw new NoSuchElementException();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -787,6 +787,7 @@ public class ITERATORS
|
||||
|
||||
@Override
|
||||
public KEY_TYPE NEXT() {
|
||||
if(!hasNext()) throw new NoSuchElementException();
|
||||
return a[from++];
|
||||
}
|
||||
|
||||
@@ -854,7 +855,7 @@ public class ITERATORS
|
||||
|
||||
@Override
|
||||
public T next() {
|
||||
if(!hasNext()) throw new IllegalStateException("End of Iterator");
|
||||
if(!hasNext()) throw new NoSuchElementException();
|
||||
T result = last.next();
|
||||
foundNext = false;
|
||||
return result;
|
||||
@@ -890,7 +891,7 @@ public class ITERATORS
|
||||
|
||||
@Override
|
||||
public T next() {
|
||||
if(!hasNext()) throw new IllegalStateException("End of Iterator");
|
||||
if(!hasNext()) throw new NoSuchElementException();
|
||||
T result = last.next();
|
||||
foundNext = false;
|
||||
return result;
|
||||
@@ -921,7 +922,7 @@ public class ITERATORS
|
||||
|
||||
@Override
|
||||
public KEY_TYPE NEXT() {
|
||||
if(!hasNext()) throw new IllegalStateException("End of Iterator");
|
||||
if(!hasNext()) throw new NoSuchElementException();
|
||||
return sortedElements.GET_KEY(index++);
|
||||
}
|
||||
}
|
||||
@@ -971,7 +972,7 @@ public class ITERATORS
|
||||
|
||||
@Override
|
||||
public KEY_TYPE NEXT() {
|
||||
if(!hasNext()) throw new IllegalStateException("End of Iterator");
|
||||
if(!hasNext()) throw new NoSuchElementException();
|
||||
foundNext = false;
|
||||
return lastFound;
|
||||
}
|
||||
@@ -1008,7 +1009,7 @@ public class ITERATORS
|
||||
|
||||
@Override
|
||||
public KEY_TYPE NEXT() {
|
||||
if(!hasNext()) throw new IllegalStateException("End of Iterator");
|
||||
if(!hasNext()) throw new NoSuchElementException();
|
||||
foundNext = false;
|
||||
return lastFound;
|
||||
}
|
||||
@@ -1031,7 +1032,7 @@ public class ITERATORS
|
||||
|
||||
@Override
|
||||
public KEY_TYPE NEXT() {
|
||||
if(!hasNext()) throw new IllegalStateException("End of Iterator");
|
||||
if(!hasNext()) throw new NoSuchElementException();
|
||||
limit--;
|
||||
return iterator.NEXT();
|
||||
}
|
||||
@@ -1054,7 +1055,7 @@ public class ITERATORS
|
||||
|
||||
@Override
|
||||
public KEY_TYPE NEXT() {
|
||||
if(!hasNext()) throw new IllegalStateException("End of Iterator");
|
||||
if(!hasNext()) throw new NoSuchElementException();
|
||||
KEY_TYPE result = iterator.NEXT();
|
||||
action.accept(result);
|
||||
return result;
|
||||
|
||||
@@ -27,7 +27,7 @@ public class LISTS
|
||||
/**
|
||||
* Empty List reference
|
||||
*/
|
||||
public static final EmptyList NO_GENERIC_TYPE EMPTY = new EmptyListBRACES();
|
||||
private static final EmptyList NO_GENERIC_TYPE EMPTY = new EmptyListBRACES();
|
||||
|
||||
/**
|
||||
* Returns a Immutable EmptyList instance that is automatically casted.
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package speiger.src.collections.PACKAGE.utils;
|
||||
|
||||
import java.util.NoSuchElementException;
|
||||
#if TYPE_BOOLEAN
|
||||
import speiger.src.collections.booleans.collections.BooleanIterator;
|
||||
import speiger.src.collections.booleans.sets.AbstractBooleanSet;
|
||||
@@ -34,7 +35,7 @@ public class SETS
|
||||
/**
|
||||
* Empty Set Variable
|
||||
*/
|
||||
public static final SET NO_GENERIC_TYPE EMPTY = new EmptySetBRACES();
|
||||
private static final SET NO_GENERIC_TYPE EMPTY = new EmptySetBRACES();
|
||||
|
||||
/**
|
||||
* EmptySet getter
|
||||
@@ -216,10 +217,10 @@ public class SETS
|
||||
return new ITERATOR KEY_GENERIC_TYPE() {
|
||||
boolean next = true;
|
||||
@Override
|
||||
public boolean hasNext() { return next = false; }
|
||||
public boolean hasNext() { return next; }
|
||||
@Override
|
||||
public KEY_TYPE NEXT() {
|
||||
if(!next) throw new IllegalStateException();
|
||||
if(!hasNext()) throw new NoSuchElementException();
|
||||
next = false;
|
||||
return element;
|
||||
}
|
||||
|
||||
+6
-1
@@ -1,6 +1,7 @@
|
||||
package speiger.src.collections.PACKAGE.utils;
|
||||
|
||||
import java.util.Comparator;
|
||||
import java.util.NoSuchElementException;
|
||||
import java.util.Spliterator;
|
||||
#if PRIMITIVES
|
||||
import java.util.Spliterator.JAVA_SPLIT_ITERATOR;
|
||||
@@ -329,7 +330,11 @@ public class SPLIT_ITERATORS
|
||||
}
|
||||
|
||||
@Override
|
||||
public KEY_TYPE NEXT() { return array[index++]; }
|
||||
public KEY_TYPE NEXT() {
|
||||
if(!hasNext()) throw new NoSuchElementException();
|
||||
return array[index++];
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasNext() { return index < fence; }
|
||||
}
|
||||
|
||||
+15
-14
@@ -57,7 +57,21 @@ public class MAPS
|
||||
/**
|
||||
* Empty Map Variable
|
||||
*/
|
||||
public static final MAP NO_KV_GENERIC_TYPE EMPTY = new EmptyMapKV_BRACES();
|
||||
private static final MAP NO_KV_GENERIC_TYPE EMPTY = new EmptyMapKV_BRACES();
|
||||
|
||||
/**
|
||||
* Empty Map getter function that autocasts to the desired Key and Value
|
||||
* @Type(T)
|
||||
* @ValueType(V)
|
||||
* @return empty map of desired type
|
||||
*/
|
||||
public static GENERIC_KEY_VALUE_BRACES MAP KEY_VALUE_GENERIC_TYPE empty() {
|
||||
#if TYPE_OBJECT || VALUE_OBJECT
|
||||
return (MAP KEY_VALUE_GENERIC_TYPE)EMPTY;
|
||||
#else
|
||||
return EMPTY;
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif
|
||||
/**
|
||||
@@ -104,19 +118,6 @@ public class MAPS
|
||||
}
|
||||
|
||||
#if !TYPE_BOOLEAN
|
||||
/**
|
||||
* Empty Map getter function that autocasts to the desired Key and Value
|
||||
* @Type(T)
|
||||
* @ValueType(V)
|
||||
* @return empty map of desired type
|
||||
*/
|
||||
public static GENERIC_KEY_VALUE_BRACES MAP KEY_VALUE_GENERIC_TYPE empty() {
|
||||
#if TYPE_OBJECT || VALUE_OBJECT
|
||||
return (MAP KEY_VALUE_GENERIC_TYPE)EMPTY;
|
||||
#else
|
||||
return EMPTY;
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function that creates a Helper wrapper to synchronize access into the map.
|
||||
|
||||
Reference in New Issue
Block a user