From 24b29457aa17c09c198464d1cb4e86b8b47aa9d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Zurcher?= Date: Wed, 18 Dec 2019 16:22:28 +0100 Subject: Collection : add replace(E, int) --- core/src/ch/asynk/gdx/boardgame/utils/Collection.java | 2 ++ core/src/ch/asynk/gdx/boardgame/utils/IterableArray.java | 9 +++++++++ 2 files changed, 11 insertions(+) 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 extends Iterator, Iterable 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 implements Collection 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]; -- cgit v1.1-2-g2b99