mirror of
https://github.com/krahets/hello-algo.git
synced 2026-11-02 03:05:24 +08:00
* 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
33 lines
769 B
Swift
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 }
|
|
}
|
|
}
|