I am currently trying to figure out what's most efficient, implementing an iterator or a for each-loop.
The object that will be traversed is a class 'Graph', which is extended by a sub-class 'Graph.Vertex'. What should be most time efficient, iterating through the objects with an iterator or with a for each-loop:
Graph.iterator();
while (Graph.iterator().hasNext()) {
// Do something
}
vs.
for (Graph.Vertex v : Graph {
// Do something
}