diff options
Diffstat (limited to 'core/src/ch')
-rw-r--r-- | core/src/ch/asynk/rustanddust/engine/util/Collection.java | 2 | ||||
-rw-r--r-- | core/src/ch/asynk/rustanddust/engine/util/IterableArray.java | 10 |
2 files changed, 12 insertions, 0 deletions
diff --git a/core/src/ch/asynk/rustanddust/engine/util/Collection.java b/core/src/ch/asynk/rustanddust/engine/util/Collection.java index a7b5a02..67ea169 100644 --- a/core/src/ch/asynk/rustanddust/engine/util/Collection.java +++ b/core/src/ch/asynk/rustanddust/engine/util/Collection.java @@ -16,6 +16,8 @@ public interface Collection<E> extends Iterator, Iterable<E> public E get(int idx); + public int indexOf(E e); + public boolean add(E e); public E remove(int idx); diff --git a/core/src/ch/asynk/rustanddust/engine/util/IterableArray.java b/core/src/ch/asynk/rustanddust/engine/util/IterableArray.java index 1b965fc..f1473dd 100644 --- a/core/src/ch/asynk/rustanddust/engine/util/IterableArray.java +++ b/core/src/ch/asynk/rustanddust/engine/util/IterableArray.java @@ -72,6 +72,16 @@ public class IterableArray<E> implements Collection<E> } @Override + public int indexOf(E e) + { + for (int i = 0; i < data.length; i++) { + if (data[i] != null && data[i].equals(e)) + return i; + } + return -1; + } + + @Override public boolean add(E e) { ensureCapacity(s + 1); |