Implementation of rangeIterator for store.

You *could* slightly deduplicate code by not setting remaining and not locking the store, but by calling reset(), at the expense of an explicit variable.