Skip to content

Commit 4c73d79

Browse files
chengmiaomiao.123miamia0
chengmiaomiao.123
authored andcommitted
optimize with capacity
1 parent 1caa704 commit 4c73d79

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

Diff for: src/hnsw/hnsw_const.rs

+11
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,17 @@ where
6464
params,
6565
}
6666
}
67+
68+
pub fn new_with_capacity(metric: Met, params: Params, capacity: usize) -> Self {
69+
Self {
70+
metric,
71+
zero: Vec::with_capacity(capacity),
72+
features: Vec::with_capacity(capacity),
73+
layers: vec![],
74+
prng: R::from_seed(R::Seed::default()),
75+
params,
76+
}
77+
}
6778
}
6879

6980
impl<Met, T, R, const M: usize, const M0: usize> Knn for Hnsw<Met, T, R, M, M0>

0 commit comments

Comments
 (0)