about summary refs log tree commit diff
path: root/src/libcollections/priority_queue.rs
diff options
context:
space:
mode:
authorAlex Crichton <alex@alexcrichton.com>2014-10-30 13:43:24 -0700
committerAlex Crichton <alex@alexcrichton.com>2014-11-01 11:37:04 -0700
commit21ac985af44f4e2470ef6f4c0eb4d72daf5a6497 (patch)
treea120c184188926cd154b40f9da77ad8a6a455c1b /src/libcollections/priority_queue.rs
parent1442235d3feab4c5ca3f55e2b3345583f640a17e (diff)
downloadrust-21ac985af44f4e2470ef6f4c0eb4d72daf5a6497.tar.gz
rust-21ac985af44f4e2470ef6f4c0eb4d72daf5a6497.zip
collections: Remove all collections traits
As part of the collections reform RFC, this commit removes all collections
traits in favor of inherent methods on collections themselves. All methods
should continue to be available on all collections.

This is a breaking change with all of the collections traits being removed and
no longer being in the prelude. In order to update old code you should move the
trait implementations to inherent implementations directly on the type itself.

Note that some traits had default methods which will also need to be implemented
to maintain backwards compatibility.

[breaking-change]
cc #18424
Diffstat (limited to 'src/libcollections/priority_queue.rs')
-rw-r--r--src/libcollections/priority_queue.rs21
1 files changed, 9 insertions, 12 deletions
diff --git a/src/libcollections/priority_queue.rs b/src/libcollections/priority_queue.rs
index 65fd8ce4f54..885b5c99c45 100644
--- a/src/libcollections/priority_queue.rs
+++ b/src/libcollections/priority_queue.rs
@@ -159,7 +159,6 @@ use core::default::Default;
 use core::mem::{zeroed, replace, swap};
 use core::ptr;
 
-use {Mutable, MutableSeq};
 use slice;
 use vec::Vec;
 
@@ -171,16 +170,6 @@ pub struct PriorityQueue<T> {
     data: Vec<T>,
 }
 
-impl<T: Ord> Collection for PriorityQueue<T> {
-    /// Returns the length of the queue.
-    fn len(&self) -> uint { self.data.len() }
-}
-
-impl<T: Ord> Mutable for PriorityQueue<T> {
-    /// Drops all items from the queue.
-    fn clear(&mut self) { self.data.truncate(0) }
-}
-
 impl<T: Ord> Default for PriorityQueue<T> {
     #[inline]
     fn default() -> PriorityQueue<T> { PriorityQueue::new() }
@@ -504,6 +493,15 @@ impl<T: Ord> PriorityQueue<T> {
         let len = self.len();
         self.siftdown_range(pos, len);
     }
+
+    /// Returns the length of the queue.
+    pub fn len(&self) -> uint { self.data.len() }
+
+    /// Returns true if the queue contains no elements
+    pub fn is_empty(&self) -> bool { self.len() == 0 }
+
+    /// Drops all items from the queue.
+    pub fn clear(&mut self) { self.data.truncate(0) }
 }
 
 /// `PriorityQueue` iterator.
@@ -545,7 +543,6 @@ mod tests {
 
     use priority_queue::PriorityQueue;
     use vec::Vec;
-    use MutableSeq;
 
     #[test]
     fn test_iterator() {