Skip to content

Commit efd2591

Browse files
committed
stabilize more of collections
1 parent 84f5ad8 commit efd2591

File tree

9 files changed

+398
-319
lines changed

9 files changed

+398
-319
lines changed

src/libcollections/binary_heap.rs

Lines changed: 25 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -161,14 +161,14 @@ use vec::{mod, Vec};
161161
///
162162
/// This will be a max-heap.
163163
#[deriving(Clone)]
164+
#[stable]
164165
pub struct BinaryHeap<T> {
165166
data: Vec<T>,
166167
}
167168

168169
#[stable]
169170
impl<T: Ord> Default for BinaryHeap<T> {
170171
#[inline]
171-
#[stable]
172172
fn default() -> BinaryHeap<T> { BinaryHeap::new() }
173173
}
174174

@@ -182,7 +182,7 @@ impl<T: Ord> BinaryHeap<T> {
182182
/// let mut heap = BinaryHeap::new();
183183
/// heap.push(4u);
184184
/// ```
185-
#[unstable = "matches collection reform specification, waiting for dust to settle"]
185+
#[stable]
186186
pub fn new() -> BinaryHeap<T> { BinaryHeap { data: vec![] } }
187187

188188
/// Creates an empty `BinaryHeap` with a specific capacity.
@@ -197,7 +197,7 @@ impl<T: Ord> BinaryHeap<T> {
197197
/// let mut heap = BinaryHeap::with_capacity(10);
198198
/// heap.push(4u);
199199
/// ```
200-
#[unstable = "matches collection reform specification, waiting for dust to settle"]
200+
#[stable]
201201
pub fn with_capacity(capacity: uint) -> BinaryHeap<T> {
202202
BinaryHeap { data: Vec::with_capacity(capacity) }
203203
}
@@ -235,7 +235,7 @@ impl<T: Ord> BinaryHeap<T> {
235235
/// println!("{}", x);
236236
/// }
237237
/// ```
238-
#[unstable = "matches collection reform specification, waiting for dust to settle"]
238+
#[stable]
239239
pub fn iter(&self) -> Iter<T> {
240240
Iter { iter: self.data.iter() }
241241
}
@@ -256,7 +256,7 @@ impl<T: Ord> BinaryHeap<T> {
256256
/// println!("{}", x);
257257
/// }
258258
/// ```
259-
#[unstable = "matches collection reform specification, waiting for dust to settle"]
259+
#[stable]
260260
pub fn into_iter(self) -> IntoIter<T> {
261261
IntoIter { iter: self.data.into_iter() }
262262
}
@@ -291,7 +291,7 @@ impl<T: Ord> BinaryHeap<T> {
291291
/// assert!(heap.capacity() >= 100);
292292
/// heap.push(4u);
293293
/// ```
294-
#[unstable = "matches collection reform specification, waiting for dust to settle"]
294+
#[stable]
295295
pub fn capacity(&self) -> uint { self.data.capacity() }
296296

297297
/// Reserves the minimum capacity for exactly `additional` more elements to be inserted in the
@@ -314,7 +314,7 @@ impl<T: Ord> BinaryHeap<T> {
314314
/// assert!(heap.capacity() >= 100);
315315
/// heap.push(4u);
316316
/// ```
317-
#[unstable = "matches collection reform specification, waiting for dust to settle"]
317+
#[stable]
318318
pub fn reserve_exact(&mut self, additional: uint) {
319319
self.data.reserve_exact(additional);
320320
}
@@ -335,13 +335,13 @@ impl<T: Ord> BinaryHeap<T> {
335335
/// assert!(heap.capacity() >= 100);
336336
/// heap.push(4u);
337337
/// ```
338-
#[unstable = "matches collection reform specification, waiting for dust to settle"]
338+
#[stable]
339339
pub fn reserve(&mut self, additional: uint) {
340340
self.data.reserve(additional);
341341
}
342342

343343
/// Discards as much additional capacity as possible.
344-
#[unstable = "matches collection reform specification, waiting for dust to settle"]
344+
#[stable]
345345
pub fn shrink_to_fit(&mut self) {
346346
self.data.shrink_to_fit();
347347
}
@@ -359,7 +359,7 @@ impl<T: Ord> BinaryHeap<T> {
359359
/// assert_eq!(heap.pop(), Some(1));
360360
/// assert_eq!(heap.pop(), None);
361361
/// ```
362-
#[unstable = "matches collection reform specification, waiting for dust to settle"]
362+
#[stable]
363363
pub fn pop(&mut self) -> Option<T> {
364364
self.data.pop().map(|mut item| {
365365
if !self.is_empty() {
@@ -384,7 +384,7 @@ impl<T: Ord> BinaryHeap<T> {
384384
/// assert_eq!(heap.len(), 3);
385385
/// assert_eq!(heap.peek(), Some(&5));
386386
/// ```
387-
#[unstable = "matches collection reform specification, waiting for dust to settle"]
387+
#[stable]
388388
pub fn push(&mut self, item: T) {
389389
let old_len = self.len();
390390
self.data.push(item);
@@ -539,11 +539,11 @@ impl<T: Ord> BinaryHeap<T> {
539539
}
540540

541541
/// Returns the length of the binary heap.
542-
#[unstable = "matches collection reform specification, waiting for dust to settle"]
542+
#[stable]
543543
pub fn len(&self) -> uint { self.data.len() }
544544

545545
/// Checks if the binary heap is empty.
546-
#[unstable = "matches collection reform specification, waiting for dust to settle"]
546+
#[stable]
547547
pub fn is_empty(&self) -> bool { self.len() == 0 }
548548

549549
/// Clears the binary heap, returning an iterator over the removed elements.
@@ -554,7 +554,7 @@ impl<T: Ord> BinaryHeap<T> {
554554
}
555555

556556
/// Drops all items from the binary heap.
557-
#[unstable = "matches collection reform specification, waiting for dust to settle"]
557+
#[stable]
558558
pub fn clear(&mut self) { self.drain(); }
559559
}
560560

@@ -563,6 +563,7 @@ pub struct Iter <'a, T: 'a> {
563563
iter: slice::Iter<'a, T>,
564564
}
565565

566+
#[stable]
566567
impl<'a, T> Iterator<&'a T> for Iter<'a, T> {
567568
#[inline]
568569
fn next(&mut self) -> Option<&'a T> { self.iter.next() }
@@ -571,18 +572,21 @@ impl<'a, T> Iterator<&'a T> for Iter<'a, T> {
571572
fn size_hint(&self) -> (uint, Option<uint>) { self.iter.size_hint() }
572573
}
573574

575+
#[stable]
574576
impl<'a, T> DoubleEndedIterator<&'a T> for Iter<'a, T> {
575577
#[inline]
576578
fn next_back(&mut self) -> Option<&'a T> { self.iter.next_back() }
577579
}
578580

581+
#[stable]
579582
impl<'a, T> ExactSizeIterator<&'a T> for Iter<'a, T> {}
580583

581584
/// An iterator that moves out of a `BinaryHeap`.
582585
pub struct IntoIter<T> {
583586
iter: vec::IntoIter<T>,
584587
}
585588

589+
#[stable]
586590
impl<T> Iterator<T> for IntoIter<T> {
587591
#[inline]
588592
fn next(&mut self) -> Option<T> { self.iter.next() }
@@ -591,18 +595,21 @@ impl<T> Iterator<T> for IntoIter<T> {
591595
fn size_hint(&self) -> (uint, Option<uint>) { self.iter.size_hint() }
592596
}
593597

598+
#[stable]
594599
impl<T> DoubleEndedIterator<T> for IntoIter<T> {
595600
#[inline]
596601
fn next_back(&mut self) -> Option<T> { self.iter.next_back() }
597602
}
598603

604+
#[stable]
599605
impl<T> ExactSizeIterator<T> for IntoIter<T> {}
600606

601607
/// An iterator that drains a `BinaryHeap`.
602608
pub struct Drain<'a, T: 'a> {
603609
iter: vec::Drain<'a, T>,
604610
}
605611

612+
#[stable]
606613
impl<'a, T: 'a> Iterator<T> for Drain<'a, T> {
607614
#[inline]
608615
fn next(&mut self) -> Option<T> { self.iter.next() }
@@ -611,19 +618,23 @@ impl<'a, T: 'a> Iterator<T> for Drain<'a, T> {
611618
fn size_hint(&self) -> (uint, Option<uint>) { self.iter.size_hint() }
612619
}
613620

621+
#[stable]
614622
impl<'a, T: 'a> DoubleEndedIterator<T> for Drain<'a, T> {
615623
#[inline]
616624
fn next_back(&mut self) -> Option<T> { self.iter.next_back() }
617625
}
618626

627+
#[stable]
619628
impl<'a, T: 'a> ExactSizeIterator<T> for Drain<'a, T> {}
620629

630+
#[stable]
621631
impl<T: Ord> FromIterator<T> for BinaryHeap<T> {
622632
fn from_iter<Iter: Iterator<T>>(iter: Iter) -> BinaryHeap<T> {
623633
BinaryHeap::from_vec(iter.collect())
624634
}
625635
}
626636

637+
#[stable]
627638
impl<T: Ord> Extend<T> for BinaryHeap<T> {
628639
fn extend<Iter: Iterator<T>>(&mut self, mut iter: Iter) {
629640
let (lower, _) = iter.size_hint();

0 commit comments

Comments
 (0)