How to perform a binary search on IList?

前端 未结 11 1373
执念已碎
执念已碎 2020-11-28 09:32

Simple question - given an IList how do you perform a binary search without writing the method yourself and without copying the data to a type with bui

11条回答
  •  一向
    一向 (楼主)
    2020-11-28 10:26

    Note that there is a bug in the implementation provided by Antoine below: when searching for an item greater than any in the list. The return value should be ~lower not ~middle. Decompile method ArraySortHelper.InternalBinarySearch (mscorlib) to see the framework implementation.

提交回复
热议问题