Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Yep, when iterators do the trick, they're preferable to indexing. But some algorithms (e.g., the tortoise and hare algorithm for cycle detection) explicitly require indexing.


Not necessarily – you can chain iterators and skip elements on the hare.


You're right. I was thinking exclusively of the case where you have an array whose elements themselves are indices into the same array.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: