Improve readability of Kotlin code (#1236)

* style(kotlin): Improve kotlin codes readability.

* remove redundant quotes.

* style(kotlin): improve codes readability.
This commit is contained in:
curtishd
2024-04-08 16:09:34 +08:00
committed by GitHub
parent ba1df4a3e8
commit 3fe8f67ba9
12 changed files with 46 additions and 51 deletions

View File

@@ -8,16 +8,21 @@ package chapter_hashing
/* 开放寻址哈希表 */
class HashMapOpenAddressing {
private var size: Int = 0 // 键值对数量
private var capacity = 4 // 哈希表容量
private val loadThres: Double = 2.0 / 3.0 // 触发扩容的负载因子阈值
private val extendRatio = 2 // 扩容倍数
private var buckets: Array<Pair?> // 桶数组
private val TOMBSTONE = Pair(-1, "-1") // 删除标记
private var size: Int // 键值对数量
private var capacity: Int // 哈希表容量
private val loadThres: Double // 触发扩容的负载因子阈值
private val extendRatio: Int // 扩容倍数
private var buckets: Array<Pair?> // 桶数组
private val TOMBSTONE: Pair // 删除标记
/* 构造方法 */
init {
size = 0
capacity = 4
loadThres = 2.0 / 3.0
extendRatio = 2
buckets = arrayOfNulls(capacity)
TOMBSTONE = Pair(-1, "-1")
}
/* 哈希函数 */