summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/nlp_ruby/PriorityQueue.rb3
1 files changed, 2 insertions, 1 deletions
diff --git a/lib/nlp_ruby/PriorityQueue.rb b/lib/nlp_ruby/PriorityQueue.rb
index 22662b3..f090e60 100644
--- a/lib/nlp_ruby/PriorityQueue.rb
+++ b/lib/nlp_ruby/PriorityQueue.rb
@@ -5,6 +5,7 @@ class PriorityQueue
def initialize a=Array.new
@queue = Array.new a
+ sort!
end
def sort!
@@ -12,12 +13,12 @@ class PriorityQueue
end
def pop
- sort!
@queue.pop
end
def push i
@queue << i
+ sort!
end
def empty?