Files
hello-algo/ko/codes/swift/utils/Vertex.swift
T
Yudong Jin 2f561d3d51 feat(ko): add the Korean online edition (#2006)
* feat(ko): add the complete Korean online edition

* Use UTF-8 for Python CI output on Windows

* Remove print-book promotion from the Korean site

* fix(ko): preserve emphasis before Korean particles
2026-10-29 03:46:43 +08:00

33 lines
769 B
Swift

/**
* File: Vertex.swift
* Created Time: 2023-02-19
* Author: nuomi1 ([email protected])
*/
/* 정점 클래스 */
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 }
}
}