@@ -393,10 +393,16 @@ pub mod linear {
393
393
}
394
394
}
395
395
396
- pub impl<K:Hash + IterBytes + Eq,V> LinearMap<K, V> {
396
+ pub impl<K: Hash + IterBytes + Eq, V> LinearMap<K, V> {
397
397
/// Create an empty LinearMap
398
398
fn new() -> LinearMap<K, V> {
399
- linear_map_with_capacity(INITIAL_CAPACITY)
399
+ LinearMap::with_capacity(INITIAL_CAPACITY)
400
+ }
401
+
402
+ /// Create an empty LinearMap with space for at least `n` elements in
403
+ /// the hash table.
404
+ fn with_capacity(capacity: uint) -> LinearMap<K, V> {
405
+ linear_map_with_capacity(capacity)
400
406
}
401
407
402
408
/// Reserve space for at least `n` elements in the hash table.
@@ -652,7 +658,15 @@ pub mod linear {
652
658
653
659
pub impl < T : Hash + IterBytes + Eq > LinearSet < T > {
654
660
/// Create an empty LinearSet
655
- fn new ( ) -> LinearSet < T > { LinearSet { map : LinearMap :: new ( ) } }
661
+ fn new ( ) -> LinearSet < T > {
662
+ LinearSet :: with_capacity ( INITIAL_CAPACITY )
663
+ }
664
+
665
+ /// Create an empty LinearSet with space for at least `n` elements in
666
+ /// the hash table.
667
+ fn with_capacity ( capacity : uint ) -> LinearSet < T > {
668
+ LinearSet { map : LinearMap :: with_capacity ( capacity) }
669
+ }
656
670
657
671
/// Reserve space for at least `n` elements in the hash table.
658
672
fn reserve_at_least ( & mut self , n : uint ) {
0 commit comments