I see my code error, where I was using aa.next, twice in a row.
The cause was that the methods first,last,next,prev take a reference argument as the index. This value of index is used as the starting point from which the search is done. So we tried aa.next(iv), where iv==77, then (if successful), the function would update iv to be equal to the next index which is larger than 77.
Because I used an uninitialized value, it took two calls of next. The first call got the first value and the 'next' next got what I was looking for, the second value.
I see my code error, where I was using aa.next, twice in a row.
The cause was that the methods first,last,next,prev take a reference argument as the index. This value of index is used as the starting point from which the search is done. So we tried aa.next(iv), where iv==77, then (if successful), the function would update iv to be equal to the next index which is larger than 77.
Because I used an uninitialized value, it took two calls of next. The first call got the first value and the 'next' next got what I was looking for, the second value.
I might have used this corrected code instead: