diff --git a/core/src/com/riiablo/attributes/StatList.java b/core/src/com/riiablo/attributes/StatList.java index ecb2d056..6f9b3e94 100644 --- a/core/src/com/riiablo/attributes/StatList.java +++ b/core/src/com/riiablo/attributes/StatList.java @@ -52,6 +52,7 @@ public final class StatList { private IndexIterator INDEX_ITERATOR; private StatIterator STAT_ITERATOR; + private StatListIterator STAT_LIST_ITERATOR; StatList() { this(MAX_LISTS); @@ -709,4 +710,39 @@ public final class StatList { throw new UnsupportedOperationException(); } } + + public StatListIterator listIterator() { + return STAT_LIST_ITERATOR == null + ? STAT_LIST_ITERATOR = new StatListIterator().reset() + : STAT_LIST_ITERATOR.reset(); + } + + public final class StatListIterator implements Iterator, Iterable { + int list = 0; + + StatListIterator reset() { + list = 0; + return this; + } + + @Override + public Iterator iterator() { + return this; + } + + @Override + public boolean hasNext() { + return list < numLists; + } + + @Override + public StatListGetter next() { + return get(list++); + } + + @Override + public void remove() { + throw new UnsupportedOperationException(); + } + } }