sorted_set 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: e56f60064165312509fe6eba771c978f17b1ec0a9e7fa48ca9507e5e8859d8cf
4
+ data.tar.gz: 8d04402fb56428ea45bf43255112b7b4ddfab075a923efc9933c882cabc9812c
5
+ SHA512:
6
+ metadata.gz: 815254e15bf0889c57f831795792761a1d14c8f8c6420b88c8c967fbf6e60dae9938f450ecb00d9daa201729eb173f3631b2fb8531d289d900dc91d9010850e0
7
+ data.tar.gz: 9a7e2c54b2c414d0bcffa55059304813af6da28f607fbabaad07967211af529df94d4f56036d5d4a60895acb51bfa1fcae8fa90810ae7dbb6ee49751899cdf38
@@ -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
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+ Gemfile.lock
@@ -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
@@ -0,0 +1,8 @@
1
+ source "https://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in sorted_set.gemspec
4
+ gemspec
5
+
6
+ gem "rake", "~> 12.0"
7
+ gem "minitest", "~> 5.0"
8
+ gem "test-unit"
@@ -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.
@@ -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).
@@ -0,0 +1,10 @@
1
+ require "bundler/gem_tasks"
2
+ require "rake/testtask"
3
+
4
+ Rake::TestTask.new(:test) do |t|
5
+ t.libs << "test"
6
+ t.libs << "lib"
7
+ t.test_files = FileList["test/**/test_*.rb"]
8
+ end
9
+
10
+ task :default => :test
@@ -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__)
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -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
@@ -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: ruby
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
+ name: set
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.0'
20
+ type: :runtime
21
+ prerelease: false
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
+ name: rbtree
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
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.1
82
+ signing_key:
83
+ specification_version: 4
84
+ summary: Implements a variant of Set whose elements are sorted in ascending order
85
+ test_files: []