about summary refs log tree commit diff
path: root/src/libstd/priority_queue.rs
diff options
context:
space:
mode:
authorDaniel Micay <danielmicay@gmail.com>2013-01-21 17:25:57 -0500
committerDaniel Micay <danielmicay@gmail.com>2013-01-22 08:09:53 -0500
commitffb9049274beaac8ddde6b9632d8c9ac7715f9d1 (patch)
tree6521f4df09db86beda63fd542dc38b834ce508f5 /src/libstd/priority_queue.rs
parent66e50892c1840a030892b2dc6480d42635990b0c (diff)
downloadrust-ffb9049274beaac8ddde6b9632d8c9ac7715f9d1.tar.gz
rust-ffb9049274beaac8ddde6b9632d8c9ac7715f9d1.zip
add a Mutable container trait with clear
Diffstat (limited to 'src/libstd/priority_queue.rs')
-rw-r--r--src/libstd/priority_queue.rs9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/libstd/priority_queue.rs b/src/libstd/priority_queue.rs
index b9c040de42a..0ff40b6421a 100644
--- a/src/libstd/priority_queue.rs
+++ b/src/libstd/priority_queue.rs
@@ -10,6 +10,7 @@
 
 //! A priority queue implemented with a binary heap
 
+use core::container::Mutable;
 use core::cmp::Ord;
 use core::prelude::*;
 use core::ptr::addr_of;
@@ -24,6 +25,11 @@ pub struct PriorityQueue <T: Ord>{
     priv data: ~[T],
 }
 
+impl <T: Ord> PriorityQueue<T>: Mutable {
+    /// Drop all items from the queue
+    fn clear(&mut self) { self.data.truncate(0) }
+}
+
 impl <T: Ord> PriorityQueue<T> {
     /// Returns the greatest item in the queue - fails if empty
     pure fn top(&self) -> &self/T { &self.data[0] }
@@ -51,9 +57,6 @@ impl <T: Ord> PriorityQueue<T> {
         vec::reserve_at_least(&mut self.data, n)
     }
 
-    /// Drop all items from the queue
-    fn clear(&mut self) { self.data.truncate(0) }
-
     /// Pop the greatest item from the queue - fails if empty
     fn pop(&mut self) -> T {
         let mut item = self.data.pop();