Files
hello-algo/ja/codes/swift/utils/Vertex.swift
Yudong Jin 7257641e0e Retranslate the complete Japanese online edition from Chinese (#2008)
* 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
2026-10-30 02:12:26 +08:00

33 lines
774 B
Swift

/**
* File: Vertex.swift
* Created Time: 2023-02-19
* Author: nuomi1 (nuomi1@qq.com)
*/
/* 頂点クラス */
public class Vertex: Hashable {
public var val: Int
public init(val: Int) {
self.val = val
}
public static func == (lhs: Vertex, rhs: Vertex) -> Bool {
lhs.val == rhs.val
}
public func hash(into hasher: inout Hasher) {
hasher.combine(val)
}
/* 値のリスト vals を入力し、頂点のリスト vets を返す */
public static func valsToVets(vals: [Int]) -> [Vertex] {
vals.map { Vertex(val: $0) }
}
/* 頂点のリスト vets を入力し、値のリスト vals を返す */
public static func vetsToVals(vets: [Vertex]) -> [Int] {
vets.map { $0.val }
}
}