@@ -16,15 +16,13 @@ use collections::{Collection, Mutable, Set, MutableSet, Map, MutableMap};
16
16
use default:: Default ;
17
17
use fmt:: Show ;
18
18
use fmt;
19
- use hash:: { Hash , Hasher , sip } ;
19
+ use hash:: { Hash , Hasher , RandomSipHasher } ;
20
20
use iter:: { Iterator , FilterMap , Chain , Repeat , Zip , Extendable } ;
21
21
use iter:: { range, range_inclusive, FromIterator } ;
22
22
use iter;
23
23
use mem:: replace;
24
24
use num;
25
25
use option:: { Some , None , Option } ;
26
- use rand:: Rng ;
27
- use rand;
28
26
use result:: { Ok , Err } ;
29
27
30
28
mod table {
@@ -733,7 +731,7 @@ impl DefaultResizePolicy {
733
731
/// }
734
732
/// ```
735
733
#[ deriving( Clone ) ]
736
- pub struct HashMap < K , V , H = sip :: SipHasher > {
734
+ pub struct HashMap < K , V , H = RandomSipHasher > {
737
735
// All hashes are keyed on these values, to prevent hash collision attacks.
738
736
hasher : H ,
739
737
@@ -1033,18 +1031,15 @@ impl<K: Eq + Hash<S>, V, S, H: Hasher<S>> MutableMap<K, V> for HashMap<K, V, H>
1033
1031
1034
1032
}
1035
1033
1036
- impl < K : Hash + Eq , V > HashMap < K , V , sip :: SipHasher > {
1034
+ impl < K : Hash + Eq , V > HashMap < K , V , RandomSipHasher > {
1037
1035
/// Create an empty HashMap.
1038
- pub fn new ( ) -> HashMap < K , V , sip :: SipHasher > {
1036
+ pub fn new ( ) -> HashMap < K , V , RandomSipHasher > {
1039
1037
HashMap :: with_capacity ( INITIAL_CAPACITY )
1040
1038
}
1041
1039
1042
1040
/// Creates an empty hash map with the given initial capacity.
1043
- pub fn with_capacity ( capacity : uint ) -> HashMap < K , V , sip:: SipHasher > {
1044
- let mut r = rand:: task_rng ( ) ;
1045
- let r0 = r. gen ( ) ;
1046
- let r1 = r. gen ( ) ;
1047
- let hasher = sip:: SipHasher :: new_with_keys ( r0, r1) ;
1041
+ pub fn with_capacity ( capacity : uint ) -> HashMap < K , V , RandomSipHasher > {
1042
+ let hasher = RandomSipHasher :: new ( ) ;
1048
1043
HashMap :: with_capacity_and_hasher ( capacity, hasher)
1049
1044
}
1050
1045
}
@@ -1489,7 +1484,7 @@ pub type SetMoveItems<K> =
1489
1484
/// HashMap where the value is (). As with the `HashMap` type, a `HashSet`
1490
1485
/// requires that the elements implement the `Eq` and `Hash` traits.
1491
1486
#[ deriving( Clone ) ]
1492
- pub struct HashSet < T , H = sip :: SipHasher > {
1487
+ pub struct HashSet < T , H = RandomSipHasher > {
1493
1488
map : HashMap < T , ( ) , H >
1494
1489
}
1495
1490
@@ -1529,15 +1524,15 @@ impl<T: Eq + Hash<S>, S, H: Hasher<S>> MutableSet<T> for HashSet<T, H> {
1529
1524
fn remove ( & mut self , value : & T ) -> bool { self . map . remove ( value) }
1530
1525
}
1531
1526
1532
- impl < T : Hash + Eq > HashSet < T , sip :: SipHasher > {
1527
+ impl < T : Hash + Eq > HashSet < T , RandomSipHasher > {
1533
1528
/// Create an empty HashSet
1534
- pub fn new ( ) -> HashSet < T , sip :: SipHasher > {
1529
+ pub fn new ( ) -> HashSet < T , RandomSipHasher > {
1535
1530
HashSet :: with_capacity ( INITIAL_CAPACITY )
1536
1531
}
1537
1532
1538
1533
/// Create an empty HashSet with space for at least `n` elements in
1539
1534
/// the hash table.
1540
- pub fn with_capacity ( capacity : uint ) -> HashSet < T , sip :: SipHasher > {
1535
+ pub fn with_capacity ( capacity : uint ) -> HashSet < T , RandomSipHasher > {
1541
1536
HashSet { map : HashMap :: with_capacity ( capacity) }
1542
1537
}
1543
1538
}
0 commit comments