IndexListIterator che implementa Iterator mediante un array list. Implementazione di Iterator mediante cursore : ElementIterator per PositionList. Aggiunti alcuni metodi e spostato le classi IndexListIterator,ElementIterator nel package Iterator.

This commit is contained in:
2014-04-06 21:55:57 +02:00
parent 7f3a0bfc24
commit 9e23828342
10 changed files with 205 additions and 75 deletions

View File

@@ -1,5 +1,9 @@
package arraylist;
import iterator.IndexListIterator;
import java.util.Iterator;
/**
* Created with xgiovio.macbookair.
* User: xgiovio
@@ -93,4 +97,16 @@ package arraylist;
return to_return;
}
@Override
///////////////// implemented used a generic IndexListIterator
public Iterator<E> iterator() {
E[] temp = (E[])new Object[this.size()];
for (int i = 0 ;i < this.size(); i++){
temp[i] = this.get(i);
}
return new IndexListIterator<E>(temp);
}
}

View File

@@ -8,7 +8,7 @@ package arraylist;
*/
//Copyright (c) 2003 Brown University, Providence, RI
//Additional modifications and methods by xgiovio
public interface IndexList<E> {
public interface IndexList<E> extends Iterable<E> {
public E remove(int i) throws IndexOutOfBoundsException;