mirror of
https://github.com/krahets/hello-algo.git
synced 2026-11-05 23:18:41 +08:00
* Retranslate the complete Japanese online edition from Chinese * Fit Japanese homepage labels and localize heading permalinks * Point Japanese contribution instructions to the Japanese preview * Replace locale conditionals with multilingual UI tables
38 lines
1.0 KiB
Swift
38 lines
1.0 KiB
Swift
/**
|
|
* File: built_in_hash.swift
|
|
* Created Time: 2023-07-01
|
|
* Author: nuomi1 (nuomi1@qq.com)
|
|
*/
|
|
|
|
import utils
|
|
|
|
@main
|
|
enum BuiltInHash {
|
|
/* 実行用コード */
|
|
static func main() {
|
|
let num = 3
|
|
let hashNum = num.hashValue
|
|
print("整数 \(num) のハッシュ値は \(hashNum)")
|
|
|
|
let bol = true
|
|
let hashBol = bol.hashValue
|
|
print("真偽値 \(bol) のハッシュ値は \(hashBol)")
|
|
|
|
let dec = 3.14159
|
|
let hashDec = dec.hashValue
|
|
print("小数 \(dec) のハッシュ値は \(hashDec)")
|
|
|
|
let str = "Hello 算法"
|
|
let hashStr = str.hashValue
|
|
print("文字列 \(str) のハッシュ値は \(hashStr)")
|
|
|
|
let arr = [AnyHashable(12836), AnyHashable("小哈")]
|
|
let hashTup = arr.hashValue
|
|
print("配列 \(arr) のハッシュ値は \(hashTup)")
|
|
|
|
let obj = ListNode(x: 0)
|
|
let hashObj = obj.hashValue
|
|
print("ノードオブジェクト \(obj) のハッシュ値は \(hashObj)")
|
|
}
|
|
}
|