-
Notifications
You must be signed in to change notification settings - Fork 125
Add binary_search_by and binary_search methods to Deque #2359
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add binary_search_by and binary_search methods to Deque #2359
Conversation
Pull Request Test Coverage Report for Build 160Details
💛 - Coveralls |
Missing tests for handling wrapped around cases. For example ///|
test "binary_search when wrapped around" {
let dq = @deque.of([5, 7, 9])
dq..push_front(3)..push_front(1)
let found_first = dq.binary_search(1)
inspect(found_first, content="Ok(0)")
let found_middle = dq.binary_search(5)
inspect(found_middle, content="Ok(2)")
let found_last = dq.binary_search(9)
inspect(found_last, content="Ok(4)")
} |
If you don't plan to specifically optimize for the wrap-around case and just use Lines 992 to 1013 in fbb9e83
|
Potential unsafe memory access in binary_search methodsCategory Code duplication between binary_search_by and binary_search methodsCategory Redundant test cases with identical functionalityCategory |
89a0d36
to
ba192be
Compare
modified: deque/deque.mbti modified: deque/deque_test.mbt
Thanks. |
PR Overview
Summary
This PR adds
binary_search_by
andbinary_search
methods to the Deque implementation, providing efficient O(log n) searching capability for sorted deques.Changes
binary_search_by
method that accepts a comparator functionbinary_search
convenience method for types implementingCompare