mirror of
https://github.com/krahets/hello-algo.git
synced 2024-12-25 14:36:29 +08:00
4d9bbe72e1
* style(kotlin): Make code and comments consistent. * style(kotlin): convert comment location. * style(c): Add missing comment. * style(kotlin): Remove redundant semicolon, parenthesis and brace * style(kotlin): Put constants inside the function. * style(kotlin): fix unnecessary indentation. * style(swift): Add missing comment. * style(kotlin): Add missing comment. * style(kotlin): Remove redundant comment. * style(kotlin): Add missing comment. * Update linked_list.kt * style(csharp,js,ts): Add missing comment. * style(kotlin): Remove empty lines. * Update list.cs * Update list.js * Update list.ts * roll back to commit 1 * style(cs,js,ts): Add missing comment in docfile. * style(kotlin): Use normal element swapping instead of scope functions.
36 lines
No EOL
893 B
Kotlin
36 lines
No EOL
893 B
Kotlin
/**
|
|
* File: built_in_hash.kt
|
|
* Created Time: 2024-01-25
|
|
* Author: curtishd (1023632660@qq.com)
|
|
*/
|
|
|
|
package chapter_hashing
|
|
|
|
import utils.ListNode
|
|
|
|
/* Driver Code */
|
|
fun main() {
|
|
val num = 3
|
|
val hashNum = num.hashCode()
|
|
println("整数 $num 的哈希值为 $hashNum")
|
|
|
|
val bol = true
|
|
val hashBol = bol.hashCode()
|
|
println("布尔量 $bol 的哈希值为 $hashBol")
|
|
|
|
val dec = 3.14159
|
|
val hashDec = dec.hashCode()
|
|
println("小数 $dec 的哈希值为 $hashDec")
|
|
|
|
val str = "Hello 算法"
|
|
val hashStr = str.hashCode()
|
|
println("字符串 $str 的哈希值为 $hashStr")
|
|
|
|
val arr = arrayOf<Any>(12836, "小哈")
|
|
val hashTup = arr.contentHashCode()
|
|
println("数组 ${arr.contentToString()} 的哈希值为 $hashTup")
|
|
|
|
val obj = ListNode(0)
|
|
val hashObj = obj.hashCode()
|
|
println("节点对象 $obj 的哈希值为 $hashObj")
|
|
} |