MasterPuppeteer

Keep redefining this same class as an inner class so this one will be reusable throughout.

1 +package tv.puppetmaster.data;
2 +
3 +import java.util.ArrayList;
4 +import java.util.List;
5 +
6 +import tv.puppetmaster.data.i.Puppet;
7 +
8 +public class BasePuppetIterator extends Puppet.PuppetIterator {
9 +
10 + private int mCurrentIndex = 0;
11 + private List<Puppet> mPuppets = new ArrayList<>();
12 +
13 + @Override
14 + public void add(Puppet puppet) {
15 + mPuppets.add(puppet);
16 + }
17 +
18 + @Override
19 + public boolean hasNext() {
20 + boolean hasNext = mCurrentIndex < mPuppets.size();
21 + if (!hasNext) {
22 + mCurrentIndex = 0; // Reset for subsequent use
23 + }
24 + return hasNext;
25 + }
26 +
27 + @Override
28 + public Puppet next() {
29 + return mPuppets.get(mCurrentIndex++);
30 + }
31 +
32 + @Override
33 + public void remove() {
34 + }
35 +}
...\ No newline at end of file ...\ No newline at end of file