54
54
55
55
use std:: cmp:: max;
56
56
use std:: fmt;
57
- use std:: hash_old :: Hash ;
57
+ use std:: hash :: { Hash , Hasher , sip } ;
58
58
use std:: iter:: { FilterMap , Chain , Repeat , Zip } ;
59
59
use std:: iter;
60
60
use std:: mem:: replace;
@@ -79,10 +79,7 @@ struct Bucket<K,V> {
79
79
/// hash function for internal state. This means that the order of all hash maps
80
80
/// is randomized by keying each hash map randomly on creation.
81
81
///
82
- /// It is required that the keys implement the `Eq` and `Hash` traits, although
83
- /// this can frequently be achieved by just implementing the `Eq` and
84
- /// `IterBytes` traits as `Hash` is automatically implemented for types that
85
- /// implement `IterBytes`.
82
+ /// It is required that the keys implement the `Eq` and `Hash` traits.
86
83
pub struct HashMap < K , V > {
87
84
priv k0: u64 ,
88
85
priv k1: u64 ,
@@ -131,14 +128,14 @@ impl<K:Hash + Eq,V> HashMap<K, V> {
131
128
132
129
#[ inline]
133
130
fn bucket_for_key ( & self , k : & K ) -> SearchResult {
134
- let hash = k . hash_keyed ( self . k0 , self . k1 ) as uint ;
131
+ let hash = sip :: hash_with_keys ( self . k0 , self . k1 , k ) as uint ;
135
132
self . bucket_for_key_with_hash ( hash, k)
136
133
}
137
134
138
135
#[ inline]
139
136
fn bucket_for_key_equiv < Q : Hash + Equiv < K > > ( & self , k : & Q )
140
137
-> SearchResult {
141
- let hash = k . hash_keyed ( self . k0 , self . k1 ) as uint ;
138
+ let hash = sip :: hash_with_keys ( self . k0 , self . k1 , k ) as uint ;
142
139
self . bucket_for_key_with_hash_equiv ( hash, k)
143
140
}
144
141
@@ -339,14 +336,14 @@ impl<K:Hash + Eq,V> MutableMap<K, V> for HashMap<K, V> {
339
336
self . expand ( ) ;
340
337
}
341
338
342
- let hash = k . hash_keyed ( self . k0 , self . k1 ) as uint ;
339
+ let hash = sip :: hash_with_keys ( self . k0 , self . k1 , & k ) as uint ;
343
340
self . insert_internal ( hash, k, v)
344
341
}
345
342
346
343
/// Removes a key from the map, returning the value at the key if the key
347
344
/// was previously in the map.
348
345
fn pop ( & mut self , k : & K ) -> Option < V > {
349
- let hash = k . hash_keyed ( self . k0 , self . k1 ) as uint ;
346
+ let hash = sip :: hash_with_keys ( self . k0 , self . k1 , k ) as uint ;
350
347
self . pop_internal ( hash, k)
351
348
}
352
349
}
@@ -446,7 +443,7 @@ impl<K: Hash + Eq, V> HashMap<K, V> {
446
443
self . expand ( ) ;
447
444
}
448
445
449
- let hash = k . hash_keyed ( self . k0 , self . k1 ) as uint ;
446
+ let hash = sip :: hash_with_keys ( self . k0 , self . k1 , & k ) as uint ;
450
447
let idx = match self . bucket_for_key_with_hash ( hash, & k) {
451
448
TableFull => fail ! ( "Internal logic error" ) ,
452
449
FoundEntry ( idx) => { found ( & k, self . mut_value_for_bucket ( idx) , a) ; idx }
@@ -925,7 +922,7 @@ pub type SetAlgebraItems<'a, T> =
925
922
926
923
impl <
927
924
E : Encoder ,
928
- K : Encodable < E > + Hash + IterBytes + Eq ,
925
+ K : Encodable < E > + Hash + Eq ,
929
926
V : Encodable < E >
930
927
> Encodable < E > for HashMap < K , V > {
931
928
fn encode ( & self , e : & mut E ) {
@@ -942,7 +939,7 @@ impl<
942
939
943
940
impl <
944
941
D : Decoder ,
945
- K : Decodable < D > + Hash + IterBytes + Eq ,
942
+ K : Decodable < D > + Hash + Eq ,
946
943
V : Decodable < D >
947
944
> Decodable < D > for HashMap < K , V > {
948
945
fn decode ( d : & mut D ) -> HashMap < K , V > {
@@ -960,7 +957,7 @@ impl<
960
957
961
958
impl <
962
959
S : Encoder ,
963
- T : Encodable < S > + Hash + IterBytes + Eq
960
+ T : Encodable < S > + Hash + Eq
964
961
> Encodable < S > for HashSet < T > {
965
962
fn encode ( & self , s : & mut S ) {
966
963
s. emit_seq ( self . len ( ) , |s| {
@@ -975,7 +972,7 @@ impl<
975
972
976
973
impl <
977
974
D : Decoder ,
978
- T : Decodable < D > + Hash + IterBytes + Eq
975
+ T : Decodable < D > + Hash + Eq
979
976
> Decodable < D > for HashSet < T > {
980
977
fn decode ( d : & mut D ) -> HashSet < T > {
981
978
d. read_seq ( |d, len| {
0 commit comments