-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMyIter.java
26 lines (21 loc) · 901 Bytes
/
MyIter.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import java.util.Iterator;
import java.util.Map;
import java.util.Map.Entry;
public class MyIter<E> implements Iterator<Map.Entry<E,Integer>>{
//OVERVIEW: MyIter è una classe d'appoggio che crea un Iteratore senza il metodo remove
private Iterator<Map.Entry<E,Integer>> itr;
public MyIter(final Iterator<Map.Entry<E,Integer>> parametro) {
if (parametro == null) {
throw new NullPointerException("Iteratore Vuoto");
}
this.itr = parametro;
}
//REQUIRES: paramentro != null
//THROWS: se (parametro==null) lancia una NullPointerException
//MODIFIES:
//EFFECTS:
public boolean hasNext(){return this.itr.hasNext();}
public Map.Entry<E,Integer> next(){return this.itr.next();}
public void remove(){ throw new UnsupportedOperationException("remove() non consentita!"); }
//EFFECTS: lancia una UnsupportedOperationException;
}