about summary refs log tree commit diff
path: root/src/libextra/priority_queue.rs
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2014-02-04 04:31:34 -0800
committerbors <bors@rust-lang.org>2014-02-04 04:31:34 -0800
commitcdc678945fec211b06b6ec4ba059b8259dfeb2c2 (patch)
tree477355751716088e11b4425eaabf21eb7925c81a /src/libextra/priority_queue.rs
parent10de762f6cf87a1c41cd047ec6b9970688f48873 (diff)
parent65f35781489ccaa66585b91f215308f3091bf404 (diff)
downloadrust-cdc678945fec211b06b6ec4ba059b8259dfeb2c2.tar.gz
rust-cdc678945fec211b06b6ec4ba059b8259dfeb2c2.zip
auto merge of #11951 : dmanescu/rust/reserve-rename, r=huonw
Changes in std::{str,vec,hashmap} and extra::{priority_queue,ringbuf}.
Fixes #11949
Diffstat (limited to 'src/libextra/priority_queue.rs')
-rw-r--r--src/libextra/priority_queue.rs14
1 files changed, 9 insertions, 5 deletions
diff --git a/src/libextra/priority_queue.rs b/src/libextra/priority_queue.rs
index 33b3931e989..3ae3dae9ea3 100644
--- a/src/libextra/priority_queue.rs
+++ b/src/libextra/priority_queue.rs
@@ -51,10 +51,14 @@ impl<T:Ord> PriorityQueue<T> {
     /// Returns the number of elements the queue can hold without reallocating
     pub fn capacity(&self) -> uint { self.data.capacity() }
 
-    pub fn reserve(&mut self, n: uint) { self.data.reserve(n) }
-
-    pub fn reserve_at_least(&mut self, n: uint) {
-        self.data.reserve_at_least(n)
+    /// Reserve capacity for exactly n elements in the PriorityQueue.
+    /// Do nothing if the capacity is already sufficient.
+    pub fn reserve_exact(&mut self, n: uint) { self.data.reserve_exact(n) }
+
+    /// Reserve capacity for at least n elements in the PriorityQueue.
+    /// Do nothing if the capacity is already sufficient.
+    pub fn reserve(&mut self, n: uint) {
+        self.data.reserve(n)
     }
 
     /// Pop the greatest item from the queue - fails if empty
@@ -203,7 +207,7 @@ impl<T: Ord> Extendable<T> for PriorityQueue<T> {
         let (lower, _) = iter.size_hint();
 
         let len = self.capacity();
-        self.reserve_at_least(len + lower);
+        self.reserve(len + lower);
 
         for elem in *iter {
             self.push(elem);