mirror of
https://github.com/krahets/hello-algo.git
synced 2025-12-09 23:40:04 +08:00
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:
@@ -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")
|
||||
}
|
||||
|
||||
/* 哈希函数 */
|
||||
|
||||
Reference in New Issue
Block a user