1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 package io.github.prolobjectlink.prolog.jlog;
23
24 import java.util.Enumeration;
25 import java.util.Iterator;
26 import java.util.NoSuchElementException;
27
28 import io.github.prolobjectlink.prolog.AbstractIterator;
29 import ubc.cs.JLog.Terms.iTermToObject;
30 import ubc.cs.JLog.Terms.jList;
31 import ubc.cs.JLog.Terms.jTerm;
32
33
34
35
36
37
38 final class JLogIterator extends AbstractIterator<jTerm> implements Iterator<jTerm> {
39
40 private Enumeration<?> e;
41
42 JLogIterator(jList list) {
43 if (list != null) {
44 this.e = list.elements(new iTermToObject() {
45 public Object createObjectFromTerm(jTerm term) {
46 return term;
47 }
48 });
49 }
50 }
51
52 public boolean hasNext() {
53 return e != null && e.hasMoreElements();
54 }
55
56 public jTerm next() {
57 if (!hasNext()) {
58 throw new NoSuchElementException();
59 }
60 return e != null ? (jTerm) e.nextElement() : null;
61 }
62
63 }