@@ -687,15 +687,7 @@ impl<K, V, S> OrderMap<K, V, S>
687687 ///
688688 /// Computes in **O(n)** time.
689689 pub fn clear ( & mut self ) {
690- self . core . entries . clear ( ) ;
691- self . clear_indices ( ) ;
692- }
693-
694- // clear self.core.indices to the same state as "no elements"
695- fn clear_indices ( & mut self ) {
696- for pos in self . core . indices . iter_mut ( ) {
697- * pos = Pos :: none ( ) ;
698- }
690+ self . core . clear ( ) ;
699691 }
700692
701693 /// Reserve capacity for `additional` more key-value pairs.
@@ -979,7 +971,7 @@ impl<K, V, S> OrderMap<K, V, S>
979971 /// Clears the `OrderMap`, returning all key-value pairs as a drain iterator.
980972 /// Keeps the allocated memory for reuse.
981973 pub fn drain ( & mut self , range : RangeFull ) -> Drain < K , V > {
982- self . clear_indices ( ) ;
974+ self . core . clear_indices ( ) ;
983975
984976 Drain {
985977 iter : self . core . entries . drain ( range) ,
@@ -1041,6 +1033,18 @@ impl<K, V> OrderMapCore<K, V> {
10411033 usable_capacity ( self . raw_capacity ( ) )
10421034 }
10431035
1036+ fn clear ( & mut self ) {
1037+ self . entries . clear ( ) ;
1038+ self . clear_indices ( ) ;
1039+ }
1040+
1041+ // clear self.indices to the same state as "no elements"
1042+ fn clear_indices ( & mut self ) {
1043+ for pos in self . indices . iter_mut ( ) {
1044+ * pos = Pos :: none ( ) ;
1045+ }
1046+ }
1047+
10441048 fn first_allocation ( & mut self ) {
10451049 debug_assert_eq ! ( self . len( ) , 0 ) ;
10461050 let raw_cap = 8usize ;
0 commit comments