Skip to content

Commit 03f2db9

Browse files
committed
Left a few build config changes out. [admin]
1 parent 57a0c75 commit 03f2db9

5 files changed

Lines changed: 123 additions & 79 deletions

File tree

.ruby

Lines changed: 53 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,54 @@
1-
---
2-
name: pqueue
3-
spec_version: 1.0.0
4-
title: PQueue
5-
contact: Trans <transfire@gmail.com>
6-
requires:
7-
- group:
1+
---
2+
source:
3+
- meta
4+
authors:
5+
- name: K. Kodama
6+
- name: Ronald Butler
7+
- name: Olivier Renaud
8+
- name: Rick Bradley
9+
- name: Thomas Sawyer
10+
email: transfire@gmail.com
11+
copyrights:
12+
- holder: K. Kodama
13+
year: '2001'
14+
replacements: []
15+
alternatives: []
16+
requirements:
17+
- name: detroit
18+
groups:
819
- build
9-
name: syckle
10-
version: 0+
11-
suite: rubyworks
12-
manifest:
13-
- .ruby
14-
- lib/pqueue.rb
15-
- test/test_pqueue.rb
16-
- HISTORY.rdoc
17-
- LICENSE
18-
- README.rdoc
19-
- VERSION
20-
version: 1.0.0
21-
licenses:
22-
- LGPLv3
23-
copyright: Copyright (c) 2001 K. Kodama
24-
description: A priority queue is like a standard queue, except that each inserted elements is given a certain priority, based on the result of the comparison block given at instantiation time. Retrieving an element from the queue will always return the one with the highest priority.
25-
summary: Queue with prioritized elements
26-
authors:
27-
- K. Kodama
28-
- Ronald Butler
29-
- Olivier Renaud
30-
- Rick Bradley
31-
- Thomas Sawyer
32-
created: 2001-03-10
20+
development: true
21+
- name: microtest
22+
groups:
23+
- test
24+
development: true
25+
- name: ae
26+
groups:
27+
- test
28+
development: true
29+
dependencies: []
30+
conflicts: []
31+
repositories:
32+
- uri: git://github.com/rubyworks/pqueue.git
33+
scm: git
34+
name: upstream
35+
resources: {}
36+
extra: {}
37+
load_path:
38+
- lib
39+
revision: 0
40+
created: '2001-03-10'
41+
summary: Queue of Prioritized Elements
42+
title: PQueue
43+
version: 2.0.0
44+
name: pqueue
45+
description: ! 'A priority queue is like a standard queue, except that each inserted
46+
elements
47+
48+
is given a certain priority, based on the result of the comparison block given
49+
50+
at instantiation time. Retrieving an element from the queue will always return
51+
52+
the one with the highest priority.'
53+
organization: rubyworks
54+
date: '2011-10-29'

HISTORY.rdoc

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,18 @@
11
= CHANGE HISTORY
22

3+
== 2.0.0 / 2011-10-29
4+
5+
This is a complete rewrite to simplify the design and use more
6+
of Ruby's internal methods. Overall performance should be markedly
7+
improoved. Note that the interal array that stores the queue is not
8+
in reverse order from the previous version. If using #to_a be aware
9+
that the priority order is now reversed.
10+
11+
312
== 1.0.0 / 2009-07-05
413

5-
This is the initial standalone release of PQueue,
6-
spun-off from the Ruby Facets.
14+
This is the initial standalone release of PQueue, spun-off from the
15+
Ruby Facets and originally written by K. Komada.
716

817
Changes:
918

README.rdoc

Lines changed: 22 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
= PQueue
22

