lazy_priority_queue 0.0.0 → 0.1.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 +4 -4
- data/lib/lazy_priority_queue.rb +12 -0
- metadata +9 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ad75f66fb343a6f9ccf9f3d531172bf550c47901
|
4
|
+
data.tar.gz: 454b6fed5f8e191d41c50a35ba90668ef44fe2c5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6375ce0f1ed00787843eaf642489d069e9f799c331b638b424b5c4c1494c79cc553a71be0a61fa63a706bf17fa810c4da653d73cc6614dc2e2fa9e4cfc7c9c7b
|
7
|
+
data.tar.gz: 07c52e047784873415bc5a1e1d7e47c77d72e32ebcfe4855699002548527489602f05b163a4555a00a1d2eb54a13f2eba52948fee8e1f8ab72687c55cac53a39
|
data/lib/lazy_priority_queue.rb
CHANGED
@@ -25,6 +25,8 @@ class LazyPriorityQueue
|
|
25
25
|
|
26
26
|
element
|
27
27
|
end
|
28
|
+
alias_method :push, :enqueue
|
29
|
+
alias_method :insert, :enqueue
|
28
30
|
|
29
31
|
def change_priority element, new_key
|
30
32
|
node = @references[element]
|
@@ -68,6 +70,7 @@ class LazyPriorityQueue
|
|
68
70
|
|
69
71
|
element
|
70
72
|
end
|
73
|
+
alias_method :pop, :dequeue
|
71
74
|
|
72
75
|
def delete element
|
73
76
|
change_priority element, @top_condition
|
@@ -76,6 +79,7 @@ class LazyPriorityQueue
|
|
76
79
|
|
77
80
|
def empty?; @references.empty? end
|
78
81
|
def size; @references.size end
|
82
|
+
alias_method :length, :size
|
79
83
|
|
80
84
|
private
|
81
85
|
|
@@ -135,10 +139,18 @@ class MinPriorityQueue < LazyPriorityQueue
|
|
135
139
|
def initialize
|
136
140
|
super(-Float::INFINITY) { |parent_node, child_node| parent_node.key <= child_node.key }
|
137
141
|
end
|
142
|
+
|
143
|
+
alias_method :decrease_key, :change_priority
|
144
|
+
alias_method :min, :peek
|
145
|
+
alias_method :extract_min, :dequeue
|
138
146
|
end
|
139
147
|
|
140
148
|
class MaxPriorityQueue < LazyPriorityQueue
|
141
149
|
def initialize
|
142
150
|
super( Float::INFINITY) { |parent_node, child_node| parent_node.key >= child_node.key }
|
143
151
|
end
|
152
|
+
|
153
|
+
alias_method :increase_key, :change_priority
|
154
|
+
alias_method :max, :peek
|
155
|
+
alias_method :extract_max, :dequeue
|
144
156
|
end
|
metadata
CHANGED
@@ -1,19 +1,19 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lazy_priority_queue
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matías Battocchia
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-01-
|
11
|
+
date: 2016-01-12 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
|
-
description: Lazy priority queue is a priority queue which implements a
|
14
|
-
heap. It supports the change priority operation, being suitable for
|
15
|
-
Dijkstra's shortest path and Prim's minimum spanning tree. It can
|
16
|
-
as a min-priority queue as well as a max-priority queue.
|
13
|
+
description: Lazy priority queue is a pure Ruby priority queue which implements a
|
14
|
+
lazy binomial heap. It supports the change priority operation, being suitable for
|
15
|
+
algorithms like Dijkstra's shortest path and Prim's minimum spanning tree. It can
|
16
|
+
be instantiated as a min-priority queue as well as a max-priority queue.
|
17
17
|
email: matias@riseup.net
|
18
18
|
executables: []
|
19
19
|
extensions: []
|
@@ -43,5 +43,7 @@ rubyforge_project:
|
|
43
43
|
rubygems_version: 2.4.5.1
|
44
44
|
signing_key:
|
45
45
|
specification_version: 4
|
46
|
-
summary: A priority queue
|
46
|
+
summary: A priority queue implemented using a lazy binomial heap. It allows change
|
47
|
+
priority operation.
|
47
48
|
test_files: []
|
49
|
+
has_rdoc:
|