@@ -64,32 +64,20 @@ fn lt<K: Ord + TotalOrd, V: Ord>(a: &TreeMap<K, V>,
64
64
impl < K : Ord + TotalOrd , V : Ord > Ord for TreeMap < K , V > {
65
65
#[ inline]
66
66
fn lt ( & self , other : & TreeMap < K , V > ) -> bool { lt ( self , other) }
67
- #[ inline]
68
- fn le ( & self , other : & TreeMap < K , V > ) -> bool { !lt ( other, self ) }
69
- #[ inline]
70
- fn ge ( & self , other : & TreeMap < K , V > ) -> bool { !lt ( self , other) }
71
- #[ inline]
72
- fn gt ( & self , other : & TreeMap < K , V > ) -> bool { lt ( other, self ) }
73
67
}
74
68
75
69
impl < K : TotalOrd , V > Container for TreeMap < K , V > {
76
- /// Return the number of elements in the map
77
70
fn len ( & self ) -> uint { self . length }
78
-
79
- /// Return true if the map contains no elements
80
- fn is_empty ( & self ) -> bool { self . root . is_none ( ) }
81
71
}
82
72
83
73
impl < K : TotalOrd , V > Mutable for TreeMap < K , V > {
84
- /// Clear the map, removing all key-value pairs.
85
74
fn clear ( & mut self ) {
86
75
self . root = None ;
87
76
self . length = 0
88
77
}
89
78
}
90
79
91
80
impl < K : TotalOrd , V > Map < K , V > for TreeMap < K , V > {
92
- /// Return a reference to the value corresponding to the key
93
81
fn find < ' a > ( & ' a self , key : & K ) -> Option < & ' a V > {
94
82
let mut current: & ' a Option < ~TreeNode < K , V > > = & self . root ;
95
83
loop {
@@ -108,22 +96,17 @@ impl<K: TotalOrd, V> Map<K, V> for TreeMap<K, V> {
108
96
}
109
97
110
98
impl < K : TotalOrd , V > MutableMap < K , V > for TreeMap < K , V > {
111
- /// Return a mutable reference to the value corresponding to the key
112
99
#[ inline]
113
100
fn find_mut < ' a > ( & ' a mut self , key : & K ) -> Option < & ' a mut V > {
114
101
find_mut ( & mut self . root , key)
115
102
}
116
103
117
- /// Insert a key-value pair from the map. If the key already had a value
118
- /// present in the map, that value is returned. Otherwise None is returned.
119
104
fn swap ( & mut self , key : K , value : V ) -> Option < V > {
120
105
let ret = insert ( & mut self . root , key, value) ;
121
106
if ret. is_none ( ) { self . length += 1 }
122
107
ret
123
108
}
124
109
125
- /// Removes a key from the map, returning the value at the key if the key
126
- /// was previously in the map.
127
110
fn pop ( & mut self , key : & K ) -> Option < V > {
128
111
let ret = remove ( & mut self . root , key) ;
129
112
if ret. is_some ( ) { self . length -= 1 }
@@ -531,15 +514,13 @@ impl<K, V> Iterator<(K, V)> for MoveEntries<K,V> {
531
514
}
532
515
533
516
impl < ' a , T > Iterator < & ' a T > for SetItems < ' a , T > {
534
- /// Advance the iterator to the next node (in order). If there are no more nodes, return `None`.
535
517
#[ inline]
536
518
fn next ( & mut self ) -> Option < & ' a T > {
537
519
self . iter . next ( ) . map ( |( value, _) | value)
538
520
}
539
521
}
540
522
541
523
impl < ' a , T > Iterator < & ' a T > for RevSetItems < ' a , T > {
542
- /// Advance the iterator to the next node (in order). If there are no more nodes, return `None`.
543
524
#[ inline]
544
525
fn next ( & mut self ) -> Option < & ' a T > {
545
526
self . iter . next ( ) . map ( |( value, _) | value)
@@ -557,19 +538,11 @@ pub struct TreeSet<T> {
557
538
impl < T : Eq + TotalOrd > Eq for TreeSet < T > {
558
539
#[ inline]
559
540
fn eq ( & self , other : & TreeSet < T > ) -> bool { self . map == other. map }
560
- #[ inline]
561
- fn ne ( & self , other : & TreeSet < T > ) -> bool { self . map != other. map }
562
541
}
563
542
564
543
impl < T : Ord + TotalOrd > Ord for TreeSet < T > {
565
544
#[ inline]
566
545
fn lt ( & self , other : & TreeSet < T > ) -> bool { self . map < other. map }
567
- #[ inline]
568
- fn le ( & self , other : & TreeSet < T > ) -> bool { self . map <= other. map }
569
- #[ inline]
570
- fn ge ( & self , other : & TreeSet < T > ) -> bool { self . map >= other. map }
571
- #[ inline]
572
- fn gt ( & self , other : & TreeSet < T > ) -> bool { self . map > other. map }
573
546
}
574
547
575
548
impl < T : TotalOrd > Container for TreeSet < T > {
0 commit comments