summaryrefslogtreecommitdiffstats
path: root/core/src
diff options
context:
space:
mode:
Diffstat (limited to 'core/src')
-rw-r--r--core/src/ch/asynk/rustanddust/engine/util/ArrayListIt.java49
1 files changed, 49 insertions, 0 deletions
diff --git a/core/src/ch/asynk/rustanddust/engine/util/ArrayListIt.java b/core/src/ch/asynk/rustanddust/engine/util/ArrayListIt.java
new file mode 100644
index 0000000..c9128f2
--- /dev/null
+++ b/core/src/ch/asynk/rustanddust/engine/util/ArrayListIt.java
@@ -0,0 +1,49 @@
+package ch.asynk.rustanddust.engine.util;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+
+public class ArrayListIt<E> extends ArrayList<E> implements Iterator, Iterable<E>
+{
+ private int i;
+ private int s;
+
+ public ArrayListIt()
+ {
+ super();
+ }
+
+ public ArrayListIt(int n)
+ {
+ super(n);
+ }
+
+ @Override
+ @SuppressWarnings("unchecked")
+ public Iterator<E> iterator()
+ {
+ this.i = 0;
+ this.s = size();
+ return (Iterator<E>) this;
+ }
+
+ @Override
+ public boolean hasNext()
+ {
+ return (i < s);
+ }
+
+ @Override
+ public E next()
+ {
+ E e = get(i);
+ i += 1;
+ return e;
+ }
+
+ @Override
+ public void remove()
+ {
+ throw new RuntimeException("Iterator.remove is not allowed in here bitch!");
+ }
+}