File: array_bsearch_index.rb

package info (click to toggle)
ruby-test-prof 0.12.2%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, forky, sid, trixie
  • size: 508 kB
  • sloc: ruby: 4,075; makefile: 4
file content (15 lines) | stat: -rw-r--r-- 345 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
# frozen_string_literal: true

module TestProf
  # Ruby 2.3 #bsearch_index method (for usage with older Rubies)
  # Straightforward and non-optimal implementation,
  # just for compatibility
  module ArrayBSearchIndex
    refine Array do
      def bsearch_index(&block)
        el = bsearch(&block)
        index(el)
      end
    end
  end
end