diff options
author | Jérémy Zurcher <jeremy@asynk.ch> | 2016-01-09 11:45:16 +0100 |
---|---|---|
committer | Jérémy Zurcher <jeremy@asynk.ch> | 2016-01-09 11:45:16 +0100 |
commit | 1619921f6acda0b328f10b34339c2ffd7f06d238 (patch) | |
tree | b317b5246652c0a664096bf909d7737fb7d60eb3 | |
parent | 857015ded40dbf165f52301da89b7180447a11d6 (diff) | |
download | RustAndDust-1619921f6acda0b328f10b34339c2ffd7f06d238.zip RustAndDust-1619921f6acda0b328f10b34339c2ffd7f06d238.tar.gz |
add engine/util/ArrayListIt
-rw-r--r-- | core/src/ch/asynk/rustanddust/engine/util/ArrayListIt.java | 49 |
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!"); + } +} |