Hacker News
new
|
past
|
comments
|
ask
|
show
|
jobs
|
submit
login
viperscape
on Feb 29, 2016
|
parent
|
context
|
favorite
| on:
Comparing Rust and Java
That's true for slicing and indexes, but hopefully you can use Iterator then for basic traversal, which does this.
catnaroek
on Feb 29, 2016
[–]
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.
llogiq
on March 2, 2016
|
parent
[–]
Not necessarily – you can chain iterators and skip elements on the hare.
catnaroek
on March 2, 2016
|
root
|
parent
[–]
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: