@@ -161,14 +161,14 @@ use vec::{mod, Vec};
161
161
///
162
162
/// This will be a max-heap.
163
163
#[ deriving( Clone ) ]
164
+ #[ stable]
164
165
pub struct BinaryHeap < T > {
165
166
data : Vec < T > ,
166
167
}
167
168
168
169
#[ stable]
169
170
impl < T : Ord > Default for BinaryHeap < T > {
170
171
#[ inline]
171
- #[ stable]
172
172
fn default ( ) -> BinaryHeap < T > { BinaryHeap :: new ( ) }
173
173
}
174
174
@@ -182,7 +182,7 @@ impl<T: Ord> BinaryHeap<T> {
182
182
/// let mut heap = BinaryHeap::new();
183
183
/// heap.push(4u);
184
184
/// ```
185
- #[ unstable = "matches collection reform specification, waiting for dust to settle" ]
185
+ #[ stable ]
186
186
pub fn new ( ) -> BinaryHeap < T > { BinaryHeap { data : vec ! [ ] } }
187
187
188
188
/// Creates an empty `BinaryHeap` with a specific capacity.
@@ -197,7 +197,7 @@ impl<T: Ord> BinaryHeap<T> {
197
197
/// let mut heap = BinaryHeap::with_capacity(10);
198
198
/// heap.push(4u);
199
199
/// ```
200
- #[ unstable = "matches collection reform specification, waiting for dust to settle" ]
200
+ #[ stable ]
201
201
pub fn with_capacity ( capacity : uint ) -> BinaryHeap < T > {
202
202
BinaryHeap { data : Vec :: with_capacity ( capacity) }
203
203
}
@@ -235,7 +235,7 @@ impl<T: Ord> BinaryHeap<T> {
235
235
/// println!("{}", x);
236
236
/// }
237
237
/// ```
238
- #[ unstable = "matches collection reform specification, waiting for dust to settle" ]
238
+ #[ stable ]
239
239
pub fn iter ( & self ) -> Iter < T > {
240
240
Iter { iter : self . data . iter ( ) }
241
241
}
@@ -256,7 +256,7 @@ impl<T: Ord> BinaryHeap<T> {
256
256
/// println!("{}", x);
257
257
/// }
258
258
/// ```
259
- #[ unstable = "matches collection reform specification, waiting for dust to settle" ]
259
+ #[ stable ]
260
260
pub fn into_iter ( self ) -> IntoIter < T > {
261
261
IntoIter { iter : self . data . into_iter ( ) }
262
262
}
@@ -291,7 +291,7 @@ impl<T: Ord> BinaryHeap<T> {
291
291
/// assert!(heap.capacity() >= 100);
292
292
/// heap.push(4u);
293
293
/// ```
294
- #[ unstable = "matches collection reform specification, waiting for dust to settle" ]
294
+ #[ stable ]
295
295
pub fn capacity ( & self ) -> uint { self . data . capacity ( ) }
296
296
297
297
/// Reserves the minimum capacity for exactly `additional` more elements to be inserted in the
@@ -314,7 +314,7 @@ impl<T: Ord> BinaryHeap<T> {
314
314
/// assert!(heap.capacity() >= 100);
315
315
/// heap.push(4u);
316
316
/// ```
317
- #[ unstable = "matches collection reform specification, waiting for dust to settle" ]
317
+ #[ stable ]
318
318
pub fn reserve_exact ( & mut self , additional : uint ) {
319
319
self . data . reserve_exact ( additional) ;
320
320
}
@@ -335,13 +335,13 @@ impl<T: Ord> BinaryHeap<T> {
335
335
/// assert!(heap.capacity() >= 100);
336
336
/// heap.push(4u);
337
337
/// ```
338
- #[ unstable = "matches collection reform specification, waiting for dust to settle" ]
338
+ #[ stable ]
339
339
pub fn reserve ( & mut self , additional : uint ) {
340
340
self . data . reserve ( additional) ;
341
341
}
342
342
343
343
/// Discards as much additional capacity as possible.
344
- #[ unstable = "matches collection reform specification, waiting for dust to settle" ]
344
+ #[ stable ]
345
345
pub fn shrink_to_fit ( & mut self ) {
346
346
self . data . shrink_to_fit ( ) ;
347
347
}
@@ -359,7 +359,7 @@ impl<T: Ord> BinaryHeap<T> {
359
359
/// assert_eq!(heap.pop(), Some(1));
360
360
/// assert_eq!(heap.pop(), None);
361
361
/// ```
362
- #[ unstable = "matches collection reform specification, waiting for dust to settle" ]
362
+ #[ stable ]
363
363
pub fn pop ( & mut self ) -> Option < T > {
364
364
self . data . pop ( ) . map ( |mut item| {
365
365
if !self . is_empty ( ) {
@@ -384,7 +384,7 @@ impl<T: Ord> BinaryHeap<T> {
384
384
/// assert_eq!(heap.len(), 3);
385
385
/// assert_eq!(heap.peek(), Some(&5));
386
386
/// ```
387
- #[ unstable = "matches collection reform specification, waiting for dust to settle" ]
387
+ #[ stable ]
388
388
pub fn push ( & mut self , item : T ) {
389
389
let old_len = self . len ( ) ;
390
390
self . data . push ( item) ;
@@ -539,11 +539,11 @@ impl<T: Ord> BinaryHeap<T> {
539
539
}
540
540
541
541
/// Returns the length of the binary heap.
542
- #[ unstable = "matches collection reform specification, waiting for dust to settle" ]
542
+ #[ stable ]
543
543
pub fn len ( & self ) -> uint { self . data . len ( ) }
544
544
545
545
/// Checks if the binary heap is empty.
546
- #[ unstable = "matches collection reform specification, waiting for dust to settle" ]
546
+ #[ stable ]
547
547
pub fn is_empty ( & self ) -> bool { self . len ( ) == 0 }
548
548
549
549
/// Clears the binary heap, returning an iterator over the removed elements.
@@ -554,7 +554,7 @@ impl<T: Ord> BinaryHeap<T> {
554
554
}
555
555
556
556
/// Drops all items from the binary heap.
557
- #[ unstable = "matches collection reform specification, waiting for dust to settle" ]
557
+ #[ stable ]
558
558
pub fn clear ( & mut self ) { self . drain ( ) ; }
559
559
}
560
560
@@ -570,6 +570,7 @@ impl<'a, T> Clone for Iter<'a, T> {
570
570
}
571
571
}
572
572
573
+ #[ stable]
573
574
impl < ' a , T > Iterator < & ' a T > for Iter < ' a , T > {
574
575
#[ inline]
575
576
fn next ( & mut self ) -> Option < & ' a T > { self . iter . next ( ) }
@@ -578,18 +579,21 @@ impl<'a, T> Iterator<&'a T> for Iter<'a, T> {
578
579
fn size_hint ( & self ) -> ( uint , Option < uint > ) { self . iter . size_hint ( ) }
579
580
}
580
581
582
+ #[ stable]
581
583
impl < ' a , T > DoubleEndedIterator < & ' a T > for Iter < ' a , T > {
582
584
#[ inline]
583
585
fn next_back ( & mut self ) -> Option < & ' a T > { self . iter . next_back ( ) }
584
586
}
585
587
588
+ #[ stable]
586
589
impl < ' a , T > ExactSizeIterator < & ' a T > for Iter < ' a , T > { }
587
590
588
591
/// An iterator that moves out of a `BinaryHeap`.
589
592
pub struct IntoIter < T > {
590
593
iter : vec:: IntoIter < T > ,
591
594
}
592
595
596
+ #[ stable]
593
597
impl < T > Iterator < T > for IntoIter < T > {
594
598
#[ inline]
595
599
fn next ( & mut self ) -> Option < T > { self . iter . next ( ) }
@@ -598,18 +602,21 @@ impl<T> Iterator<T> for IntoIter<T> {
598
602
fn size_hint ( & self ) -> ( uint , Option < uint > ) { self . iter . size_hint ( ) }
599
603
}
600
604
605
+ #[ stable]
601
606
impl < T > DoubleEndedIterator < T > for IntoIter < T > {
602
607
#[ inline]
603
608
fn next_back ( & mut self ) -> Option < T > { self . iter . next_back ( ) }
604
609
}
605
610
611
+ #[ stable]
606
612
impl < T > ExactSizeIterator < T > for IntoIter < T > { }
607
613
608
614
/// An iterator that drains a `BinaryHeap`.
609
615
pub struct Drain < ' a , T : ' a > {
610
616
iter : vec:: Drain < ' a , T > ,
611
617
}
612
618
619
+ #[ stable]
613
620
impl < ' a , T : ' a > Iterator < T > for Drain < ' a , T > {
614
621
#[ inline]
615
622
fn next ( & mut self ) -> Option < T > { self . iter . next ( ) }
@@ -618,19 +625,23 @@ impl<'a, T: 'a> Iterator<T> for Drain<'a, T> {
618
625
fn size_hint ( & self ) -> ( uint , Option < uint > ) { self . iter . size_hint ( ) }
619
626
}
620
627
628
+ #[ stable]
621
629
impl < ' a , T : ' a > DoubleEndedIterator < T > for Drain < ' a , T > {
622
630
#[ inline]
623
631
fn next_back ( & mut self ) -> Option < T > { self . iter . next_back ( ) }
624
632
}
625
633
634
+ #[ stable]
626
635
impl < ' a , T : ' a > ExactSizeIterator < T > for Drain < ' a , T > { }
627
636
637
+ #[ stable]
628
638
impl < T : Ord > FromIterator < T > for BinaryHeap < T > {
629
639
fn from_iter < Iter : Iterator < T > > ( iter : Iter ) -> BinaryHeap < T > {
630
640
BinaryHeap :: from_vec ( iter. collect ( ) )
631
641
}
632
642
}
633
643
644
+ #[ stable]
634
645
impl < T : Ord > Extend < T > for BinaryHeap < T > {
635
646
fn extend < Iter : Iterator < T > > ( & mut self , mut iter : Iter ) {
636
647
let ( lower, _) = iter. size_hint ( ) ;
0 commit comments