3+
{Home}[http://rubyworks.github.com/pqueue] |
4+
{Code}[http://github.com/rubyworks/pqueue] |
5+
{Docs}[http://rubydoc.info/gems/pqueue/frames] |
6+
{Mail}[http://groups.google.com/group/rubyworks] | #rubyworks
7+
8+
39
== DESCRIPTION
410

511
Priority queue with array based heap.
@@ -19,41 +25,32 @@ Heap.rb by Ronald Butler. The two libraries were later merged
1925
and generally improved by Olivier Renaud.
2026

2127

22-
== RESOURCES
23-
24-
* home: http://rubyworks.github.com/pqueue
25-
* code: http://github.com/rubyworks/pqueue
26-
* docs: http://rubyworks.github.com/pqueue/rdoc
27-
* talk: http://googlegroups.com/group/rubyworks
28-
29-
3028
== SYNOPSIS
3129

3230
require 'pqueue'
3331

34-
pq = PQueue.new([1,2,3]){ |a,b| a > b }
32+
pq = PQueue.new([2,3,1]){ |a,b| a > b }
3533

3634
pq.pop #=> 3
3735

3836

39-
== COPYING
37+
== ACKNOWLEDGEMENT
38+
39+
Although the library has been completely rewritten since, we still would
40+
like to acknowledge the efforts of the original PQueue authors and
41+
contributors.
42+
43+
* Olivier Renaud (2007)
44+
* Rick Bradley (2003)
45+
* Ronald Butler (2002)
46+
* K. Kodama (2001, original library)
47+
4048

41-
* Copyright (c) 2011 Thomas Sawyer
42-
* Copyright (c) 2007 Olivier Renaud
43-
* Copyright (c) 2005 K.Kodama
44-
* Copyright (c) 2003 Rick Bradley
45-
* Copyright (c) 2002 Ronald Butler
46-
* Copyright (c) 2001 K.Kodama
49+
== COPYRIGHTS
4750

48-
Licensed under the Apache License, Version 2.0 (the "License");
49-
you may not use this program except in compliance with the License.
50-
You may obtain a copy of the License at
51+
Copyright (c) 2011 Rubyworks.
5152

52-
http://www.apache.org/licenses/LICENSE-2.0
53+
PQueue is distributable in accordance with the *FreeBSD* license.
5354

54-
Unless required by applicable law or agreed to in writing, software
55-
distributed under the License is distributed on an "AS IS" BASIS,
56-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
57-
See the License for the specific language governing permissions and
58-
limitations under the License.
55+
See the COPYING.rdoc file for details.
5956

VERSION

Lines changed: 0 additions & 1 deletion
This file was deleted.

test/test_pqueue.rb

Lines changed: 37 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,30 @@
1+
require 'microtest'
2+
require 'ae/legacy'
3+
14
require 'pqueue'
2-
require 'test/unit'
35

4-
class TC_PQueue < Test::Unit::TestCase
5-
ARY_TEST = [2,6,1,3,8,15,0,-4,7,8,10]
6+
class TC_PQueue < MicroTest::TestCase
7+
include AE::Legacy::Assertions
8+
9+
ARY_TEST = [2,6,1,3,8,15,0,-4,7,8,10]
610
ARY_TEST_2 = [25,10,5,13,16,9,16,12]
711

8-
def test_initialize
9-
assert_nothing_raised { PQueue.new }
10-
assert_nothing_raised { PQueue.new([3]) }
11-
assert_nothing_raised { PQueue.new(ARY_TEST) }
12-
assert_nothing_raised { PQueue.new {|a,b| a<b} }
13-
assert_nothing_raised { PQueue.new([3]) {|a,b| a<b} }
14-
assert_nothing_raised { PQueue.new(ARY_TEST) {|a,b| a<b} }
12+
def test_initialize_empty
13+
PQueue.new
14+
end
15+
16+
def test_initialize_single_element
17+
PQueue.new([3])
18+
end
19+
20+
def test_initialize_multiple_elements
21+
PQueue.new(ARY_TEST)
22+
end
23+
24+
def test_initialize_with_custom_comparison
25+
PQueue.new {|a,b| b<=>a}
26+
PQueue.new([3]) {|a,b| b<=>a}
27+
PQueue.new(ARY_TEST) {|a,b| b<=>a}
1528
end
1629

1730
def test_top
@@ -36,14 +49,18 @@ def test_insertion
3649
ret = q.push(24)
3750
assert_equal(q, ret)
3851
assert_equal(ARY_TEST.size+1, q.size)
52+
end
53+
54+
def test_concat
55+
q = PQueue.new(ARY_TEST)
3956

40-
ret = q.push_all(ARY_TEST_2)
57+
ret = q.concat(ARY_TEST_2)
4158
assert_equal(q, ret)
42-
assert_equal(ARY_TEST.size+1+ARY_TEST_2.size, q.size)
59+
assert_equal(ARY_TEST.size+ARY_TEST_2.size, q.size)
4360

4461
q = PQueue.new(ARY_TEST)
4562
r = PQueue.new(ARY_TEST_2)
46-
q.push_all(r)
63+
q.concat(r)
4764
assert_equal(ARY_TEST.size + ARY_TEST_2.size, q.size)
4865
end
4966

@@ -70,9 +87,9 @@ def test_inspect
7087

7188
def test_to_a
7289
q = PQueue.new(ARY_TEST)
73-
assert_equal(ARY_TEST.sort.reverse, q.sort)
90+
assert_equal(ARY_TEST.sort, q.to_a)
7491
q = PQueue.new(0..4)
75-
assert_equal([4,3,2,1,0], q.sort)
92+
assert_equal([0,1,2,3,4], q.to_a)
7693
end
7794

7895
def pop_array
@@ -90,20 +107,20 @@ def test_include
90107
assert_equal(false, q.include?(15))
91108
end
92109

93-
def test_assert_equal
110+
def test_equal
94111
assert_equal(PQueue.new, PQueue.new)
95112
assert_equal(PQueue.new(ARY_TEST), PQueue.new(ARY_TEST.sort_by{rand}))
96113
end
97114

98-
def test_replace_top
115+
def test_swap
99116
q = PQueue.new
100-
assert_nil(q.replace_top(6))
117+
assert_nil(q.swap(6))
101118
assert_equal(6, q.top)
102119

103120
q = PQueue.new(ARY_TEST)
104121
h = PQueue.new(ARY_TEST)
105122
q.pop; q.push(11)
106-
h.replace_top(11)
123+
h.swap(11)
107124
assert_equal(q, h)
108125
end
109126

@@ -126,7 +143,7 @@ def test_array_copied
126143

127144
ary = ARY_TEST.dup
128145
q = PQueue.new([1])
129-
q.push_all(ary)
146+
q.concat(ary)
130147
q.pop
131148
assert_equal(ARY_TEST, ary)
132149

0 commit comments

Comments
 (0)