Enumerate ImmutableSortedSet from an index

188 Views Asked by At

ImmutableSortedSet has an IndexOf and I can enumerate the set with a normal for-loop.

But according to the source code for ImmutableSortedSet it looks like it have to do a tree-search for every index lookup. If I have thousands of items in the set this probably won't be very efficient (and very unnecessary).

Can I somehow get an enumerator from a certain index and forwards? I mean one that just traverses the internal node tree more efficiently?

Perhaps some way of hacking the enumerator with reflection? I kind of want it to fast forward to a certain node and the continue the enumeration from that.

I have attempted to manipulate the "_reverse"-field in the enumerator to first "guide" it to the first node. But I couldn't get the field-change to stick.

Another idea is to populate the node-stack initially as if it already were halfway inside the enumeration, at the point were I want it to start. Just don't know if it is possible.

0

There are 0 best solutions below