@@ -226,10 +226,10 @@ impl<K: Ord, V> Map<K, V> for TreeMap<K, V> {
226
226
}
227
227
228
228
impl < K : Ord , V > MutableMap < K , V > for TreeMap < K , V > {
229
- // See comments on def_tree_find_mut_with
229
+ // See comments on tree_find_with_mut
230
230
#[ inline]
231
231
fn find_mut < ' a > ( & ' a mut self , key : & K ) -> Option < & ' a mut V > {
232
- tree_find_mut_with ( & mut self . root , |x| key. cmp ( x) )
232
+ tree_find_with_mut ( & mut self . root , |x| key. cmp ( x) )
233
233
}
234
234
235
235
fn swap ( & mut self , key : K , value : V ) -> Option < V > {
@@ -361,6 +361,12 @@ impl<K: Ord, V> TreeMap<K, V> {
361
361
RevEntries { iter : self . iter ( ) }
362
362
}
363
363
364
+ /// Deprecated: use `iter_mut`.
365
+ #[ deprecated = "use iter_mut" ]
366
+ pub fn mut_iter < ' a > ( & ' a mut self ) -> MutEntries < ' a , K , V > {
367
+ self . iter_mut ( )
368
+ }
369
+
364
370
/// Gets a lazy forward iterator over the key-value pairs in the
365
371
/// map, with the values being mutable.
366
372
///
@@ -383,15 +389,21 @@ impl<K: Ord, V> TreeMap<K, V> {
383
389
/// assert_eq!(map.find(&"b"), Some(&12));
384
390
/// assert_eq!(map.find(&"c"), Some(&3));
385
391
/// ```
386
- pub fn mut_iter < ' a > ( & ' a mut self ) -> MutEntries < ' a , K , V > {
392
+ pub fn iter_mut < ' a > ( & ' a mut self ) -> MutEntries < ' a , K , V > {
387
393
MutEntries {
388
394
stack : vec ! ( ) ,
389
- node : mut_deref ( & mut self . root ) ,
395
+ node : deref_mut ( & mut self . root ) ,
390
396
remaining_min : self . length ,
391
397
remaining_max : self . length
392
398
}
393
399
}
394
400
401
+ /// Deprecated: use `rev_iter_mut`.
402
+ #[ deprecated = "use rev_iter_mut" ]
403
+ pub fn mut_rev_iter < ' a > ( & ' a mut self ) -> RevMutEntries < ' a , K , V > {
404
+ self . rev_iter_mut ( )
405
+ }
406
+
395
407
/// Gets a lazy reverse iterator over the key-value pairs in the
396
408
/// map, with the values being mutable.
397
409
///
@@ -414,10 +426,15 @@ impl<K: Ord, V> TreeMap<K, V> {
414
426
/// assert_eq!(map.find(&"b"), Some(&12));
415
427
/// assert_eq!(map.find(&"c"), Some(&13));
416
428
/// ```
417
- pub fn mut_rev_iter < ' a > ( & ' a mut self ) -> RevMutEntries < ' a , K , V > {
429
+ pub fn rev_iter_mut < ' a > ( & ' a mut self ) -> RevMutEntries < ' a , K , V > {
418
430
RevMutEntries { iter : self . mut_iter ( ) }
419
431
}
420
432
433
+ /// Deprecated: use `into_iter`.
434
+ #[ depreated = "use into_iter" ]
435
+ pub fn move_iter ( self ) -> MoveEntries < K , V > {
436
+ self . into_iter ( )
437
+ }
421
438
422
439
/// Gets a lazy iterator that consumes the treemap.
423
440
///
@@ -434,7 +451,7 @@ impl<K: Ord, V> TreeMap<K, V> {
434
451
/// let vec: Vec<(&str, int)> = map.move_iter().collect();
435
452
/// assert_eq!(vec, vec![("a", 1), ("b", 2), ("c", 3)]);
436
453
/// ```
437
- pub fn move_iter ( self ) -> MoveEntries < K , V > {
454
+ pub fn into_iter ( self ) -> MoveEntries < K , V > {
438
455
let TreeMap { root : root, length : length } = self ;
439
456
let stk = match root {
440
457
None => vec ! ( ) ,
@@ -477,6 +494,12 @@ impl<K, V> TreeMap<K, V> {
477
494
tree_find_with ( & self . root , f)
478
495
}
479
496
497
+ /// Deprecated: use `find_with_mut`.
498
+ #[ deprecated = "use find_with_mut" ]
499
+ pub fn find_mut_with < ' a > ( & ' a mut self , f: |& K | -> Ordering ) -> Option < & ' a mut V > {
500
+ self . find_with_mut ( f)
501
+ }
502
+
480
503
/// Returns the value for which `f(key)` returns `Equal`. `f` is invoked
481
504
/// with current key and guides tree navigation. That means `f` should
482
505
/// be aware of natural ordering of the tree.
@@ -497,8 +520,8 @@ impl<K, V> TreeMap<K, V> {
497
520
/// assert_eq!(t.find(&"User-Agent"), Some(&new_ua));
498
521
/// ```
499
522
#[ inline]
500
- pub fn find_mut_with < ' a > ( & ' a mut self , f: |& K | -> Ordering ) -> Option < & ' a mut V > {
501
- tree_find_mut_with ( & mut self . root , f)
523
+ pub fn find_with_mut < ' a > ( & ' a mut self , f: |& K | -> Ordering ) -> Option < & ' a mut V > {
524
+ tree_find_with_mut ( & mut self . root , f)
502
525
}
503
526
}
504
527
@@ -594,15 +617,21 @@ impl<K: Ord, V> TreeMap<K, V> {
594
617
595
618
/// Gets a lazy iterator that should be initialized using
596
619
/// `traverse_left`/`traverse_right`/`traverse_complete`.
597
- fn mut_iter_for_traversal < ' a > ( & ' a mut self ) -> MutEntries < ' a , K , V > {
620
+ fn iter_mut_for_traversal < ' a > ( & ' a mut self ) -> MutEntries < ' a , K , V > {
598
621
MutEntries {
599
622
stack : vec ! ( ) ,
600
- node : mut_deref ( & mut self . root ) ,
623
+ node : deref_mut ( & mut self . root ) ,
601
624
remaining_min : 0 ,
602
625
remaining_max : self . length
603
626
}
604
627
}
605
628
629
+ /// Deprecated: use `lower_bound_mut`.
630
+ #[ deprecated = "use lower_bound_mut" ]
631
+ pub fn mut_lower_bound < ' a > ( & ' a mut self , k : & K ) -> MutEntries < ' a , K , V > {
632
+ self . lower_bound_mut ( k)
633
+ }
634
+
606
635
/// Returns a lazy value iterator to the first key-value pair (with
607
636
/// the value being mutable) whose key is not less than `k`.
608
637
///
@@ -633,8 +662,14 @@ impl<K: Ord, V> TreeMap<K, V> {
633
662
/// assert_eq!(map.find(&6), Some(&"changed"));
634
663
/// assert_eq!(map.find(&8), Some(&"changed"));
635
664
/// ```
636
- pub fn mut_lower_bound < ' a > ( & ' a mut self , k : & K ) -> MutEntries < ' a , K , V > {
637
- bound_setup ! ( self . mut_iter_for_traversal( ) , k, true )
665
+ pub fn lower_bound_mut < ' a > ( & ' a mut self , k : & K ) -> MutEntries < ' a , K , V > {
666
+ bound_setup ! ( self . iter_mut_for_traversal( ) , k, true )
667
+ }
668
+
669
+ /// Deprecated: use `upper_bound_mut`.
670
+ #[ deprecated = "use upper_bound_mut" ]
671
+ pub fn mut_upper_bound < ' a > ( & ' a mut self , k : & K ) -> MutEntries < ' a , K , V > {
672
+ self . upper_bound_mut ( k)
638
673
}
639
674
640
675
/// Returns a lazy iterator to the first key-value pair (with the
@@ -667,8 +702,8 @@ impl<K: Ord, V> TreeMap<K, V> {
667
702
/// assert_eq!(map.find(&6), Some(&"changed"));
668
703
/// assert_eq!(map.find(&8), Some(&"changed"));
669
704
/// ```
670
- pub fn mut_upper_bound < ' a > ( & ' a mut self , k : & K ) -> MutEntries < ' a , K , V > {
671
- bound_setup ! ( self . mut_iter_for_traversal ( ) , k, false )
705
+ pub fn upper_bound_mut < ' a > ( & ' a mut self , k : & K ) -> MutEntries < ' a , K , V > {
706
+ bound_setup ! ( self . iter_mut_for_traversal ( ) , k, false )
672
707
}
673
708
}
674
709
@@ -862,7 +897,7 @@ define_iterator! {
862
897
define_iterator ! {
863
898
MutEntries ,
864
899
RevMutEntries ,
865
- deref = mut_deref ,
900
+ deref = deref_mut ,
866
901
867
902
addr_mut = mut
868
903
}
@@ -877,7 +912,7 @@ fn deref<'a, K, V>(node: &'a Option<Box<TreeNode<K, V>>>) -> *const TreeNode<K,
877
912
}
878
913
}
879
914
880
- fn mut_deref < K , V > ( x : & mut Option < Box < TreeNode < K , V > > > )
915
+ fn deref_mut < K , V > ( x : & mut Option < Box < TreeNode < K , V > > > )
881
916
-> * mut TreeNode < K , V > {
882
917
match * x {
883
918
Some ( ref mut n) => {
@@ -1169,6 +1204,12 @@ impl<T: Ord> TreeSet<T> {
1169
1204
RevSetItems { iter : self . map . rev_iter ( ) }
1170
1205
}
1171
1206
1207
+ /// Deprecated: use `into_iter`.
1208
+ #[ deprecated = "use into_iter" ]
1209
+ pub fn move_iter ( self ) -> MoveSetItems < T > {
1210
+ self . into_iter ( )
1211
+ }
1212
+
1172
1213
/// Creates a consuming iterator, that is, one that moves each value out of the
1173
1214
/// set in ascending order. The set cannot be used after calling this.
1174
1215
///
@@ -1183,8 +1224,8 @@ impl<T: Ord> TreeSet<T> {
1183
1224
/// assert_eq!(v, vec![1, 2, 3, 4, 5]);
1184
1225
/// ```
1185
1226
#[ inline]
1186
- pub fn move_iter ( self ) -> MoveSetItems < T > {
1187
- self . map . move_iter ( ) . map ( |( value, _) | value)
1227
+ pub fn into_iter ( self ) -> MoveSetItems < T > {
1228
+ self . map . into_iter ( ) . map ( |( value, _) | value)
1188
1229
}
1189
1230
1190
1231
/// Gets a lazy iterator pointing to the first value not less than `v` (greater or equal).
@@ -1488,7 +1529,7 @@ fn tree_find_with<'r, K, V>(node: &'r Option<Box<TreeNode<K, V>>>,
1488
1529
}
1489
1530
1490
1531
// See comments above tree_find_with
1491
- fn tree_find_mut_with < ' r , K , V > ( node : & ' r mut Option < Box < TreeNode < K , V > > > ,
1532
+ fn tree_find_with_mut < ' r , K , V > ( node : & ' r mut Option < Box < TreeNode < K , V > > > ,
1492
1533
f: |& K | -> Ordering ) -> Option < & ' r mut V > {
1493
1534
1494
1535
let mut current = node;
0 commit comments