File: EIterator.java

package info (click to toggle)
mauve 20120103-1
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 28,504 kB
  • sloc: java: 250,155; sh: 2,834; xml: 208; makefile: 66
file content (35 lines) | stat: -rw-r--r-- 905 bytes parent folder | download | duplicates (5)
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
27
28
29
30
31
32
33
34
35
// Tags: not-a-test

package gnu.testlet.java.util.AbstractMap;

import java.util.*;

class EIterator implements Iterator {
        int pos=0;
        int status=0;

	private AcuniaAbstractMapTest map;

        public EIterator(AcuniaAbstractMapTest map) {
		this.map = map;
	}

        public  boolean hasNext() {
                return  pos < map.size();
        }

        public Object next() {
                status = 1;
                if (pos>= map.size()) throw new NoSuchElementException("no elements left");
                pos++;
                return new Entry(map.keys.get(pos-1), map.values.get(pos-1));                   
        }

        public void remove() {
                if (status != 1 ) throw new IllegalStateException("do a next() operation before remove()");
                map.deleteInAM(map.keys.get(pos-1));
                pos--;
                status=-1;
        }
}