mirror of
https://github.com/discourse/discourse.git
synced 2025-06-16 03:11:19 +08:00
Remove file that is no longer used.
This commit is contained in:
@ -1,29 +0,0 @@
|
|||||||
// The binarySearch() function is licensed under the UNLICENSE
|
|
||||||
// https://github.com/Olical/binary-search
|
|
||||||
|
|
||||||
// Modified for use in Discourse
|
|
||||||
|
|
||||||
export default function binarySearch(list, target, keyProp) {
|
|
||||||
var min = 0;
|
|
||||||
var max = list.length - 1;
|
|
||||||
var guess;
|
|
||||||
var keyProperty = keyProp || "id";
|
|
||||||
|
|
||||||
while (min <= max) {
|
|
||||||
guess = Math.floor((min + max) / 2);
|
|
||||||
|
|
||||||
if (Em.get(list[guess], keyProperty) === target) {
|
|
||||||
return guess;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
if (Em.get(list[guess], keyProperty) < target) {
|
|
||||||
min = guess + 1;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
max = guess - 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return -Math.floor((min + max) / 2);
|
|
||||||
}
|
|
Reference in New Issue
Block a user