views:

604

answers:

3

I know there is no direct equivalent in Java itself, but perhaps a third party?

It is really convenient. Currently I'd like to implement an iterator that yields all nodes in a tree, which is about five lines of code with yield.

+4  A: 

Linky Linky.

runrunraygun
http://chaoticjava.com/yielder/api/Internal server error.
Stefan Kendall
hey, that's cool, I didn't know about that. +1 for the question and your answer.
GregS
alternative link http://www.ohloh.net/p/infomancers-collections
runrunraygun
"and rewriting the bytecode of a yieldNextCore()" - seems too risky so I won't use it in production code (there are other alternatives, like writing an 'iterateAllMembers()' method that accepts a Func<T>.
ripper234
+4  A: 

Here is an article on this and library from Jim Blackler that does this in Java alone.

Ichorus
This looks like what I was looking for, thanks.
ripper234
I just saw this! Glad it was useful.
Jim Blackler
A: 

http://msdn.microsoft.com/en-us/library/9k7k7cf0.aspx

Christopher
I'm asking how to do this is Java, not C# :)
ripper234
Oops! Got a bit ahead of myself there.
Christopher