Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package e2;
- import java.util.ArrayList;
- import java.util.Iterator;
- import java.util.Spliterator;
- import java.util.function.Consumer;
- public abstract class Circular extends TVRealityList implements Iterator<String> {
- public Circular(int pos, int k, ArrayList<String> lista) {
- super(pos, lista, k);
- }
- @Override
- public Iterator<String> iterator(){
- Iterator<String> it = new Iterator<String>() {
- @Override
- public boolean hasNext() {
- if (getPos() > 0) {
- return true;
- } else return false;
- }
- @Override
- public String next() {
- int i = (getPos() + 1) % (getLista().size());
- return getLista().get(i);
- }
- @Override
- public void remove() {
- int i = getPos();
- getLista().remove(i);
- }
- };
- return it;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement