Invalid Reverse Iterator Seek Test
See original GitHub issueIt seems the test for iterator#seek() on reverse iterator
is invalid. This test uses make
which batches three items with keys one, two, three
, then creates an iterator
with { reverse: true, limit: 1 }
, then attempts to seek
to key three!
expecting to find it and for the key to be three
.
Possibly invalid assumptions:
- Items are stored in the order they are received:
{ reverse: true, limit: 1 }
- Key seeking is done by subset matching:
three!
!=three
but does start withthree
Possible changes:
- Remove
{ limit: 1 }
to seek all items in reverse and tolerate the subset match - Correct the
seek('three!')
call to beseek('three')
If both changes are made then this test passes. Am I missing some reason why this is a valid test?
Issue Analytics
- State:
- Created 4 years ago
- Comments:7 (4 by maintainers)
Top Results From Across the Web
Seek iterator with Reverse doesn't work · Issue #436 - GitHub
My code was incorrect in this case, and to be truly correct you would need to know the length of the longest key...
Read more >How can I check that assignment of const_reverse_iterator to ...
I can check that assignment of iterator{} = const_iterator{} is not valid, but not an assignment of reverse_iterator{} ...
Read more >Iterator Invalidation in C++ - GeeksforGeeks
All iterators and references are invalidated unless the inserted member is at an end (front or back) of the deque (in which case...
Read more >Java - While vs For vs Iterator Performance Test - Mkyong.com
A simple Java code to test the performance of the following looping methods : While Loop; For Loop; Iterator Loop.
Read more >How to Remove Objects From ArrayList while Iterating in Java
Now, let's see an example of removing elements from ArrayList while looping using for() loop and ArrayList.remove() method, which is wrong, and the...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
The limit applies to the total number of items retrieved, not to what’s on disk. It does a seek first, then from it where landed, retrieves items until the limit is reached.
Ahhh, I see now. Thank you for that explanation. This might be a good explanation to add to the iterator documentation? I’ll close this issue. Sorry for the trouble.