mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-13 23:17:57 +00:00
cd32aaa4cf
--HG-- rename : browser/devtools/debugger/test/browser_dbg_addon1.xpi => browser/devtools/debugger/test/addon1.xpi rename : browser/devtools/debugger/test/browser_dbg_addon2.xpi => browser/devtools/debugger/test/addon2.xpi rename : browser/devtools/debugger/test/binary_search.coffee => browser/devtools/debugger/test/code_binary_search.coffee rename : browser/devtools/debugger/test/binary_search.js => browser/devtools/debugger/test/code_binary_search.js rename : browser/devtools/debugger/test/binary_search.map => browser/devtools/debugger/test/code_binary_search.map rename : browser/devtools/debugger/test/blackboxing_blackboxme.js => browser/devtools/debugger/test/code_blackboxing_blackboxme.js rename : browser/devtools/debugger/test/blackboxing_one.js => browser/devtools/debugger/test/code_blackboxing_one.js rename : browser/devtools/debugger/test/blackboxing_three.js => browser/devtools/debugger/test/code_blackboxing_three.js rename : browser/devtools/debugger/test/blackboxing_two.js => browser/devtools/debugger/test/code_blackboxing_two.js rename : browser/devtools/debugger/test/test-function-search-01.js => browser/devtools/debugger/test/code_function-search-01.js rename : browser/devtools/debugger/test/test-function-search-02.js => browser/devtools/debugger/test/code_function-search-02.js rename : browser/devtools/debugger/test/test-function-search-03.js => browser/devtools/debugger/test/code_function-search-03.js rename : browser/devtools/debugger/test/test-location-changes-bp.js => browser/devtools/debugger/test/code_location-changes.js rename : browser/devtools/debugger/test/math.js => browser/devtools/debugger/test/code_math.js rename : browser/devtools/debugger/test/math.map => browser/devtools/debugger/test/code_math.map rename : browser/devtools/debugger/test/math.min.js => browser/devtools/debugger/test/code_math.min.js rename : browser/devtools/debugger/test/test-script-switching-01.js => browser/devtools/debugger/test/code_script-switching-01.js rename : browser/devtools/debugger/test/test-script-switching-02.js => browser/devtools/debugger/test/code_script-switching-02.js rename : browser/devtools/debugger/test/test-editor-mode => browser/devtools/debugger/test/code_test-editor-mode rename : browser/devtools/debugger/test/binary_search.html => browser/devtools/debugger/test/doc_binary_search.html rename : browser/devtools/debugger/test/browser_dbg_blackboxing.html => browser/devtools/debugger/test/doc_blackboxing.html rename : browser/devtools/debugger/test/browser_dbg_cmd_break.html => browser/devtools/debugger/test/doc_cmd-break.html rename : browser/devtools/debugger/test/browser_dbg_cmd.html => browser/devtools/debugger/test/doc_cmd-dbg.html rename : browser/devtools/debugger/test/browser_dbg_conditional-breakpoints.html => browser/devtools/debugger/test/doc_conditional-breakpoints.html rename : browser/devtools/debugger/test/browser_dbg_update-editor-mode.html => browser/devtools/debugger/test/doc_editor-mode.html rename : browser/devtools/debugger/test/browser_dbg_tab1.html => browser/devtools/debugger/test/doc_empty-tab-01.html rename : browser/devtools/debugger/test/browser_dbg_tab2.html => browser/devtools/debugger/test/doc_empty-tab-02.html rename : browser/devtools/debugger/test/test-event-listeners.html => browser/devtools/debugger/test/doc_event-listeners.html rename : browser/devtools/debugger/test/browser_dbg_frame-parameters.html => browser/devtools/debugger/test/doc_frame-parameters.html rename : browser/devtools/debugger/test/browser_dbg_displayName.html => browser/devtools/debugger/test/doc_function-display-name.html rename : browser/devtools/debugger/test/browser_dbg_function-search-02.html => browser/devtools/debugger/test/doc_function-search.html rename : browser/devtools/debugger/test/browser_dbg_iframes.html => browser/devtools/debugger/test/doc_iframes.html rename : browser/devtools/debugger/test/test-location-changes-bp.html => browser/devtools/debugger/test/doc_included-script.html rename : browser/devtools/debugger/test/browser_dbg_debuggerstatement.html => browser/devtools/debugger/test/doc_inline-debugger-statement.html rename : browser/devtools/debugger/test/browser_dbg_breakpoint-new-script.html => browser/devtools/debugger/test/doc_inline-script.html rename : browser/devtools/debugger/test/browser_dbg_big-data.html => browser/devtools/debugger/test/doc_large-array-buffer.html rename : browser/devtools/debugger/test/minified.html => browser/devtools/debugger/test/doc_minified.html rename : browser/devtools/debugger/test/browser_dbg_pause-exceptions.html => browser/devtools/debugger/test/doc_pause-exceptions.html rename : browser/devtools/debugger/test/browser_dbg_stack.html => browser/devtools/debugger/test/doc_recursion-stack.html rename : browser/devtools/debugger/test/browser_dbg_script-switching.html => browser/devtools/debugger/test/doc_script-switching-01.html rename : browser/devtools/debugger/test/browser_dbg_script-switching-02.html => browser/devtools/debugger/test/doc_script-switching-02.html rename : browser/devtools/debugger/test/test-step-out.html => browser/devtools/debugger/test/doc_step-out.html rename : browser/devtools/debugger/test/browser_dbg_watch-expressions.html => browser/devtools/debugger/test/doc_watch-expressions.html rename : browser/devtools/debugger/test/browser_dbg_with-frame.html => browser/devtools/debugger/test/doc_with-frame.html
18 lines
532 B
CoffeeScript
18 lines
532 B
CoffeeScript
# Uses a binary search algorithm to locate a value in the specified array.
|
|
window.binary_search = (items, value) ->
|
|
|
|
start = 0
|
|
stop = items.length - 1
|
|
pivot = Math.floor (start + stop) / 2
|
|
|
|
while items[pivot] isnt value and start < stop
|
|
|
|
# Adjust the search area.
|
|
stop = pivot - 1 if value < items[pivot]
|
|
start = pivot + 1 if value > items[pivot]
|
|
|
|
# Recalculate the pivot.
|
|
pivot = Math.floor (stop + start) / 2
|
|
|
|
# Make sure we've found the correct value.
|
|
if items[pivot] is value then pivot else -1 |