diff options
author | Jérémy Zurcher <jeremy@asynk.ch> | 2019-12-18 16:22:28 +0100 |
---|---|---|
committer | Jérémy Zurcher <jeremy@asynk.ch> | 2019-12-18 16:22:28 +0100 |
commit | 24b29457aa17c09c198464d1cb4e86b8b47aa9d5 (patch) | |
tree | 462bc13840bf9a068a369bd910718376df88594c /core | |
parent | 2349d0ac3ae59109099bba02fc491284d566e024 (diff) | |
download | gdx-boardgame-24b29457aa17c09c198464d1cb4e86b8b47aa9d5.zip gdx-boardgame-24b29457aa17c09c198464d1cb4e86b8b47aa9d5.tar.gz |
Collection : add replace(E, int)
Diffstat (limited to 'core')
-rw-r--r-- | core/src/ch/asynk/gdx/boardgame/utils/Collection.java | 2 | ||||
-rw-r--r-- | core/src/ch/asynk/gdx/boardgame/utils/IterableArray.java | 9 |
2 files changed, 11 insertions, 0 deletions
diff --git a/core/src/ch/asynk/gdx/boardgame/utils/Collection.java b/core/src/ch/asynk/gdx/boardgame/utils/Collection.java index 220e4c7..22b61b6 100644 --- a/core/src/ch/asynk/gdx/boardgame/utils/Collection.java +++ b/core/src/ch/asynk/gdx/boardgame/utils/Collection.java @@ -22,6 +22,8 @@ public interface Collection<E> extends Iterator<E>, Iterable<E> public boolean insert(E e, int idx); + public boolean replace(E e, int idx); + public E remove(int idx); public boolean remove(E e); diff --git a/core/src/ch/asynk/gdx/boardgame/utils/IterableArray.java b/core/src/ch/asynk/gdx/boardgame/utils/IterableArray.java index f592baa..8ec7eb2 100644 --- a/core/src/ch/asynk/gdx/boardgame/utils/IterableArray.java +++ b/core/src/ch/asynk/gdx/boardgame/utils/IterableArray.java @@ -91,6 +91,15 @@ public class IterableArray<E> implements Collection<E> return true; } + @Override public boolean replace(E e, int idx) + { + if (idx < s) { + data[idx] = e; + return true; + } + return false; + } + @Override public E remove(int i) { E e = data[i]; |