• Post Reply Bookmark Topic Watch Topic
  • New Topic

How do I convert Iterator to Enumerator?  RSS feed

 
steve anson
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am working with JTrees and have implemented a model which uses Iterators to loop thru the children of a node.
Sometimes, for example a JTree model will have methods that need to return an Enumerator.
How do I convert an Iterator to an Enumerator or vica versa?
Thanks
sanson@digitalbrain.com
 
Avi Abrami
Ranch Hand
Posts: 1141
1
Java Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Steve,
"Iterator" and "Enumerator" are both interfaces. So just make your "model" implement both interfaces, and overload the method that returns the "Iterator" so that it also returns an "Enumerator". Voila! (Cool, no?)
Good Luck,
Avi.
 
steve anson
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Avi,
that makes perfect sense now you've pointed it out.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!