Quote (carteblanche @ Dec 1 2013 01:43pm)
you can make as many different iterators as you want. have fun!
thnx for response I'm still a little confused, if say I have a graph class i.e
Code
public class Graph<E> implements Iterable<E>{
public Iterator<E> iterator(){
return new edgeIterator();
}
public edgeIterator()....
public vertexIterator()...
}
what if I want to return a vertexIterator instread? I'm assuming I can't make 2 iterator methods.
Quote (labatymo @ Dec 1 2013 04:38pm)
Are these subclasses of your graph class?
You can make a million iterators for whatever you want to put in a data structure, but if you want to create your own data structure of edge and vertex and make them iterateable, you have to
Code
implements Iterable
on those classes
Yea I'm writing my own vertex/edge class and trying to make it so that the graph stores the vertex/edge objects
so would I make the graph class iterable?
This post was edited by Naiva on Dec 1 2013 04:34pm