@@ -1033,11 +1033,13 @@ impl<K: Eq + Hash<S>, V, S, H: Hasher<S>> MutableMap<K, V> for HashMap<K, V, H>
1033
1033
1034
1034
impl < K : Hash + Eq , V > HashMap < K , V , RandomSipHasher > {
1035
1035
/// Create an empty HashMap.
1036
+ #[ inline]
1036
1037
pub fn new ( ) -> HashMap < K , V , RandomSipHasher > {
1037
1038
HashMap :: with_capacity ( INITIAL_CAPACITY )
1038
1039
}
1039
1040
1040
1041
/// Creates an empty hash map with the given initial capacity.
1042
+ #[ inline]
1041
1043
pub fn with_capacity ( capacity : uint ) -> HashMap < K , V , RandomSipHasher > {
1042
1044
let hasher = RandomSipHasher :: new ( ) ;
1043
1045
HashMap :: with_capacity_and_hasher ( capacity, hasher)
@@ -1048,6 +1050,7 @@ impl<K: Eq + Hash<S>, V, S, H: Hasher<S>> HashMap<K, V, H> {
1048
1050
/// Creates an empty hashmap which will use the given hasher to hash keys.
1049
1051
///
1050
1052
/// The creates map has the default initial capacity.
1053
+ #[ inline]
1051
1054
pub fn with_hasher ( hasher : H ) -> HashMap < K , V , H > {
1052
1055
HashMap :: with_capacity_and_hasher ( INITIAL_CAPACITY , hasher)
1053
1056
}
@@ -1059,6 +1062,7 @@ impl<K: Eq + Hash<S>, V, S, H: Hasher<S>> HashMap<K, V, H> {
1059
1062
/// is designed to allow HashMaps to be resistant to attacks that
1060
1063
/// cause many collisions and very poor performance. Setting it
1061
1064
/// manually using this function can expose a DoS attack vector.
1065
+ #[ inline]
1062
1066
pub fn with_capacity_and_hasher ( capacity : uint , hasher : H ) -> HashMap < K , V , H > {
1063
1067
let cap = num:: next_power_of_two ( max ( INITIAL_CAPACITY , capacity) ) ;
1064
1068
HashMap {
@@ -1526,12 +1530,14 @@ impl<T: Eq + Hash<S>, S, H: Hasher<S>> MutableSet<T> for HashSet<T, H> {
1526
1530
1527
1531
impl < T : Hash + Eq > HashSet < T , RandomSipHasher > {
1528
1532
/// Create an empty HashSet
1533
+ #[ inline]
1529
1534
pub fn new ( ) -> HashSet < T , RandomSipHasher > {
1530
1535
HashSet :: with_capacity ( INITIAL_CAPACITY )
1531
1536
}
1532
1537
1533
1538
/// Create an empty HashSet with space for at least `n` elements in
1534
1539
/// the hash table.
1540
+ #[ inline]
1535
1541
pub fn with_capacity ( capacity : uint ) -> HashSet < T , RandomSipHasher > {
1536
1542
HashSet { map : HashMap :: with_capacity ( capacity) }
1537
1543
}
@@ -1542,6 +1548,7 @@ impl<T: Eq + Hash<S>, S, H: Hasher<S>> HashSet<T, H> {
1542
1548
/// keys.
1543
1549
///
1544
1550
/// The hash set is also created with the default initial capacity.
1551
+ #[ inline]
1545
1552
pub fn with_hasher ( hasher : H ) -> HashSet < T , H > {
1546
1553
HashSet :: with_capacity_and_hasher ( INITIAL_CAPACITY , hasher)
1547
1554
}
@@ -1553,6 +1560,7 @@ impl<T: Eq + Hash<S>, S, H: Hasher<S>> HashSet<T, H> {
1553
1560
/// is designed to allow `HashSet`s to be resistant to attacks that
1554
1561
/// cause many collisions and very poor performance. Setting it
1555
1562
/// manually using this function can expose a DoS attack vector.
1563
+ #[ inline]
1556
1564
pub fn with_capacity_and_hasher ( capacity : uint , hasher : H ) -> HashSet < T , H > {
1557
1565
HashSet { map : HashMap :: with_capacity_and_hasher ( capacity, hasher) }
1558
1566
}
0 commit comments