From 19ebaa5e3959ddc7358eab8ad8aa2c6bee49ebba Mon Sep 17 00:00:00 2001 From: myfreess Date: Tue, 14 Jan 2025 13:12:35 +0800 Subject: [PATCH] add argument 'capacity~' for @hashset.new --- hashset/hashset.mbt | 4 ++-- hashset/hashset.mbti | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/hashset/hashset.mbt b/hashset/hashset.mbt index 4181eec8c..883851358 100644 --- a/hashset/hashset.mbt +++ b/hashset/hashset.mbt @@ -18,10 +18,10 @@ let default_init_capacity = 8 ///| /// Create new hash set. -pub fn T::new[K]() -> T[K] { +pub fn T::new[K](capacity~ : Int = default_init_capacity) -> T[K] { { size: 0, - capacity: default_init_capacity, + capacity, growAt: calc_grow_threshold(default_init_capacity), entries: FixedArray::make(default_init_capacity, None), } diff --git a/hashset/hashset.mbti b/hashset/hashset.mbti index 95235d02c..75c3b6be6 100644 --- a/hashset/hashset.mbti +++ b/hashset/hashset.mbti @@ -20,7 +20,7 @@ impl T { intersection[K : Hash + Eq](Self[K], Self[K]) -> Self[K] is_empty[K](Self[K]) -> Bool iter[K](Self[K]) -> Iter[K] - new[K]() -> Self[K] + new[K](capacity~ : Int = ..) -> Self[K] of[K : Hash + Eq](FixedArray[K]) -> Self[K] remove[K : Hash + Eq](Self[K], K) -> Unit size[K](Self[K]) -> Int