Koloboke
Koloboke copied to clipboard
re-settable Iterator or Cursor
I'm not sure If I'm missing something. But I would like to get access to either an iterator or Cursor to loop over elements of a collection without it internally creating a new instance of an Iterator or Cursor (such as NoRemovedIterator or NoRemovedCursor).
One way I imagine doing this is creating the Iterator or Cursor at initialization and then resetting it every time I need to loop over the elements.
I don't want to use the for each lambdas as I have other variables needed for iteration that would also potentially cause a new lambda instance to be created.
I found a workaround. I created a subclass of Consumer that has mutable properties and I reset its state before I call forEach(Consumer)