Iterator for DBIDs.
Important note: this iterator has a
significantly different syntax
and semantics than the Java iterators. It is much more aligned with C than
with Java, but at the same time, the syntax is much more compatible with for
loops.
Usage example:
for (DBIDIter iter = ids.iter(); iter.valid(); iter.advance()) {
Object o = relation.get(iter); // Many interfaces allow direct use
DBID id = DBIDUtil.deref(iter); // Materialize only if you need to!
}
We list some fundamental differences.
iter.valid()
refers to the current element,
Iterator.next()
to the next.
iter.advance()
does not return an element. Use
get...
to access it.
DBIDIter.get...
do not advance the iterator.