|
SetIterator.java
|
//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\ // PLEASE DO NOT EDIT WITHOUT THE EXPLICIT CONSENT OF THE AUTHOR! \\ //\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\ package hlt.language.util; import java.util.Iterator;
|
This provides an iterator for SetOf objects. NB: this
is an exact replica of the implementation of SetEnumeration
with the additional (non-supported) remove() method as
mandated by the java.util.Iterator interface.
NB: once built wih the constructor SetIterator(s),
a set iterator will not be altered if a set
|
public class SetIterator implements Iterator { private SetOf set; private int position = 0; private int[] indices; SetIterator (SetOf set) { setupIterator(set); } private void setupIterator (SetOf set) { if (set.indices == null) set.buildIndices(); this.indices = set.indices; this.set = set; } public SetIterator reset (SetOf set) { setupIterator(set); return this; } public final boolean hasNext () { return (indices != null) && (position < indices.length); } public final Object next () { return (indices == null) ? null : set.base.get(indices[position++]); }
| This method is not implemented - it just throws an UnsupportedOperationException. |
public final void remove () { throw new UnsupportedOperationException(); } }
This file was generated on Sat May 11 08:40:08 CEST 2019 from file SetIterator.java
by the hlt.language.tools.Hilite Java tool written by Hassan Aït-Kaci