sorted_set 1.0.0-java
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.github/workflows/test.yml +29 -0
- data/.gitignore +9 -0
- data/CHANGELOG.md +8 -0
- data/Gemfile +8 -0
- data/LICENSE.txt +24 -0
- data/README.md +55 -0
- data/Rakefile +10 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/lib/sorted_set.rb +57 -0
- data/sorted_set.gemspec +32 -0
- metadata +85 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: '081898341e9841dc1003f668d4ca625f40927bc9f8833cd6a6bfcb06f5bcfc7a'
|
4
|
+
data.tar.gz: d473ca555544efb5a22774b1c2d38ac0813825264510851b41db04b1dbbea471
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: b03e842ed2ecc92e2e71a0182573f1dedbf7179c9146a1be3acb91e8b60e89c30ba7b8edb09a3f3f67e9399297f88d5148491743b6b1b9dd363e48be846471a5
|
7
|
+
data.tar.gz: 852398e0e8803f42c833a98f3e4ca809f792c6fcdb2c3e798ba4e143f064da9fe714fa8a33f14b014a5a9a369ff105e6b16e349e18a1edf8c471f4adba5cfaa2
|
@@ -0,0 +1,29 @@
|
|
1
|
+
name: test
|
2
|
+
|
3
|
+
on: [push, pull_request]
|
4
|
+
|
5
|
+
jobs:
|
6
|
+
test:
|
7
|
+
strategy:
|
8
|
+
fail-fast: false
|
9
|
+
matrix:
|
10
|
+
ruby: [ 2.7, head, jruby ]
|
11
|
+
os: [ ubuntu ]
|
12
|
+
|
13
|
+
name: >-
|
14
|
+
${{matrix.os}}-ruby-${{matrix.ruby}}
|
15
|
+
runs-on: ${{matrix.os}}-latest
|
16
|
+
continue-on-error: ${{matrix.ruby == 'head'}}
|
17
|
+
|
18
|
+
steps:
|
19
|
+
- name: Check out
|
20
|
+
uses: actions/checkout@master
|
21
|
+
|
22
|
+
- name: Set up ruby and bundle
|
23
|
+
uses: ruby/setup-ruby@v1
|
24
|
+
with:
|
25
|
+
ruby-version: ${{matrix.ruby}}
|
26
|
+
bundler-cache: true
|
27
|
+
|
28
|
+
- name: Run test
|
29
|
+
run: bundle exec rake test
|
data/.gitignore
ADDED
data/CHANGELOG.md
ADDED
@@ -0,0 +1,8 @@
|
|
1
|
+
# SortedSet Changelog
|
2
|
+
|
3
|
+
## 1.0.0 (2020-12-22)
|
4
|
+
|
5
|
+
This is the first release of sorted_set as a gem. Here lists the changes since the version bundled with Ruby 2.7.
|
6
|
+
|
7
|
+
* Breaking Changes
|
8
|
+
* The pure-ruby fallback implementation has been removed. It now requires an RBTree library (rbtree for CRuby, rbtree-jruby for JRuby) to install and run.
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
Copyright (c) 2002-2020 Akinori MUSHA
|
2
|
+
|
3
|
+
All rights reserved.
|
4
|
+
|
5
|
+
Redistribution and use in source and binary forms, with or without
|
6
|
+
modification, are permitted provided that the following conditions
|
7
|
+
are met:
|
8
|
+
1. Redistributions of source code must retain the above copyright
|
9
|
+
notice, this list of conditions and the following disclaimer.
|
10
|
+
2. Redistributions in binary form must reproduce the above copyright
|
11
|
+
notice, this list of conditions and the following disclaimer in the
|
12
|
+
documentation and/or other materials provided with the distribution.
|
13
|
+
|
14
|
+
THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
15
|
+
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
16
|
+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
17
|
+
ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
18
|
+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
19
|
+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
20
|
+
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
21
|
+
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
22
|
+
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
23
|
+
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
24
|
+
SUCH DAMAGE.
|
data/README.md
ADDED
@@ -0,0 +1,55 @@
|
|
1
|
+
# SortedSet
|
2
|
+
|
3
|
+
SortedSet implements a Set whose elements are sorted in ascending
|
4
|
+
order (according to the return values of their `<=>` methods) when
|
5
|
+
iterating over them.
|
6
|
+
|
7
|
+
Every element in SortedSet must be *mutually comparable* to every
|
8
|
+
other: comparison with `<=>` must not return nil for any pair of
|
9
|
+
elements. Otherwise ArgumentError will be raised.
|
10
|
+
|
11
|
+
## Installation
|
12
|
+
|
13
|
+
Add this line to your application's Gemfile:
|
14
|
+
|
15
|
+
```ruby
|
16
|
+
gem 'sorted_set'
|
17
|
+
```
|
18
|
+
|
19
|
+
And then execute:
|
20
|
+
|
21
|
+
$ bundle install
|
22
|
+
|
23
|
+
Or install it yourself as:
|
24
|
+
|
25
|
+
$ gem install sorted_set
|
26
|
+
|
27
|
+
## Usage
|
28
|
+
|
29
|
+
```ruby
|
30
|
+
require "sorted_set"
|
31
|
+
|
32
|
+
set = SortedSet.new([2, 1, 5, 6, 4, 5, 3, 3, 3])
|
33
|
+
ary = []
|
34
|
+
|
35
|
+
set.each do |obj|
|
36
|
+
ary << obj
|
37
|
+
end
|
38
|
+
|
39
|
+
p ary # => [1, 2, 3, 4, 5, 6]
|
40
|
+
|
41
|
+
set2 = SortedSet.new([1, 2, "3"])
|
42
|
+
set2.each { |obj| } # => raises ArgumentError: comparison of Fixnum with String failed
|
43
|
+
```
|
44
|
+
|
45
|
+
## Development
|
46
|
+
|
47
|
+
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.
|
48
|
+
|
49
|
+
## Contributing
|
50
|
+
|
51
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/knu/sorted_set.
|
52
|
+
|
53
|
+
## License
|
54
|
+
|
55
|
+
The gem is available as open source under either the terms of the [2-Clause BSD License](https://opensource.org/licenses/BSD-2-Clause).
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "sorted_set"
|
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/lib/sorted_set.rb
ADDED
@@ -0,0 +1,57 @@
|
|
1
|
+
# :markup: markdown
|
2
|
+
|
3
|
+
require 'set'
|
4
|
+
require 'rbtree'
|
5
|
+
|
6
|
+
##
|
7
|
+
# SortedSet implements a Set whose elements are sorted in ascending
|
8
|
+
# order (according to the return values of their `<=>` methods) when
|
9
|
+
# iterating over them.
|
10
|
+
#
|
11
|
+
# Every element in SortedSet must be *mutually comparable* to every
|
12
|
+
# other: comparison with `<=>` must not return nil for any pair of
|
13
|
+
# elements. Otherwise ArgumentError will be raised.
|
14
|
+
#
|
15
|
+
# ## Example
|
16
|
+
#
|
17
|
+
# ```ruby
|
18
|
+
# require "sorted_set"
|
19
|
+
#
|
20
|
+
# set = SortedSet.new([2, 1, 5, 6, 4, 5, 3, 3, 3])
|
21
|
+
# ary = []
|
22
|
+
#
|
23
|
+
# set.each do |obj|
|
24
|
+
# ary << obj
|
25
|
+
# end
|
26
|
+
#
|
27
|
+
# p ary # => [1, 2, 3, 4, 5, 6]
|
28
|
+
#
|
29
|
+
# set2 = SortedSet.new([1, 2, "3"])
|
30
|
+
# set2.each { |obj| } # => raises ArgumentError: comparison of Fixnum with String failed
|
31
|
+
# ```
|
32
|
+
|
33
|
+
class SortedSet < Set
|
34
|
+
# Remove the existing implementation in case Ruby 2.x loads this
|
35
|
+
# library after loading the standard set library which defines
|
36
|
+
# SortedSet.
|
37
|
+
if class_variable_defined?(:@@setup)
|
38
|
+
# a hack to shut up warning
|
39
|
+
alias_method :old_init, :initialize
|
40
|
+
|
41
|
+
instance_methods(false).each { |m| remove_method(m) }
|
42
|
+
end
|
43
|
+
|
44
|
+
# Creates a SortedSet. See Set.new for details.
|
45
|
+
def initialize(*args)
|
46
|
+
@hash = RBTree.new
|
47
|
+
super
|
48
|
+
end
|
49
|
+
|
50
|
+
if class_variable_defined?(:@@setup)
|
51
|
+
remove_class_variable(:@@setup)
|
52
|
+
remove_class_variable(:@@mutex) if class_variable_defined?(:@@mutex)
|
53
|
+
|
54
|
+
# a hack to shut up warning
|
55
|
+
remove_method :old_init
|
56
|
+
end
|
57
|
+
end
|
data/sorted_set.gemspec
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
Gem::Specification.new do |spec|
|
2
|
+
spec.name = "sorted_set"
|
3
|
+
spec.version = "1.0.0"
|
4
|
+
spec.authors = ["Akinori MUSHA"]
|
5
|
+
spec.email = ["knu@idaemons.org"]
|
6
|
+
|
7
|
+
spec.summary = %q{Implements a variant of Set whose elements are sorted in ascending order}
|
8
|
+
spec.description = %q{Implements a variant of Set whose elements are sorted in ascending order}
|
9
|
+
spec.homepage = "https://github.com/knu/sorted_set"
|
10
|
+
spec.license = "BSD-2-Clause"
|
11
|
+
spec.required_ruby_version = Gem::Requirement.new(">= 2.3.0")
|
12
|
+
|
13
|
+
spec.metadata["homepage_uri"] = spec.homepage
|
14
|
+
spec.metadata["source_code_uri"] = spec.homepage
|
15
|
+
spec.metadata["changelog_uri"] = "https://github.com/knu/sorted_set/blob/v#{spec.version}/CHANGELOG.md"
|
16
|
+
|
17
|
+
# Specify which files should be added to the gem when it is released.
|
18
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
19
|
+
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
20
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
21
|
+
end
|
22
|
+
spec.bindir = "exe"
|
23
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
24
|
+
spec.require_paths = ["lib"]
|
25
|
+
spec.add_runtime_dependency "set", "~> 1.0"
|
26
|
+
if defined?(JRUBY_VERSION)
|
27
|
+
spec.platform = 'java'
|
28
|
+
spec.add_runtime_dependency "rbtree-jruby"
|
29
|
+
else
|
30
|
+
spec.add_runtime_dependency "rbtree"
|
31
|
+
end
|
32
|
+
end
|
metadata
ADDED
@@ -0,0 +1,85 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: sorted_set
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: java
|
6
|
+
authors:
|
7
|
+
- Akinori MUSHA
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2020-12-22 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
requirement: !ruby/object:Gem::Requirement
|
15
|
+
requirements:
|
16
|
+
- - "~>"
|
17
|
+
- !ruby/object:Gem::Version
|
18
|
+
version: '1.0'
|
19
|
+
name: set
|
20
|
+
prerelease: false
|
21
|
+
type: :runtime
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
requirement: !ruby/object:Gem::Requirement
|
29
|
+
requirements:
|
30
|
+
- - ">="
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '0'
|
33
|
+
name: rbtree-jruby
|
34
|
+
prerelease: false
|
35
|
+
type: :runtime
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
description: Implements a variant of Set whose elements are sorted in ascending order
|
42
|
+
email:
|
43
|
+
- knu@idaemons.org
|
44
|
+
executables: []
|
45
|
+
extensions: []
|
46
|
+
extra_rdoc_files: []
|
47
|
+
files:
|
48
|
+
- ".github/workflows/test.yml"
|
49
|
+
- ".gitignore"
|
50
|
+
- CHANGELOG.md
|
51
|
+
- Gemfile
|
52
|
+
- LICENSE.txt
|
53
|
+
- README.md
|
54
|
+
- Rakefile
|
55
|
+
- bin/console
|
56
|
+
- bin/setup
|
57
|
+
- lib/sorted_set.rb
|
58
|
+
- sorted_set.gemspec
|
59
|
+
homepage: https://github.com/knu/sorted_set
|
60
|
+
licenses:
|
61
|
+
- BSD-2-Clause
|
62
|
+
metadata:
|
63
|
+
homepage_uri: https://github.com/knu/sorted_set
|
64
|
+
source_code_uri: https://github.com/knu/sorted_set
|
65
|
+
changelog_uri: https://github.com/knu/sorted_set/blob/v1.0.0/CHANGELOG.md
|
66
|
+
post_install_message:
|
67
|
+
rdoc_options: []
|
68
|
+
require_paths:
|
69
|
+
- lib
|
70
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
71
|
+
requirements:
|
72
|
+
- - ">="
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: 2.3.0
|
75
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
76
|
+
requirements:
|
77
|
+
- - ">="
|
78
|
+
- !ruby/object:Gem::Version
|
79
|
+
version: '0'
|
80
|
+
requirements: []
|
81
|
+
rubygems_version: 3.2.2
|
82
|
+
signing_key:
|
83
|
+
specification_version: 4
|
84
|
+
summary: Implements a variant of Set whose elements are sorted in ascending order
|
85
|
+
test_files: []
|