pairing_heap 3.0.1 → 3.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/main.yml +1 -1
- data/Gemfile.lock +37 -21
- data/README.md +244 -353
- data/Rakefile +2 -0
- data/lib/pairing_heap/version.rb +1 -1
- data/lib/pairing_heap.rb +30 -0
- data/pairing_heap.gemspec +3 -10
- metadata +8 -7
data/Rakefile
CHANGED
data/lib/pairing_heap/version.rb
CHANGED
data/lib/pairing_heap.rb
CHANGED
@@ -425,6 +425,27 @@ module PairingHeap
|
|
425
425
|
NodeVisitor.visit_node(@root) { |x| yield [x.elem, x.priority] }
|
426
426
|
end
|
427
427
|
|
428
|
+
# Merges provided heap
|
429
|
+
# Time Complexity: O(1)
|
430
|
+
# @param other SimplePairingHeap to be merged
|
431
|
+
# @return [self]
|
432
|
+
# @raise [ArgumentError] if the provided argument is self
|
433
|
+
# @note This method modifies the argument
|
434
|
+
def merge(other)
|
435
|
+
if equal?(other)
|
436
|
+
raise ArgumentError, "Cannot merge with itself"
|
437
|
+
end
|
438
|
+
other_root = other.root
|
439
|
+
@root = if @root
|
440
|
+
other_root ? meld(@root, other_root) : @root
|
441
|
+
else
|
442
|
+
other_root
|
443
|
+
end
|
444
|
+
@size += other.size
|
445
|
+
other.clear!
|
446
|
+
self
|
447
|
+
end
|
448
|
+
|
428
449
|
private
|
429
450
|
|
430
451
|
include MergePairs
|
@@ -441,6 +462,15 @@ module PairingHeap
|
|
441
462
|
parent.subheaps = child
|
442
463
|
parent
|
443
464
|
end
|
465
|
+
|
466
|
+
protected
|
467
|
+
|
468
|
+
attr_reader :root
|
469
|
+
|
470
|
+
def clear!
|
471
|
+
@root = nil
|
472
|
+
@size = 0
|
473
|
+
end
|
444
474
|
end
|
445
475
|
|
446
476
|
# Priority queue where the smallest priority is the most prioritary
|
data/pairing_heap.gemspec
CHANGED
@@ -17,9 +17,8 @@ Gem::Specification.new do |spec|
|
|
17
17
|
spec.metadata["homepage_uri"] = spec.homepage
|
18
18
|
spec.metadata["source_code_uri"] = spec.homepage
|
19
19
|
spec.metadata["documentation_uri"] = "https://rubydoc.info/gems/pairing_heap"
|
20
|
+
spec.metadata["rubygems_mfa_required"] = "true"
|
20
21
|
|
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
22
|
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
24
23
|
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{\A(?:test|spec|features)/}) }
|
25
24
|
end
|
@@ -27,14 +26,8 @@ Gem::Specification.new do |spec|
|
|
27
26
|
spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
|
28
27
|
spec.require_paths = ["lib"]
|
29
28
|
|
30
|
-
|
31
|
-
# spec.add_dependency "example-gem", "~> 1.0"
|
32
|
-
|
33
|
-
spec.add_development_dependency "minitest", "~> 5.0"
|
29
|
+
spec.add_development_dependency "minitest", "~> 5.21"
|
34
30
|
spec.add_development_dependency "rake", "~> 13.0"
|
35
31
|
spec.add_development_dependency "simplecov", "~> 0.22.0"
|
36
|
-
spec.add_development_dependency "standard", "~> 1.
|
37
|
-
|
38
|
-
# For more information and examples about making a new gem, checkout our
|
39
|
-
# guide at: https://bundler.io/guides/creating_gem.html
|
32
|
+
spec.add_development_dependency "standard", "~> 1.31"
|
40
33
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pairing_heap
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.0
|
4
|
+
version: 3.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Marcin Henryk Bartkowiak
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-02-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: minitest
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '5.
|
19
|
+
version: '5.21'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '5.
|
26
|
+
version: '5.21'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -58,14 +58,14 @@ dependencies:
|
|
58
58
|
requirements:
|
59
59
|
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: '1.
|
61
|
+
version: '1.31'
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: '1.
|
68
|
+
version: '1.31'
|
69
69
|
description: Performant priority queue in pure ruby with support for changing priority
|
70
70
|
using pairing heap data structure
|
71
71
|
email:
|
@@ -94,6 +94,7 @@ metadata:
|
|
94
94
|
homepage_uri: https://github.com/mhib/pairing_heap
|
95
95
|
source_code_uri: https://github.com/mhib/pairing_heap
|
96
96
|
documentation_uri: https://rubydoc.info/gems/pairing_heap
|
97
|
+
rubygems_mfa_required: 'true'
|
97
98
|
post_install_message:
|
98
99
|
rdoc_options: []
|
99
100
|
require_paths:
|
@@ -109,7 +110,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
109
110
|
- !ruby/object:Gem::Version
|
110
111
|
version: '0'
|
111
112
|
requirements: []
|
112
|
-
rubygems_version: 3.
|
113
|
+
rubygems_version: 3.5.3
|
113
114
|
signing_key:
|
114
115
|
specification_version: 4
|
115
116
|
summary: Performant priority queue in pure ruby with support for changing priority
|