mirror of
https://github.com/collinsmith/riiablo.git
synced 2025-01-20 09:17:29 +07:00
Added support for iterating over StatList lists
This commit is contained in:
parent
b17f528611
commit
a3b3840b20
@ -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<StatListGetter>, Iterable<StatListGetter> {
|
||||
int list = 0;
|
||||
|
||||
StatListIterator reset() {
|
||||
list = 0;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterator<StatListGetter> iterator() {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasNext() {
|
||||
return list < numLists;
|
||||
}
|
||||
|
||||
@Override
|
||||
public StatListGetter next() {
|
||||
return get(list++);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void remove() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user