@@ -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
@@ -563,6 +563,7 @@ pub struct Iter <'a, T: 'a> {
563
563
iter : slice:: Iter < ' a , T > ,
564
564
}
565
565
566
+ #[ stable]
566
567
impl < ' a , T > Iterator < & ' a T > for Iter < ' a , T > {
567
568
#[ inline]
568
569
fn next ( & mut self ) -> Option < & ' a T > { self . iter . next ( ) }
@@ -571,18 +572,21 @@ impl<'a, T> Iterator<&'a T> for Iter<'a, T> {
571
572
fn size_hint ( & self ) -> ( uint , Option < uint > ) { self . iter . size_hint ( ) }
572
573
}
573
574
575
+ #[ stable]
574
576
impl < ' a , T > DoubleEndedIterator < & ' a T > for Iter < ' a , T > {
575
577
#[ inline]
576
578
fn next_back ( & mut self ) -> Option < & ' a T > { self . iter . next_back ( ) }
577
579
}
578
580
581
+ #[ stable]
579
582
impl < ' a , T > ExactSizeIterator < & ' a T > for Iter < ' a , T > { }
580
583
581
584
/// An iterator that moves out of a `BinaryHeap`.
582
585
pub struct IntoIter < T > {
583
586
iter : vec:: IntoIter < T > ,
584
587
}
585
588
589
+ #[ stable]
586
590
impl < T > Iterator < T > for IntoIter < T > {
587
591
#[ inline]
588
592
fn next ( & mut self ) -> Option < T > { self . iter . next ( ) }
@@ -591,18 +595,21 @@ impl<T> Iterator<T> for IntoIter<T> {
591
595
fn size_hint ( & self ) -> ( uint , Option < uint > ) { self . iter . size_hint ( ) }
592
596
}
593
597
598
+ #[ stable]
594
599
impl < T > DoubleEndedIterator < T > for IntoIter < T > {
595
600
#[ inline]
596
601
fn next_back ( & mut self ) -> Option < T > { self . iter . next_back ( ) }
597
602
}
598
603
604
+ #[ stable]
599
605
impl < T > ExactSizeIterator < T > for IntoIter < T > { }
600
606
601
607
/// An iterator that drains a `BinaryHeap`.
602
608
pub struct Drain < ' a , T : ' a > {
603
609
iter : vec:: Drain < ' a , T > ,
604
610
}
605
611
612
+ #[ stable]
606
613
impl < ' a , T : ' a > Iterator < T > for Drain < ' a , T > {
607
614
#[ inline]
608
615
fn next ( & mut self ) -> Option < T > { self . iter . next ( ) }
@@ -611,19 +618,23 @@ impl<'a, T: 'a> Iterator<T> for Drain<'a, T> {
611
618
fn size_hint ( & self ) -> ( uint , Option < uint > ) { self . iter . size_hint ( ) }
612
619
}
613
620
621
+ #[ stable]
614
622
impl < ' a , T : ' a > DoubleEndedIterator < T > for Drain < ' a , T > {
615
623
#[ inline]
616
624
fn next_back ( & mut self ) -> Option < T > { self . iter . next_back ( ) }
617
625
}
618
626
627
+ #[ stable]
619
628
impl < ' a , T : ' a > ExactSizeIterator < T > for Drain < ' a , T > { }
620
629
630
+ #[ stable]
621
631
impl < T : Ord > FromIterator < T > for BinaryHeap < T > {
622
632
fn from_iter < Iter : Iterator < T > > ( iter : Iter ) -> BinaryHeap < T > {
623
633
BinaryHeap :: from_vec ( iter. collect ( ) )
624
634
}
625
635
}
626
636
637
+ #[ stable]
627
638
impl < T : Ord > Extend < T > for BinaryHeap < T > {
628
639
fn extend < Iter : Iterator < T > > ( & mut self , mut iter : Iter ) {
629
640
let ( lower, _) = iter. size_hint ( ) ;
0 commit comments