about summary refs log tree commit diff
path: root/src/libextra
diff options
context:
space:
mode:
authorSteven Fackler <sfackler@gmail.com>2013-07-25 04:02:08 -0400
committerSteven Fackler <sfackler@gmail.com>2013-07-25 15:17:30 -0700
commitfeb18fe8daa3952718c29039ec792d5e69d1276f (patch)
treec3d3d6143b8ae1c9765033a29b193f85dc0dd860 /src/libextra
parentb1f5b1ba5fd12a058d153e9da8f11cd1bc597bf0 (diff)
downloadrust-feb18fe8daa3952718c29039ec792d5e69d1276f.tar.gz
rust-feb18fe8daa3952718c29039ec792d5e69d1276f.zip
Added default impls for container methods
A couple of implementations of Container::is_empty weren't exactly
self.len() == 0 so I left them alone (e.g. Treemap).
Diffstat (limited to 'src/libextra')
-rw-r--r--src/libextra/bitv.rs2
-rw-r--r--src/libextra/priority_queue.rs3
-rw-r--r--src/libextra/ringbuf.rs3
-rw-r--r--src/libextra/smallintmap.rs3
-rw-r--r--src/libextra/treemap.rs13
5 files changed, 1 insertions, 23 deletions
diff --git a/src/libextra/bitv.rs b/src/libextra/bitv.rs
index 168d6a39916..6e52802578c 100644
--- a/src/libextra/bitv.rs
+++ b/src/libextra/bitv.rs
@@ -703,8 +703,8 @@ impl cmp::Eq for BitvSet {
 }
 
 impl Container for BitvSet {
+    #[inline]
     fn len(&self) -> uint { self.size }
-    fn is_empty(&self) -> bool { self.size == 0 }
 }
 
 impl Mutable for BitvSet {
diff --git a/src/libextra/priority_queue.rs b/src/libextra/priority_queue.rs
index d07b645a541..dd24a2a9eb9 100644
--- a/src/libextra/priority_queue.rs
+++ b/src/libextra/priority_queue.rs
@@ -27,9 +27,6 @@ pub struct PriorityQueue<T> {
 impl<T:Ord> Container for PriorityQueue<T> {
     /// Returns the length of the queue
     fn len(&self) -> uint { self.data.len() }
-
-    /// Returns true if a queue contains no elements
-    fn is_empty(&self) -> bool { self.len() == 0 }
 }
 
 impl<T:Ord> Mutable for PriorityQueue<T> {
diff --git a/src/libextra/ringbuf.rs b/src/libextra/ringbuf.rs
index f46af664b18..aa670ec5ff8 100644
--- a/src/libextra/ringbuf.rs
+++ b/src/libextra/ringbuf.rs
@@ -34,9 +34,6 @@ pub struct RingBuf<T> {
 impl<T> Container for RingBuf<T> {
     /// Return the number of elements in the RingBuf
     fn len(&self) -> uint { self.nelts }
-
-    /// Return true if the RingBufcontains no elements
-    fn is_empty(&self) -> bool { self.len() == 0 }
 }
 
 impl<T> Mutable for RingBuf<T> {
diff --git a/src/libextra/smallintmap.rs b/src/libextra/smallintmap.rs
index bd78f41ddf5..bf6f80534b4 100644
--- a/src/libextra/smallintmap.rs
+++ b/src/libextra/smallintmap.rs
@@ -37,9 +37,6 @@ impl<V> Container for SmallIntMap<V> {
         }
         sz
     }
-
-    /// Return true if the map contains no elements
-    fn is_empty(&self) -> bool { self.len() == 0 }
 }
 
 impl<V> Mutable for SmallIntMap<V> {
diff --git a/src/libextra/treemap.rs b/src/libextra/treemap.rs
index 303ae6a6d1d..8c7ace56412 100644
--- a/src/libextra/treemap.rs
+++ b/src/libextra/treemap.rs
@@ -135,19 +135,6 @@ impl<K: TotalOrd, V> MutableMap<K, V> for TreeMap<K, V> {
         find_mut(&mut self.root, key)
     }
 
-    /// Insert a key-value pair into the map. An existing value for a
-    /// key is replaced by the new value. Return true if the key did
-    /// not already exist in the map.
-    fn insert(&mut self, key: K, value: V) -> bool {
-        self.swap(key, value).is_none()
-    }
-
-    /// Remove a key-value pair from the map. Return true if the key
-    /// was present in the map, otherwise false.
-    fn remove(&mut self, key: &K) -> bool {
-        self.pop(key).is_some()
-    }
-
     /// Insert a key-value pair from the map. If the key already had a value
     /// present in the map, that value is returned. Otherwise None is returned.
     fn swap(&mut self, key: K, value: V) -> Option<V> {