You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Obtaining an EdgeIteratorState given an integer edge id is unnecessarily expensive, because Graph#getEdgeIteratorState creates an object instead of simply updating the edge id being in use as we do with the other EdgeExplorers. We need something like RandomAccessEdgeExplorer.setEdge(edgeId) in analogy to EdgeExplorer.setBaseNode(node).
For example this method is a bottleneck in Path#forEveryEdge like in Path#calcPoints.
Can I ask something outrageous? Do you thing we could -- in the long run -- a) rename these things to *Cursor, and b) refactor them so that we can make them Iterable, like in the primitive-collections library we are using?
Doesn't sound so outrageous :) I don't really care about Iterator vs. Cursor what do you think makes the difference ? What do you mean making them iterable ? You mean having something like prev() in addition to next() ? Ah you mean java.lang.Iterable ?
Yes. java.lang.iterable. The things in carrotsearch-collections, for example: You can for-each them, even though they iterate with a cursor rather than with value objects. That‘s kind of cool, I was thinking, maybe we could emulate that.
But I‘m not pushing here. Maybe just for new stuff, or experiment with a wrapper which provides that kind of interface.. don‘t know.
I can‘t imagine how it could be slower than manually writing a hasNext()-next()-loop. In fact I think it‘s literally compiled to that.
I think when people say for-each is slower, they usually mean that it is slower than using a for loop with an array index (not an iterator at all). Which makes sense.
Activity
michaz commentedon Jan 8, 2020
Can I ask something outrageous? Do you thing we could -- in the long run -- a) rename these things to *Cursor, and b) refactor them so that we can make them Iterable, like in the primitive-collections library we are using?
easbar commentedon Jan 8, 2020
Doesn't sound so outrageous :) I don't really care about Iterator vs. Cursor what do you think makes the difference ? What do you mean making them iterable ? You mean having something like prev() in addition to next() ? Ah you mean
java.lang.Iterable?michaz commentedon Jan 8, 2020
Yes. java.lang.iterable. The things in carrotsearch-collections, for example: You can for-each them, even though they iterate with a cursor rather than with value objects. That‘s kind of cool, I was thinking, maybe we could emulate that.
But I‘m not pushing here. Maybe just for new stuff, or experiment with a wrapper which provides that kind of interface.. don‘t know.
michaz commentedon Jan 8, 2020
I can‘t imagine how it could be slower than manually writing a hasNext()-next()-loop. In fact I think it‘s literally compiled to that.
I think when people say for-each is slower, they usually mean that it is slower than using a for loop with an array index (not an iterator at all). Which makes sense.