priority_queue 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.0
1
+ 0.2.0
@@ -33,4 +33,8 @@ class PriorityQueue
33
33
  size + queue.size
34
34
  end
35
35
  end
36
+
37
+ def empty?
38
+ @queues.all? {|priority, queue| queue.empty?}
39
+ end
36
40
  end
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{priority_queue}
8
- s.version = "0.1.0"
8
+ s.version = "0.2.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Justin Balthrop"]
@@ -40,4 +40,26 @@ class PriorityQueueTest < Test::Unit::TestCase
40
40
  3.times { pq.shift }
41
41
  assert_equal 0, pq.size
42
42
  end
43
+
44
+ should "know if it is empty" do
45
+ pq = PriorityQueue.new
46
+
47
+ assert pq.empty?
48
+
49
+ pq[7] << :foo
50
+ pq[7] << :fu
51
+ pq[1] << :bap
52
+ pq[0] << :zap
53
+
54
+ assert !pq.empty?
55
+
56
+ 3.times { pq.shift }
57
+ assert !pq.empty?
58
+
59
+ pq.shift
60
+ assert pq.empty?
61
+
62
+ pq.shift
63
+ assert pq.empty?
64
+ end
43
65
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: priority_queue
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Justin Balthrop