mirror of
https://github.com/krahets/hello-algo.git
synced 2026-08-10 19:10:57 +00:00
Review Swift codes (#1150)
* feat(swift): review for chapter_computational_complexity * feat(swift): review for chapter_data_structure * feat(swift): review for chapter_array_and_linkedlist * feat(swift): review for chapter_stack_and_queue * feat(swift): review for chapter_hashing * feat(swift): review for chapter_tree * feat(swift): add codes for heap article * feat(swift): review for chapter_heap * feat(swift): review for chapter_graph * feat(swift): review for chapter_searching * feat(swift): review for chapter_sorting * feat(swift): review for chapter_divide_and_conquer * feat(swift): review for chapter_backtracking * feat(swift): review for chapter_dynamic_programming * feat(swift): review for chapter_greedy * feat(swift): review for utils * feat(swift): update ci tool * feat(swift): trailing closure * feat(swift): array init * feat(swift): map index
This commit is contained in:
@@ -30,7 +30,7 @@ class HashMapChaining {
|
||||
|
||||
/* 负载因子 */
|
||||
func loadFactor() -> Double {
|
||||
Double(size / capacity)
|
||||
Double(size) / Double(capacity)
|
||||
}
|
||||
|
||||
/* 查询操作 */
|
||||
@@ -76,9 +76,10 @@ class HashMapChaining {
|
||||
for (pairIndex, pair) in bucket.enumerated() {
|
||||
if pair.key == key {
|
||||
buckets[index].remove(at: pairIndex)
|
||||
size -= 1
|
||||
break
|
||||
}
|
||||
}
|
||||
size -= 1
|
||||
}
|
||||
|
||||
/* 扩容哈希表 */
|
||||
|
||||
Reference in New Issue
Block a user