Permalink
Browse files

fix a bug

  • Loading branch information...
1 parent 209e329 commit 2dfadee6b7473b853c2e1015811f7039daf058bf @ZhangHanDong committed Mar 19, 2011
Showing with 3 additions and 2 deletions.
  1. +3 −2 lib/ruby_extendsions/array_extendsions.rb
@@ -44,7 +44,7 @@ def is_blank_all?
def random
return self[rand(self.size)]
end
- # 二分查找返回数组index, 目前只限于元素为数字的数组
+ # 二分查找返回数组index, 只限于可排序的元素
def binary_search_index(e, l = 0, u = length - 1)
return if l>u
m=(l+u)/2
@@ -59,7 +59,8 @@ def binary_search_index(e, l = 0, u = length - 1)
# 基于二分查找的include?
def b_include? e
- !self.binary_search_index(e).nil?
+ temp = self.sort
+ !temp.binary_search_index(e).nil?
end
#比较两个数组内容相同,不包含顺序

0 comments on commit 2dfadee

Please sign in to comment.