bsearch20 1.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +8 -0
- data/.travis.yml +6 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Changelog +71 -0
- data/Gemfile +7 -0
- data/Gemfile.lock +21 -0
- data/LICENSE.txt +21 -0
- data/README.md +46 -0
- data/Rakefile +10 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/bsearch20.gemspec +29 -0
- data/lib/bsearch20.rb +118 -0
- data/lib/bsearch20/version.rb +3 -0
- metadata +61 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: a239115588ce607ed7343dbda5f8d87a65d0001b8d6073ad7379ddcc78160c4c
|
|
4
|
+
data.tar.gz: ea5f324ee5b0224818e6cdd8b9e6241c832f0c532f5c125a226a96afd9d12282
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: cbfd53997b3b95071986780df4b2aeddefaca5165dc431d19612d27650b86ead1baeb99b1b87706e303442c48a7217ecb2b3d3183f6adbde5094102aa6fac112
|
|
7
|
+
data.tar.gz: ef63599f009c707f89eaeb077682f716860ef6014ac4beb7050297a9f6c4fb3200d795b36db8f6b67e1840533bb23724654a94437da68eaf3d04b3ca719de32a
|
data/.gitignore
ADDED
data/.travis.yml
ADDED
data/CODE_OF_CONDUCT.md
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
|
2
|
+
|
|
3
|
+
## Our Pledge
|
|
4
|
+
|
|
5
|
+
In the interest of fostering an open and welcoming environment, we as
|
|
6
|
+
contributors and maintainers pledge to making participation in our project and
|
|
7
|
+
our community a harassment-free experience for everyone, regardless of age, body
|
|
8
|
+
size, disability, ethnicity, gender identity and expression, level of experience,
|
|
9
|
+
nationality, personal appearance, race, religion, or sexual identity and
|
|
10
|
+
orientation.
|
|
11
|
+
|
|
12
|
+
## Our Standards
|
|
13
|
+
|
|
14
|
+
Examples of behavior that contributes to creating a positive environment
|
|
15
|
+
include:
|
|
16
|
+
|
|
17
|
+
* Using welcoming and inclusive language
|
|
18
|
+
* Being respectful of differing viewpoints and experiences
|
|
19
|
+
* Gracefully accepting constructive criticism
|
|
20
|
+
* Focusing on what is best for the community
|
|
21
|
+
* Showing empathy towards other community members
|
|
22
|
+
|
|
23
|
+
Examples of unacceptable behavior by participants include:
|
|
24
|
+
|
|
25
|
+
* The use of sexualized language or imagery and unwelcome sexual attention or
|
|
26
|
+
advances
|
|
27
|
+
* Trolling, insulting/derogatory comments, and personal or political attacks
|
|
28
|
+
* Public or private harassment
|
|
29
|
+
* Publishing others' private information, such as a physical or electronic
|
|
30
|
+
address, without explicit permission
|
|
31
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
|
32
|
+
professional setting
|
|
33
|
+
|
|
34
|
+
## Our Responsibilities
|
|
35
|
+
|
|
36
|
+
Project maintainers are responsible for clarifying the standards of acceptable
|
|
37
|
+
behavior and are expected to take appropriate and fair corrective action in
|
|
38
|
+
response to any instances of unacceptable behavior.
|
|
39
|
+
|
|
40
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
|
41
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
|
42
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
|
43
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
|
44
|
+
threatening, offensive, or harmful.
|
|
45
|
+
|
|
46
|
+
## Scope
|
|
47
|
+
|
|
48
|
+
This Code of Conduct applies both within project spaces and in public spaces
|
|
49
|
+
when an individual is representing the project or its community. Examples of
|
|
50
|
+
representing a project or community include using an official project e-mail
|
|
51
|
+
address, posting via an official social media account, or acting as an appointed
|
|
52
|
+
representative at an online or offline event. Representation of a project may be
|
|
53
|
+
further defined and clarified by project maintainers.
|
|
54
|
+
|
|
55
|
+
## Enforcement
|
|
56
|
+
|
|
57
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
|
58
|
+
reported by contacting the project team at kifer.mada@gmail.com. All
|
|
59
|
+
complaints will be reviewed and investigated and will result in a response that
|
|
60
|
+
is deemed necessary and appropriate to the circumstances. The project team is
|
|
61
|
+
obligated to maintain confidentiality with regard to the reporter of an incident.
|
|
62
|
+
Further details of specific enforcement policies may be posted separately.
|
|
63
|
+
|
|
64
|
+
Project maintainers who do not follow or enforce the Code of Conduct in good
|
|
65
|
+
faith may face temporary or permanent repercussions as determined by other
|
|
66
|
+
members of the project's leadership.
|
|
67
|
+
|
|
68
|
+
## Attribution
|
|
69
|
+
|
|
70
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
|
71
|
+
available at [https://contributor-covenant.org/version/1/4][version]
|
|
72
|
+
|
|
73
|
+
[homepage]: https://contributor-covenant.org
|
|
74
|
+
[version]: https://contributor-covenant.org/version/1/4/
|
data/Changelog
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
2020-07-24 Andy Kifer <kifer.mada@gmail.com>
|
|
2
|
+
|
|
3
|
+
* Forked into Ruby/Bsearch20
|
|
4
|
+
* Syntax updates for ruby 2.7+
|
|
5
|
+
|
|
6
|
+
2001-12-10 Satoru Takabayashi <satoru@namazu.org>
|
|
7
|
+
|
|
8
|
+
* Ruby/Bsearch: Version 1.5 released.
|
|
9
|
+
|
|
10
|
+
* bsearch.rb (Array::bsearch_range): Take &block and pass &block.
|
|
11
|
+
(Array::bsearch_last): Likewise.
|
|
12
|
+
(Array::bsearch_first): Likewise.
|
|
13
|
+
(Array::bsearch_lower_boundary): Likewise.
|
|
14
|
+
(Array::bsearch_upper_boundary): Likewise.
|
|
15
|
+
|
|
16
|
+
2001-11-16 Satoru Takabayashi <satoru@namazu.org>
|
|
17
|
+
|
|
18
|
+
* tests/test.rb (check_boundaries): New method.
|
|
19
|
+
|
|
20
|
+
2001-10-19 Satoru Takabayashi <satoru@namazu.org>
|
|
21
|
+
|
|
22
|
+
* Ruby/Bsearch: Version 1.4 released.
|
|
23
|
+
|
|
24
|
+
* tests/test.rb (lookup): Add assertions.
|
|
25
|
+
|
|
26
|
+
* bsearch.rb (Array::bsearch_lower_boundary): Use .to_i for
|
|
27
|
+
working with mathn.rb (Rational).
|
|
28
|
+
Thanks to Nenad Ocelic <nocelic@medri.hr> for reporting it.
|
|
29
|
+
(Array::bsearch_upper_boundary): Likewise.
|
|
30
|
+
|
|
31
|
+
2001-09-12 Satoru Takabayashi <satoru@namazu.org>
|
|
32
|
+
|
|
33
|
+
* Ruby/Bsearch: Version 1.3 released.
|
|
34
|
+
|
|
35
|
+
* bsearch.en.rd: Update documentation .
|
|
36
|
+
|
|
37
|
+
* bsearch.ja.rd: Likewise.
|
|
38
|
+
|
|
39
|
+
2001-08-16 Satoru Takabayashi <satoru@namazu.org>
|
|
40
|
+
|
|
41
|
+
* bsearch.rb (bsearch_lower_bound): New method.
|
|
42
|
+
|
|
43
|
+
* bsearch.rb (bsearch_upper_bound): New method.
|
|
44
|
+
|
|
45
|
+
* bsearch.rb (bsearch_range): Return the range consisting of
|
|
46
|
+
bsearch_lower_bound and bsearch_upper_bound.
|
|
47
|
+
|
|
48
|
+
2001-07-03 Satoru Takabayashi <satoru@namazu.org>
|
|
49
|
+
|
|
50
|
+
* Ruby/Bsearch: Version 1.2 released.
|
|
51
|
+
|
|
52
|
+
* Rewrite documents with rdtools.
|
|
53
|
+
|
|
54
|
+
2001-05-29 Satoru Takabayashi <satoru@namazu.org>
|
|
55
|
+
|
|
56
|
+
* Ruby/Bsearch: Version 1.1 released.
|
|
57
|
+
|
|
58
|
+
* tests/test.rb: Add tests for Array#bsearch_range method.
|
|
59
|
+
|
|
60
|
+
2001-05-23 Satoru Takabayashi <satoru@namazu.org>
|
|
61
|
+
|
|
62
|
+
* bsearch.rb (bsearch_range): New method.
|
|
63
|
+
|
|
64
|
+
* bsearch.rb (bsearch_last): Add an ommitable parameter `range'.
|
|
65
|
+
|
|
66
|
+
* bsearch.rb (bsearch_first): Add an ommitable parameter `range'.
|
|
67
|
+
|
|
68
|
+
2001-05-05 Satoru Takabayashi <satoru@namazu.org>
|
|
69
|
+
|
|
70
|
+
* Ruby/Bsearch: Version 1.0 released.
|
|
71
|
+
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
PATH
|
|
2
|
+
remote: .
|
|
3
|
+
specs:
|
|
4
|
+
bsearch20 (1.6.0)
|
|
5
|
+
|
|
6
|
+
GEM
|
|
7
|
+
remote: https://rubygems.org/
|
|
8
|
+
specs:
|
|
9
|
+
minitest (5.14.1)
|
|
10
|
+
rake (12.3.3)
|
|
11
|
+
|
|
12
|
+
PLATFORMS
|
|
13
|
+
ruby
|
|
14
|
+
|
|
15
|
+
DEPENDENCIES
|
|
16
|
+
bsearch20!
|
|
17
|
+
minitest (~> 5.0)
|
|
18
|
+
rake (~> 12.0)
|
|
19
|
+
|
|
20
|
+
BUNDLED WITH
|
|
21
|
+
2.1.2
|
data/LICENSE.txt
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2020 Andy Kifer
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
|
13
|
+
all copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
# Bsearch20
|
|
2
|
+
|
|
3
|
+
This is a fork of the excelent [Ruby/Bsearch](https://rubygems.org/gems/bsearch) gem originally written by Satoru Takabayashi.
|
|
4
|
+
|
|
5
|
+
The API is described [here](http://0xcc.net/ruby-bsearch/)
|
|
6
|
+
|
|
7
|
+
Most of the changes are syntaxes, the original gem was published in 2001, almost 20 years ago!
|
|
8
|
+
|
|
9
|
+
## Installation
|
|
10
|
+
|
|
11
|
+
Add this line to your application's Gemfile:
|
|
12
|
+
|
|
13
|
+
```ruby
|
|
14
|
+
gem 'bsearch20'
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
And then execute:
|
|
18
|
+
|
|
19
|
+
$ bundle install
|
|
20
|
+
|
|
21
|
+
Or install it yourself as:
|
|
22
|
+
|
|
23
|
+
$ gem install bsearch20
|
|
24
|
+
|
|
25
|
+
## Usage
|
|
26
|
+
|
|
27
|
+
TODO: Write usage instructions here
|
|
28
|
+
|
|
29
|
+
## Development
|
|
30
|
+
|
|
31
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
|
32
|
+
|
|
33
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
|
34
|
+
|
|
35
|
+
## Contributing
|
|
36
|
+
|
|
37
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/bsearch20. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/[USERNAME]/bsearch20/blob/master/CODE_OF_CONDUCT.md).
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
## License
|
|
41
|
+
|
|
42
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
|
43
|
+
|
|
44
|
+
## Code of Conduct
|
|
45
|
+
|
|
46
|
+
Everyone interacting in the Bsearch20 project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/bsearch20/blob/master/CODE_OF_CONDUCT.md).
|
data/Rakefile
ADDED
data/bin/console
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
|
|
3
|
+
require "bundler/setup"
|
|
4
|
+
require "bsearch20"
|
|
5
|
+
|
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
|
8
|
+
|
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
|
10
|
+
# require "pry"
|
|
11
|
+
# Pry.start
|
|
12
|
+
|
|
13
|
+
require "irb"
|
|
14
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
data/bsearch20.gemspec
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
require_relative 'lib/bsearch20/version'
|
|
2
|
+
|
|
3
|
+
Gem::Specification.new do |spec|
|
|
4
|
+
spec.name = "bsearch20"
|
|
5
|
+
spec.version = Bsearch20::VERSION
|
|
6
|
+
spec.authors = ["Satoru Takabayashi, Andy Kifer"]
|
|
7
|
+
spec.email = ["kifer.mada@gmail.com"]
|
|
8
|
+
|
|
9
|
+
spec.summary = %q{Ruby/Bsearch: a binary search library for Ruby}
|
|
10
|
+
spec.description = %q{This is an upgraded version of the excelent bsearch gem by Satoru Takabayashi. Tailored for Ruby 2.7+ mostly syntax changes.}
|
|
11
|
+
spec.homepage = "https://github.com/FranckyU/bsearch20"
|
|
12
|
+
spec.license = "MIT"
|
|
13
|
+
spec.required_ruby_version = Gem::Requirement.new(">= 2.7.0")
|
|
14
|
+
|
|
15
|
+
# spec.metadata["allowed_push_host"] = ""
|
|
16
|
+
|
|
17
|
+
spec.metadata["homepage_uri"] = spec.homepage
|
|
18
|
+
spec.metadata["source_code_uri"] = "https://github.com/FranckyU/bsearch20"
|
|
19
|
+
spec.metadata["changelog_uri"] = "https://github.com/FranckyU/bsearch20/blob/master/Changelog"
|
|
20
|
+
|
|
21
|
+
# Specify which files should be added to the gem when it is released.
|
|
22
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
|
23
|
+
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
|
24
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
|
25
|
+
end
|
|
26
|
+
spec.bindir = "exe"
|
|
27
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
|
28
|
+
spec.require_paths = ["lib"]
|
|
29
|
+
end
|
data/lib/bsearch20.rb
ADDED
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
#
|
|
2
|
+
# Ruby/Bsearch - a binary search library for Ruby.
|
|
3
|
+
#
|
|
4
|
+
# Copyright (C) 2001 Satoru Takabayashi <satoru@namazu.org>
|
|
5
|
+
# All rights reserved.
|
|
6
|
+
# This is free software with ABSOLUTELY NO WARRANTY.
|
|
7
|
+
#
|
|
8
|
+
# You can redistribute it and/or modify it under the terms of
|
|
9
|
+
# the Ruby's licence.
|
|
10
|
+
#
|
|
11
|
+
# Example:
|
|
12
|
+
#
|
|
13
|
+
# % irb -r ./bsearch.rb
|
|
14
|
+
# >> %w(a b c c c d e f).bsearch_first {|x| x <=> "c"}
|
|
15
|
+
# => 2
|
|
16
|
+
# >> %w(a b c c c d e f).bsearch_last {|x| x <=> "c"}
|
|
17
|
+
# => 4
|
|
18
|
+
# >> %w(a b c e f).bsearch_first {|x| x <=> "c"}
|
|
19
|
+
# => 2
|
|
20
|
+
# >> %w(a b e f).bsearch_first {|x| x <=> "c"}
|
|
21
|
+
# => nil
|
|
22
|
+
# >> %w(a b e f).bsearch_last {|x| x <=> "c"}
|
|
23
|
+
# => nil
|
|
24
|
+
# >> %w(a b e f).bsearch_lower_boundary {|x| x <=> "c"}
|
|
25
|
+
# => 2
|
|
26
|
+
# >> %w(a b e f).bsearch_upper_boundary {|x| x <=> "c"}
|
|
27
|
+
# => 2
|
|
28
|
+
# >> %w(a b c c c d e f).bsearch_range {|x| x <=> "c"}
|
|
29
|
+
# => 2...5
|
|
30
|
+
# >> %w(a b c d e f).bsearch_range {|x| x <=> "c"}
|
|
31
|
+
# => 2...3
|
|
32
|
+
# >> %w(a b d e f).bsearch_range {|x| x <=> "c"}
|
|
33
|
+
# => 2...2
|
|
34
|
+
$LOAD_PATH << File.dirname(File.expand_path(__FILE__))
|
|
35
|
+
|
|
36
|
+
require_relative "bsearch20/version"
|
|
37
|
+
|
|
38
|
+
class Array
|
|
39
|
+
#
|
|
40
|
+
# The binary search algorithm is extracted from Jon Bentley's
|
|
41
|
+
# Programming Pearls 2nd ed. p.93
|
|
42
|
+
#
|
|
43
|
+
|
|
44
|
+
#
|
|
45
|
+
# Return the lower boundary. (inside)
|
|
46
|
+
#
|
|
47
|
+
def bsearch_lower_boundary(range = 0...self.length, &block)
|
|
48
|
+
lower = range.first() -1
|
|
49
|
+
upper = if range.exclude_end? then range.last else range.last + 1 end
|
|
50
|
+
while lower + 1 != upper
|
|
51
|
+
mid = ((lower + upper) / 2).to_i # for working with mathn.rb (Rational)
|
|
52
|
+
if yield(self[mid]) < 0
|
|
53
|
+
lower = mid
|
|
54
|
+
else
|
|
55
|
+
upper = mid
|
|
56
|
+
end
|
|
57
|
+
end
|
|
58
|
+
return upper
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
#
|
|
62
|
+
# This method searches the FIRST occurrence which satisfies a
|
|
63
|
+
# condition given by a block in binary fashion and return the
|
|
64
|
+
# index of the first occurrence. Return nil if not found.
|
|
65
|
+
#
|
|
66
|
+
def bsearch_first(range = 0...self.length, &block)
|
|
67
|
+
boundary = bsearch_lower_boundary(range, &block)
|
|
68
|
+
if boundary >= self.length || yield(self[boundary]) != 0
|
|
69
|
+
return nil
|
|
70
|
+
else
|
|
71
|
+
return boundary
|
|
72
|
+
end
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
alias bsearch bsearch_first
|
|
76
|
+
|
|
77
|
+
#
|
|
78
|
+
# Return the upper boundary. (outside)
|
|
79
|
+
#
|
|
80
|
+
def bsearch_upper_boundary(range = 0...self.length, &block)
|
|
81
|
+
lower = range.first() -1
|
|
82
|
+
upper = if range.exclude_end? then range.last else range.last + 1 end
|
|
83
|
+
while lower + 1 != upper
|
|
84
|
+
mid = ((lower + upper) / 2).to_i # for working with mathn.rb (Rational)
|
|
85
|
+
if yield(self[mid]) <= 0
|
|
86
|
+
lower = mid
|
|
87
|
+
else
|
|
88
|
+
upper = mid
|
|
89
|
+
end
|
|
90
|
+
end
|
|
91
|
+
return lower + 1 # outside of the matching range.
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
#
|
|
95
|
+
# This method searches the LAST occurrence which satisfies a
|
|
96
|
+
# condition given by a block in binary fashion and return the
|
|
97
|
+
# index of the last occurrence. Return nil if not found.
|
|
98
|
+
#
|
|
99
|
+
def bsearch_last(range = 0...self.length, &block)
|
|
100
|
+
# `- 1' for canceling `lower + 1' in bsearch_upper_boundary.
|
|
101
|
+
boundary = bsearch_upper_boundary(range, &block) - 1
|
|
102
|
+
|
|
103
|
+
if (boundary <= -1 || yield(self[boundary]) != 0)
|
|
104
|
+
return nil
|
|
105
|
+
else
|
|
106
|
+
return boundary
|
|
107
|
+
end
|
|
108
|
+
end
|
|
109
|
+
|
|
110
|
+
#
|
|
111
|
+
# Return the search result as a Range object.
|
|
112
|
+
#
|
|
113
|
+
def bsearch_range(range = 0...self.length, &block)
|
|
114
|
+
lower = bsearch_lower_boundary(range, &block)
|
|
115
|
+
upper = bsearch_upper_boundary(range, &block)
|
|
116
|
+
return lower...upper
|
|
117
|
+
end
|
|
118
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: bsearch20
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 1.6.0
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Satoru Takabayashi, Andy Kifer
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: exe
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2020-07-24 00:00:00.000000000 Z
|
|
12
|
+
dependencies: []
|
|
13
|
+
description: This is an upgraded version of the excelent bsearch gem by Satoru Takabayashi.
|
|
14
|
+
Tailored for Ruby 2.7+ mostly syntax changes.
|
|
15
|
+
email:
|
|
16
|
+
- kifer.mada@gmail.com
|
|
17
|
+
executables: []
|
|
18
|
+
extensions: []
|
|
19
|
+
extra_rdoc_files: []
|
|
20
|
+
files:
|
|
21
|
+
- ".gitignore"
|
|
22
|
+
- ".travis.yml"
|
|
23
|
+
- CODE_OF_CONDUCT.md
|
|
24
|
+
- Changelog
|
|
25
|
+
- Gemfile
|
|
26
|
+
- Gemfile.lock
|
|
27
|
+
- LICENSE.txt
|
|
28
|
+
- README.md
|
|
29
|
+
- Rakefile
|
|
30
|
+
- bin/console
|
|
31
|
+
- bin/setup
|
|
32
|
+
- bsearch20.gemspec
|
|
33
|
+
- lib/bsearch20.rb
|
|
34
|
+
- lib/bsearch20/version.rb
|
|
35
|
+
homepage: https://github.com/FranckyU/bsearch20
|
|
36
|
+
licenses:
|
|
37
|
+
- MIT
|
|
38
|
+
metadata:
|
|
39
|
+
homepage_uri: https://github.com/FranckyU/bsearch20
|
|
40
|
+
source_code_uri: https://github.com/FranckyU/bsearch20
|
|
41
|
+
changelog_uri: https://github.com/FranckyU/bsearch20/blob/master/Changelog
|
|
42
|
+
post_install_message:
|
|
43
|
+
rdoc_options: []
|
|
44
|
+
require_paths:
|
|
45
|
+
- lib
|
|
46
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
47
|
+
requirements:
|
|
48
|
+
- - ">="
|
|
49
|
+
- !ruby/object:Gem::Version
|
|
50
|
+
version: 2.7.0
|
|
51
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
52
|
+
requirements:
|
|
53
|
+
- - ">="
|
|
54
|
+
- !ruby/object:Gem::Version
|
|
55
|
+
version: '0'
|
|
56
|
+
requirements: []
|
|
57
|
+
rubygems_version: 3.1.2
|
|
58
|
+
signing_key:
|
|
59
|
+
specification_version: 4
|
|
60
|
+
summary: 'Ruby/Bsearch: a binary search library for Ruby'
|
|
61
|
+
test_files: []
|