项目作者: komayuki

项目描述 :
binary search
高级语言: JavaScript
项目地址: git://github.com/komayuki/js-binary-search.git
创建时间: 2017-05-29T02:36:32Z
项目社区:https://github.com/komayuki/js-binary-search

开源协议:

下载


js-binary-search

array

  1. const bSearch = require('js-binary-search');
  2. const array = [3, 5, 12, 56, 100];
  3. bSeach.search(array, 12);
  4. // return { index: 2, item: 12 }

associative_array

  1. const bSearch = require('js-binary-search')
  2. const array = [
  3. {id: 2},
  4. {id: 5},
  5. {id: 13},
  6. {id: 26}
  7. ]
  8. bSeach.search_in_associative(array, 'id', 26)
  9. // return {index: 3, item: {id: 26}}