Permalink
Browse files

modify

  • Loading branch information...
1 parent 6e674ad commit 3de35d76f0b5e463008f349e6fb5263bfb45aafc @ZhangHanDong committed Mar 19, 2011
Showing with 7 additions and 5 deletions.
  1. +7 −5 lib/ruby_extendsions/array_extendsions.rb
@@ -49,8 +49,12 @@ def binary_search_index(e, l = 0, u = length - 1)
return if l>u
m=(l+u)/2
return if !(e.class == self[m].class)
- e < self[m] ? u=m-1 : l=m+1
- e == self[m] ? m : binary_search_index(e,l,u)
+ begin
+ e < self[m] ? u=m-1 : l=m+1
+ e == self[m] ? m : binary_search_index(e,l,u)
+ rescue
+ return nil
+ end
end
# 基于二分查找的include?
@@ -60,9 +64,7 @@ def b_include? e
#比较两个数组内容相同,不包含顺序
def compare_content com_arr
- arr = Set.new self
- com_arr = Set.new com_arr
- return arr == com_arr
+ Set.new(self) == Set.new(com_arr)
end
end#InstanceMethods

0 comments on commit 3de35d7

Please sign in to comment.