pqueue 2.1.0 → 2.2.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 +5 -5
- data/History.md +14 -0
- data/README.md +5 -8
- data/lib/pqueue.rb +1 -1
- metadata +23 -93
- data/Contributing.md +0 -63
- data/Gemfile.lock +0 -24
- data/Index.yml +0 -44
- data/test/test_pqueue.rb +0 -178
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
|
-
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 0d3ed13a1b45054455659acee6c9a05786157865b1610db98d338927aeace490
|
|
4
|
+
data.tar.gz: 0603f00d6aba6c57ee1c75c213d4b04de3355395216cfab491c4fc09ee345eb0
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 5d8c1d9a2998eeb423900368732929e0d240b38110c604ac7d35a8a2eef5343be91779d5ee7f9d58e717ebc71275cc589f154fc283db3a3f3ae4834ab9573c79
|
|
7
|
+
data.tar.gz: d88c2111f3c981ba576670baab6b85ca93d98dfee8ec9854a29215a42d2bc3eb3a9ec6834e118db96af48803b0b8d38f1b676d944b97e09e5e0eaaab8cbcbdaa
|
data/History.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# CHANGE HISTORY
|
|
2
2
|
|
|
3
|
+
## 2.2.0 / 2026-04-02
|
|
4
|
+
|
|
5
|
+
Maintenance release. Modernized project tooling.
|
|
6
|
+
|
|
7
|
+
Changes:
|
|
8
|
+
|
|
9
|
+
* Replace custom Indexer system with standard gemspec.
|
|
10
|
+
* Replace Travis CI with GitHub Actions.
|
|
11
|
+
* Add Rakefile.
|
|
12
|
+
* Switch tests to minitest.
|
|
13
|
+
* Update URLs to HTTPS.
|
|
14
|
+
* Clean up obsolete files and .gitignore.
|
|
15
|
+
|
|
16
|
+
|
|
3
17
|
## 2.1.0 / 2014-03-03
|
|
4
18
|
|
|
5
19
|
Ostatnicky has found a bug! As it turns out both `#deq` and `#shift` were
|
data/README.md
CHANGED
|
@@ -1,13 +1,10 @@
|
|
|
1
1
|
# PQueue
|
|
2
2
|
|
|
3
|
-
[
|
|
4
|
-
[
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
[
|
|
8
|
-
[YARD API](http://rubydoc.info/gems/pqueue) ·
|
|
9
|
-
[Report Issue](http://github.com/rubyworks/pqueue/issues) ·
|
|
10
|
-
[Source Code](http://github.com/rubyworks/pqueue)
|
|
3
|
+
[Source Code](https://github.com/rubyworks/pqueue) |
|
|
4
|
+
[Report Issue](https://github.com/rubyworks/pqueue/issues)
|
|
5
|
+
|
|
6
|
+
[](https://rubygems.org/gems/pqueue)
|
|
7
|
+
[](https://github.com/rubyworks/pqueue/actions/workflows/test.yml)
|
|
11
8
|
|
|
12
9
|
|
|
13
10
|
## About
|
data/lib/pqueue.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: pqueue
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 2.
|
|
4
|
+
version: 2.2.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Trans
|
|
@@ -9,141 +9,71 @@ authors:
|
|
|
9
9
|
- Ronald Butler
|
|
10
10
|
- Olivier Renaud
|
|
11
11
|
- Rick Bradley
|
|
12
|
-
autorequire:
|
|
13
12
|
bindir: bin
|
|
14
13
|
cert_chain: []
|
|
15
|
-
date:
|
|
14
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
16
15
|
dependencies:
|
|
17
16
|
- !ruby/object:Gem::Dependency
|
|
18
|
-
name:
|
|
17
|
+
name: rake
|
|
19
18
|
requirement: !ruby/object:Gem::Requirement
|
|
20
19
|
requirements:
|
|
21
|
-
- -
|
|
20
|
+
- - ">="
|
|
22
21
|
- !ruby/object:Gem::Version
|
|
23
|
-
version: '
|
|
22
|
+
version: '13'
|
|
24
23
|
type: :development
|
|
25
24
|
prerelease: false
|
|
26
25
|
version_requirements: !ruby/object:Gem::Requirement
|
|
27
26
|
requirements:
|
|
28
|
-
- -
|
|
27
|
+
- - ">="
|
|
29
28
|
- !ruby/object:Gem::Version
|
|
30
|
-
version: '
|
|
29
|
+
version: '13'
|
|
31
30
|
- !ruby/object:Gem::Dependency
|
|
32
|
-
name:
|
|
31
|
+
name: minitest
|
|
33
32
|
requirement: !ruby/object:Gem::Requirement
|
|
34
33
|
requirements:
|
|
35
|
-
- -
|
|
34
|
+
- - ">="
|
|
36
35
|
- !ruby/object:Gem::Version
|
|
37
|
-
version: '
|
|
36
|
+
version: '5'
|
|
38
37
|
type: :development
|
|
39
38
|
prerelease: false
|
|
40
39
|
version_requirements: !ruby/object:Gem::Requirement
|
|
41
40
|
requirements:
|
|
42
|
-
- -
|
|
41
|
+
- - ">="
|
|
43
42
|
- !ruby/object:Gem::Version
|
|
44
|
-
version: '
|
|
45
|
-
- !ruby/object:Gem::Dependency
|
|
46
|
-
name: rubytest
|
|
47
|
-
requirement: !ruby/object:Gem::Requirement
|
|
48
|
-
requirements:
|
|
49
|
-
- - '>='
|
|
50
|
-
- !ruby/object:Gem::Version
|
|
51
|
-
version: '0'
|
|
52
|
-
type: :development
|
|
53
|
-
prerelease: false
|
|
54
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
55
|
-
requirements:
|
|
56
|
-
- - '>='
|
|
57
|
-
- !ruby/object:Gem::Version
|
|
58
|
-
version: '0'
|
|
59
|
-
- !ruby/object:Gem::Dependency
|
|
60
|
-
name: rubytest-cli
|
|
61
|
-
requirement: !ruby/object:Gem::Requirement
|
|
62
|
-
requirements:
|
|
63
|
-
- - '>='
|
|
64
|
-
- !ruby/object:Gem::Version
|
|
65
|
-
version: '0'
|
|
66
|
-
type: :development
|
|
67
|
-
prerelease: false
|
|
68
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
69
|
-
requirements:
|
|
70
|
-
- - '>='
|
|
71
|
-
- !ruby/object:Gem::Version
|
|
72
|
-
version: '0'
|
|
73
|
-
- !ruby/object:Gem::Dependency
|
|
74
|
-
name: indexer
|
|
75
|
-
requirement: !ruby/object:Gem::Requirement
|
|
76
|
-
requirements:
|
|
77
|
-
- - '>='
|
|
78
|
-
- !ruby/object:Gem::Version
|
|
79
|
-
version: '0'
|
|
80
|
-
type: :development
|
|
81
|
-
prerelease: false
|
|
82
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
83
|
-
requirements:
|
|
84
|
-
- - '>='
|
|
85
|
-
- !ruby/object:Gem::Version
|
|
86
|
-
version: '0'
|
|
87
|
-
- !ruby/object:Gem::Dependency
|
|
88
|
-
name: mast
|
|
89
|
-
requirement: !ruby/object:Gem::Requirement
|
|
90
|
-
requirements:
|
|
91
|
-
- - '>='
|
|
92
|
-
- !ruby/object:Gem::Version
|
|
93
|
-
version: '0'
|
|
94
|
-
type: :development
|
|
95
|
-
prerelease: false
|
|
96
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
97
|
-
requirements:
|
|
98
|
-
- - '>='
|
|
99
|
-
- !ruby/object:Gem::Version
|
|
100
|
-
version: '0'
|
|
43
|
+
version: '5'
|
|
101
44
|
description: A priority queue is like a standard queue, except that each inserted
|
|
102
|
-
|
|
45
|
+
element is given a certain priority, based on the result of the comparison block
|
|
103
46
|
given at instantiation time. Retrieving an element from the queue will always return
|
|
104
47
|
the one with the highest priority.
|
|
105
48
|
email:
|
|
106
49
|
- transfire@gmail.com
|
|
107
50
|
executables: []
|
|
108
51
|
extensions: []
|
|
109
|
-
extra_rdoc_files:
|
|
110
|
-
- License.txt
|
|
111
|
-
- README.md
|
|
112
|
-
- History.md
|
|
113
|
-
- Contributing.md
|
|
52
|
+
extra_rdoc_files: []
|
|
114
53
|
files:
|
|
115
|
-
-
|
|
116
|
-
- test/test_pqueue.rb
|
|
54
|
+
- History.md
|
|
117
55
|
- License.txt
|
|
118
|
-
- Gemfile.lock
|
|
119
|
-
- Index.yml
|
|
120
56
|
- README.md
|
|
121
|
-
-
|
|
122
|
-
|
|
123
|
-
homepage: http://rubyworks.github.com/pqueue
|
|
57
|
+
- lib/pqueue.rb
|
|
58
|
+
homepage: https://github.com/rubyworks/pqueue
|
|
124
59
|
licenses:
|
|
125
|
-
- BSD-2
|
|
60
|
+
- BSD-2-Clause
|
|
126
61
|
metadata: {}
|
|
127
|
-
post_install_message:
|
|
128
62
|
rdoc_options: []
|
|
129
63
|
require_paths:
|
|
130
64
|
- lib
|
|
131
65
|
required_ruby_version: !ruby/object:Gem::Requirement
|
|
132
66
|
requirements:
|
|
133
|
-
- -
|
|
67
|
+
- - ">="
|
|
134
68
|
- !ruby/object:Gem::Version
|
|
135
|
-
version: '
|
|
69
|
+
version: '3.1'
|
|
136
70
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
137
71
|
requirements:
|
|
138
|
-
- -
|
|
72
|
+
- - ">="
|
|
139
73
|
- !ruby/object:Gem::Version
|
|
140
74
|
version: '0'
|
|
141
75
|
requirements: []
|
|
142
|
-
|
|
143
|
-
rubygems_version: 2.0.3
|
|
144
|
-
signing_key:
|
|
76
|
+
rubygems_version: 3.6.9
|
|
145
77
|
specification_version: 4
|
|
146
78
|
summary: Queue of Prioritized Elements
|
|
147
|
-
test_files:
|
|
148
|
-
- test/test_pqueue.rb
|
|
149
|
-
has_rdoc:
|
|
79
|
+
test_files: []
|
data/Contributing.md
DELETED
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
# CONTRIBUTING
|
|
2
|
-
|
|
3
|
-
## Setup
|
|
4
|
-
|
|
5
|
-
Once you've cloned the repo, hit up Bundler.
|
|
6
|
-
|
|
7
|
-
```
|
|
8
|
-
$ bundle
|
|
9
|
-
```
|
|
10
|
-
|
|
11
|
-
## Testing
|
|
12
|
-
|
|
13
|
-
We are using the Microtest framework which is a very simple test
|
|
14
|
-
framework built to mimic the original Test::Unit but build on
|
|
15
|
-
Ruby Test, the slick meta-testing framework.
|
|
16
|
-
|
|
17
|
-
Thanks to the configuration in `etc/test.rb` running test should
|
|
18
|
-
be as simple as:
|
|
19
|
-
|
|
20
|
-
```
|
|
21
|
-
$ rubytest
|
|
22
|
-
```
|
|
23
|
-
|
|
24
|
-
## Releasing
|
|
25
|
-
|
|
26
|
-
When releasing a new version there a few things that need to done.
|
|
27
|
-
First, of course, make sure the version number is correct by editing
|
|
28
|
-
the `Index.yml` file. Then update the canonical `.index` file via:
|
|
29
|
-
|
|
30
|
-
```
|
|
31
|
-
$ index -u Index.yml Gemfile
|
|
32
|
-
```
|
|
33
|
-
|
|
34
|
-
Also, don't forget to add an entry to the `HISTORY.md` file for the
|
|
35
|
-
new release.
|
|
36
|
-
|
|
37
|
-
Though it is not likely to be needed for this project, ensure the MANIFEST
|
|
38
|
-
is up to date:
|
|
39
|
-
|
|
40
|
-
```
|
|
41
|
-
$ mast -u
|
|
42
|
-
```
|
|
43
|
-
|
|
44
|
-
Now build the gem:
|
|
45
|
-
|
|
46
|
-
```
|
|
47
|
-
$ gem build .gemspec
|
|
48
|
-
```
|
|
49
|
-
|
|
50
|
-
To release simply use:
|
|
51
|
-
|
|
52
|
-
```
|
|
53
|
-
$ gem push pqueue-x.x.x.gem
|
|
54
|
-
```
|
|
55
|
-
|
|
56
|
-
Finally, don't forget to add a tag for the release. I always use the
|
|
57
|
-
description of the release from the HISTORY file as the tag message
|
|
58
|
-
(excluding the changes list).
|
|
59
|
-
|
|
60
|
-
```
|
|
61
|
-
$ gem tag -a x.x.x
|
|
62
|
-
```
|
|
63
|
-
|
data/Gemfile.lock
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
GEM
|
|
2
|
-
remote: https://rubygems.org/
|
|
3
|
-
specs:
|
|
4
|
-
ae (1.8.2)
|
|
5
|
-
ansi
|
|
6
|
-
ansi (1.4.3)
|
|
7
|
-
indexer (0.3.1)
|
|
8
|
-
microtest (0.2.1)
|
|
9
|
-
rubytest
|
|
10
|
-
rubytest (0.7.0)
|
|
11
|
-
ansi
|
|
12
|
-
rubytest-cli (0.1.0)
|
|
13
|
-
ansi
|
|
14
|
-
rubytest (>= 0.7.0)
|
|
15
|
-
|
|
16
|
-
PLATFORMS
|
|
17
|
-
ruby
|
|
18
|
-
|
|
19
|
-
DEPENDENCIES
|
|
20
|
-
ae
|
|
21
|
-
indexer
|
|
22
|
-
microtest
|
|
23
|
-
rubytest
|
|
24
|
-
rubytest-cli
|
data/Index.yml
DELETED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
name:
|
|
3
|
-
pqueue
|
|
4
|
-
|
|
5
|
-
version:
|
|
6
|
-
2.1.0
|
|
7
|
-
|
|
8
|
-
title:
|
|
9
|
-
PQueue
|
|
10
|
-
|
|
11
|
-
summary:
|
|
12
|
-
Queue of Prioritized Elements
|
|
13
|
-
|
|
14
|
-
description:
|
|
15
|
-
A priority queue is like a standard queue, except that each inserted elements
|
|
16
|
-
is given a certain priority, based on the result of the comparison block given
|
|
17
|
-
at instantiation time. Retrieving an element from the queue will always return
|
|
18
|
-
the one with the highest priority.
|
|
19
|
-
|
|
20
|
-
resources:
|
|
21
|
-
home: http://rubyworks.github.com/pqueue
|
|
22
|
-
code: http://github.com/rubyworks/pqueue
|
|
23
|
-
bugs: http://github.com/rubyworks/pqueue/issues
|
|
24
|
-
|
|
25
|
-
repositories:
|
|
26
|
-
upstream: git://github.com/rubyworks/pqueue.git
|
|
27
|
-
|
|
28
|
-
authors:
|
|
29
|
-
- Trans <transfire@gmail.com>
|
|
30
|
-
- K. Kodama
|
|
31
|
-
- Ronald Butler
|
|
32
|
-
- Olivier Renaud
|
|
33
|
-
- Rick Bradley
|
|
34
|
-
|
|
35
|
-
organization:
|
|
36
|
-
Rubyworks
|
|
37
|
-
|
|
38
|
-
created:
|
|
39
|
-
2001-03-10
|
|
40
|
-
|
|
41
|
-
copyrights:
|
|
42
|
-
- (c) 2009 Rubyworks (BSD-2)
|
|
43
|
-
- (c) 2001 K. Kodama
|
|
44
|
-
|
data/test/test_pqueue.rb
DELETED
|
@@ -1,178 +0,0 @@
|
|
|
1
|
-
require 'microtest'
|
|
2
|
-
require 'ae'
|
|
3
|
-
require 'ae/legacy'
|
|
4
|
-
|
|
5
|
-
require 'pqueue'
|
|
6
|
-
|
|
7
|
-
class PQueueTest < MicroTest::TestCase
|
|
8
|
-
include AE::Legacy::Assertions
|
|
9
|
-
|
|
10
|
-
ARY_TEST = [2,6,1,3,8,15,0,-4,7,8,10]
|
|
11
|
-
ARY_TEST_2 = [25,10,5,13,16,9,16,12]
|
|
12
|
-
|
|
13
|
-
def test_initialize_empty
|
|
14
|
-
PQueue.new
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
def test_initialize_single_element
|
|
18
|
-
PQueue.new([3])
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
def test_initialize_multiple_elements
|
|
22
|
-
PQueue.new(ARY_TEST)
|
|
23
|
-
end
|
|
24
|
-
|
|
25
|
-
def test_initialize_with_custom_comparison
|
|
26
|
-
PQueue.new {|a,b| b<=>a}
|
|
27
|
-
PQueue.new([3]) {|a,b| b<=>a}
|
|
28
|
-
PQueue.new(ARY_TEST) {|a,b| b<=>a}
|
|
29
|
-
end
|
|
30
|
-
|
|
31
|
-
def test_top
|
|
32
|
-
assert_equal(ARY_TEST.max, PQueue.new(ARY_TEST).top)
|
|
33
|
-
assert_nil(PQueue.new.top)
|
|
34
|
-
end
|
|
35
|
-
|
|
36
|
-
def test_pop
|
|
37
|
-
sorted_ary = ARY_TEST.sort
|
|
38
|
-
q = PQueue.new(ARY_TEST)
|
|
39
|
-
ARY_TEST.size.times do
|
|
40
|
-
assert_equal(sorted_ary.pop, q.pop)
|
|
41
|
-
end
|
|
42
|
-
assert_equal(0, q.size)
|
|
43
|
-
assert_nil(PQueue.new.pop)
|
|
44
|
-
end
|
|
45
|
-
|
|
46
|
-
def test_insertion
|
|
47
|
-
q = PQueue.new(ARY_TEST)
|
|
48
|
-
assert_equal(ARY_TEST.size, q.size)
|
|
49
|
-
|
|
50
|
-
ret = q.push(24)
|
|
51
|
-
assert_equal(q, ret)
|
|
52
|
-
assert_equal(ARY_TEST.size+1, q.size)
|
|
53
|
-
end
|
|
54
|
-
|
|
55
|
-
def test_concat
|
|
56
|
-
q = PQueue.new(ARY_TEST)
|
|
57
|
-
|
|
58
|
-
ret = q.concat(ARY_TEST_2)
|
|
59
|
-
assert_equal(q, ret)
|
|
60
|
-
assert_equal(ARY_TEST.size+ARY_TEST_2.size, q.size)
|
|
61
|
-
|
|
62
|
-
q = PQueue.new(ARY_TEST)
|
|
63
|
-
r = PQueue.new(ARY_TEST_2)
|
|
64
|
-
q.concat(r)
|
|
65
|
-
assert_equal(ARY_TEST.size + ARY_TEST_2.size, q.size)
|
|
66
|
-
end
|
|
67
|
-
|
|
68
|
-
def test_clear
|
|
69
|
-
q = PQueue.new(ARY_TEST).clear
|
|
70
|
-
assert_equal(q, q.clear)
|
|
71
|
-
assert_equal(0, q.size)
|
|
72
|
-
end
|
|
73
|
-
|
|
74
|
-
def test_replace
|
|
75
|
-
q = PQueue.new(ARY_TEST)
|
|
76
|
-
q.replace(ARY_TEST_2)
|
|
77
|
-
assert_equal(ARY_TEST_2.size, q.size)
|
|
78
|
-
|
|
79
|
-
q = PQueue.new(ARY_TEST)
|
|
80
|
-
q.replace(PQueue.new(ARY_TEST_2))
|
|
81
|
-
assert_equal(ARY_TEST_2.size, q.size)
|
|
82
|
-
end
|
|
83
|
-
|
|
84
|
-
def test_inspect
|
|
85
|
-
assert_equal("<PQueue: size=#{ARY_TEST.size}, top=#{ARY_TEST.max}>",
|
|
86
|
-
PQueue.new(ARY_TEST).inspect)
|
|
87
|
-
end
|
|
88
|
-
|
|
89
|
-
def test_to_a
|
|
90
|
-
q = PQueue.new(ARY_TEST)
|
|
91
|
-
assert_equal(ARY_TEST.sort, q.to_a)
|
|
92
|
-
q = PQueue.new(0..4)
|
|
93
|
-
assert_equal([0,1,2,3,4], q.to_a)
|
|
94
|
-
end
|
|
95
|
-
|
|
96
|
-
def pop_array
|
|
97
|
-
q = PQueue.new(ARY_TEST)
|
|
98
|
-
assert_equal(ARY_TEST.sort.reverse[0..5], q.pop_array(5))
|
|
99
|
-
q = PQueue.new(ARY_TEST)
|
|
100
|
-
assert_equal(ARY_TEST.sort.reverse, q.pop_array)
|
|
101
|
-
end
|
|
102
|
-
|
|
103
|
-
def test_include
|
|
104
|
-
q = PQueue.new(ARY_TEST + [21] + ARY_TEST_2)
|
|
105
|
-
assert_equal(true, q.include?(21))
|
|
106
|
-
|
|
107
|
-
q = PQueue.new(ARY_TEST - [15])
|
|
108
|
-
assert_equal(false, q.include?(15))
|
|
109
|
-
end
|
|
110
|
-
|
|
111
|
-
def test_equal
|
|
112
|
-
assert_equal(PQueue.new, PQueue.new)
|
|
113
|
-
assert_equal(PQueue.new(ARY_TEST), PQueue.new(ARY_TEST.sort_by{rand}))
|
|
114
|
-
end
|
|
115
|
-
|
|
116
|
-
def test_swap
|
|
117
|
-
q = PQueue.new
|
|
118
|
-
assert_nil(q.swap(6))
|
|
119
|
-
assert_equal(6, q.top)
|
|
120
|
-
|
|
121
|
-
q = PQueue.new(ARY_TEST)
|
|
122
|
-
h = PQueue.new(ARY_TEST)
|
|
123
|
-
q.pop; q.push(11)
|
|
124
|
-
h.swap(11)
|
|
125
|
-
assert_equal(q, h)
|
|
126
|
-
end
|
|
127
|
-
|
|
128
|
-
def test_dup
|
|
129
|
-
q = PQueue.new(ARY_TEST)
|
|
130
|
-
assert_equal(q, q.dup)
|
|
131
|
-
end
|
|
132
|
-
|
|
133
|
-
def test_array_copied
|
|
134
|
-
ary = ARY_TEST.dup
|
|
135
|
-
q = PQueue.new(ary)
|
|
136
|
-
q.pop
|
|
137
|
-
assert_equal(ARY_TEST, ary)
|
|
138
|
-
|
|
139
|
-
ary = ARY_TEST.dup
|
|
140
|
-
q = PQueue.new
|
|
141
|
-
q.replace(ary)
|
|
142
|
-
q.pop
|
|
143
|
-
assert_equal(ARY_TEST, ary)
|
|
144
|
-
|
|
145
|
-
ary = ARY_TEST.dup
|
|
146
|
-
q = PQueue.new([1])
|
|
147
|
-
q.concat(ary)
|
|
148
|
-
q.pop
|
|
149
|
-
assert_equal(ARY_TEST, ary)
|
|
150
|
-
|
|
151
|
-
q = PQueue.new(ARY_TEST)
|
|
152
|
-
r = q.dup
|
|
153
|
-
q.pop
|
|
154
|
-
assert_not_equal(q, r)
|
|
155
|
-
end
|
|
156
|
-
|
|
157
|
-
def test_reheap
|
|
158
|
-
q = PQueue.new([2,4,5])
|
|
159
|
-
q << 6
|
|
160
|
-
q.to_a.assert == [2,4,5,6]
|
|
161
|
-
q << 1
|
|
162
|
-
q.to_a.assert == [1,2,4,5,6]
|
|
163
|
-
q << 3
|
|
164
|
-
q.to_a.assert == [1,2,3,4,5,6]
|
|
165
|
-
|
|
166
|
-
q = PQueue.new([100,5,25])
|
|
167
|
-
q.to_a.assert == [5,25,100]
|
|
168
|
-
q << 17
|
|
169
|
-
q.to_a.assert == [5,17,25,100]
|
|
170
|
-
q << 0
|
|
171
|
-
q.to_a.assert == [0,5,17,25,100]
|
|
172
|
-
q << -5
|
|
173
|
-
q.to_a.assert == [-5,0,5,17,25,100]
|
|
174
|
-
q << 100
|
|
175
|
-
q.to_a.assert == [-5,0,5,17,25,100,100]
|
|
176
|
-
end
|
|
177
|
-
|
|
178
|
-
end
|