@@ -358,13 +358,13 @@ impl<K: Hash + Eq, V> HashMap<K, V> {
358358 pub fn with_capacity ( capacity : uint ) -> HashMap < K , V > {
359359 let mut r = rand:: task_rng ( ) ;
360360 let hasher = SipHasher :: new_with_keys ( r. gen ( ) , r. gen ( ) ) ;
361- HashMap :: with_capacity_and_hasher ( hasher , capacity )
361+ HashMap :: with_capacity_and_hasher ( capacity , hasher )
362362 }
363363}
364364
365365impl < K : Hash < S > + Eq , V , S , H : Hasher < S > > HashMap < K , V , H > {
366366 pub fn with_hasher ( hasher : H ) -> HashMap < K , V , H > {
367- HashMap :: with_capacity_and_hasher ( hasher , INITIAL_CAPACITY )
367+ HashMap :: with_capacity_and_hasher ( INITIAL_CAPACITY , hasher )
368368 }
369369
370370 /// Create an empty HashMap with space for at least `capacity`
@@ -374,7 +374,7 @@ impl<K: Hash<S> + Eq, V, S, H: Hasher<S>> HashMap<K, V, H> {
374374 /// is designed to allow HashMaps to be resistant to attacks that
375375 /// cause many collisions and very poor performance. Setting it
376376 /// manually using this function can expose a DoS attack vector.
377- pub fn with_capacity_and_hasher ( hasher : H , capacity : uint ) -> HashMap < K , V , H > {
377+ pub fn with_capacity_and_hasher ( capacity : uint , hasher : H ) -> HashMap < K , V , H > {
378378 let cap = max ( INITIAL_CAPACITY , capacity) ;
379379 HashMap {
380380 hasher : hasher,
@@ -587,7 +587,8 @@ impl<K: Hash<S> + Eq, V: Eq, S, H: Hasher<S>> Eq for HashMap<K, V, H> {
587587
588588impl < K : Hash < S > + Eq + Clone , V : Clone , S , H : Hasher < S > + Clone > Clone for HashMap < K , V , H > {
589589 fn clone ( & self ) -> HashMap < K , V , H > {
590- let mut new_map = HashMap :: with_capacity_and_hasher ( self . hasher . clone ( ) , self . len ( ) ) ;
590+ let mut new_map = HashMap :: with_capacity_and_hasher ( self . len ( ) ,
591+ self . hasher . clone ( ) ) ;
591592 for ( key, value) in self . iter ( ) {
592593 new_map. insert ( ( * key) . clone ( ) , ( * value) . clone ( ) ) ;
593594 }
@@ -714,7 +715,7 @@ impl<K> Iterator<K> for SetMoveItems<K> {
714715impl < K : Hash < S > + Eq , V , S , H : Hasher < S > + Default > FromIterator < ( K , V ) > for HashMap < K , V , H > {
715716 fn from_iterator < T : Iterator < ( K , V ) > > ( iter : & mut T ) -> HashMap < K , V , H > {
716717 let ( lower, _) = iter. size_hint ( ) ;
717- let mut map = HashMap :: with_capacity_and_hasher ( Default :: default ( ) , lower ) ;
718+ let mut map = HashMap :: with_capacity_and_hasher ( lower , Default :: default ( ) ) ;
718719 map. extend ( iter) ;
719720 map
720721 }
@@ -730,7 +731,7 @@ impl<K: Hash<S> + Eq, V, S, H: Hasher<S> + Default> Extendable<(K, V)> for HashM
730731
731732impl < K : Hash < S > + Eq , V , S , H : Hasher < S > + Default > Default for HashMap < K , V , H > {
732733 fn default ( ) -> HashMap < K , V , H > {
733- HashMap :: with_capacity_and_hasher ( Default :: default ( ) , INITIAL_CAPACITY )
734+ HashMap :: with_capacity_and_hasher ( INITIAL_CAPACITY , Default :: default ( ) )
734735 }
735736}
736737
@@ -802,7 +803,7 @@ impl<T: Hash<SipState> + Eq> HashSet<T, SipHasher> {
802803
803804impl < T : Hash < S > + Eq , S , H : Hasher < S > > HashSet < T , H > {
804805 pub fn with_hasher ( hasher : H ) -> HashSet < T , H > {
805- HashSet :: with_capacity_and_hasher ( hasher , INITIAL_CAPACITY )
806+ HashSet :: with_capacity_and_hasher ( INITIAL_CAPACITY , hasher )
806807 }
807808
808809 /// Create an empty HashSet with space for at least `capacity`
@@ -812,9 +813,9 @@ impl<T: Hash<S> + Eq, S, H: Hasher<S>> HashSet<T, H> {
812813 /// are designed to allow HashSets to be resistant to attacks that
813814 /// cause many collisions and very poor performance. Setting them
814815 /// manually using this function can expose a DoS attack vector.
815- pub fn with_capacity_and_hasher ( hasher : H , capacity : uint ) -> HashSet < T , H > {
816+ pub fn with_capacity_and_hasher ( capacity : uint , hasher : H ) -> HashSet < T , H > {
816817 HashSet {
817- map : HashMap :: with_capacity_and_hasher ( hasher , capacity )
818+ map : HashMap :: with_capacity_and_hasher ( capacity , hasher )
818819 }
819820 }
820821
@@ -902,7 +903,7 @@ impl<T: fmt::Show + Hash<S> + Eq, S, H: Hasher<S>> fmt::Show for HashSet<T, H> {
902903impl < T : Hash < S > + Eq , S , H : Hasher < S > + Default > FromIterator < T > for HashSet < T , H > {
903904 fn from_iterator < Iter : Iterator < T > > ( iter : & mut Iter ) -> HashSet < T , H > {
904905 let ( lower, _) = iter. size_hint ( ) ;
905- let mut set = HashSet :: with_capacity_and_hasher ( Default :: default ( ) , lower ) ;
906+ let mut set = HashSet :: with_capacity_and_hasher ( lower , Default :: default ( ) ) ;
906907 set. extend ( iter) ;
907908 set
908909 }
0 commit comments