Made MappedForeach package private (foreach returns Iterable now) and changed next() to go through the bounds check.

This commit is contained in:
Ioannis Tsakpinis 2011-07-13 12:44:25 +00:00
parent 9aafabd728
commit 0033f1cc95
2 changed files with 3 additions and 4 deletions

View File

@ -38,7 +38,7 @@ import java.util.Iterator;
*
* @author Riven
*/
public class MappedForeach<T extends MappedObject> implements Iterable<T> {
final class MappedForeach<T extends MappedObject> implements Iterable<T> {
final T mapped;
final int elementCount;
@ -58,8 +58,7 @@ public class MappedForeach<T extends MappedObject> implements Iterable<T> {
}
public T next() {
mapped.viewAddress = mapped.baseAddress + (this.index++) * mapped.stride;
MappedHelper.put_view(mapped, this.index++);
return mapped;
}

View File

@ -214,7 +214,7 @@ public class MappedObject {
* For convenience you are encouraged to static-import this specific method:
* <code>import static org.lwjgl.util.mapped.MappedObject.foreach;</code>
*/
public static <T extends MappedObject> MappedForeach<T> foreach(T mapped, int elementCount) {
public static <T extends MappedObject> Iterable<T> foreach(T mapped, int elementCount) {
return new MappedForeach<T>(mapped, elementCount);
}