Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save fulmicoton/08327751d925e591da541817009dc4d8 to your computer and use it in GitHub Desktop.

Select an option

Save fulmicoton/08327751d925e591da541817009dc4d8 to your computer and use it in GitHub Desktop.
let start = 0;
let end = NUM_DOCS_PER_BLOCK;
let mut half = NUM_DOCS_PER_BLOCK / 2;
for _ in 0..7 {
let mid = start + half;
let doc = block_docs[mid];
let cmp = (doc > target);
(start, end) =
if (doc <= target) {
(mid, end)
}
else {
(start, mid)
};
half /= 2;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment