File tree 1 file changed +11
-0
lines changed 1 file changed +11
-0
lines changed Original file line number Diff line number Diff line change @@ -687,6 +687,17 @@ impl<T:Hash + Eq> HashSet<T> {
687
687
HashSet { map : HashMap :: with_capacity ( capacity) }
688
688
}
689
689
690
+ /// Create an empty HashSet with space for at least `capacity`
691
+ /// elements in the hash table, using `k0` and `k1` as the keys.
692
+ ///
693
+ /// Warning: `k0` and `k1` are normally randomly generated, and
694
+ /// are designed to allow HashSets to be resistant to attacks that
695
+ /// cause many collisions and very poor performance. Setting them
696
+ /// manually using this function can expose a DoS attack vector.
697
+ pub fn with_capacity_and_keys ( k0 : u64 , k1 : u64 , capacity : uint ) -> HashSet < T > {
698
+ HashSet { map : HashMap :: with_capacity_and_keys ( k0, k1, capacity) }
699
+ }
700
+
690
701
/// Reserve space for at least `n` elements in the hash table.
691
702
pub fn reserve_at_least ( & mut self , n : uint ) {
692
703
self . map . reserve_at_least ( n)
You can’t perform that action at this time.
0 commit comments