Closed cmhulbert closed 1 year ago
this is a bit too cryptic for me ... what is a usage example you envision for this LocalizableRandomAccess?
Sorry I was a bit hasty when I wrote this. I wrote this with @axtimwalde, so he may be able to provide additional context as well.
Wanting something like this came up when trying to use LoopBuilder
over a set of images, and have access to both the values, and the positions they are at. Using the current LocalizableRandomAccess should make this possible, but then you are moving two cursors for each pixel, one for the values, and one for the positions. This proposal was to provide a variant of LocalizableRandomAcess which would have a get
that returns a Pair<Localizable, Supplier<T>>
. This allows us to use the position without having to move a duplicate cursor, as well as have access to the value at that location, but only if needed, hence the supplier.
We will implement this next week, it's a reminder to self.
Reference: Localizables
Should provide the position without a copy, and the value supplier should not be evalutated unless explicitly called after the
get
on the LocalizableRandomAcess