mirror of
https://github.com/krahets/hello-algo.git
synced 2026-06-18 09:47:56 +08:00
* Add Russian docs site baseline * Add Russian localized codebase * Polish Russian code wording * Update ru code translation. * Update code translation and chapter covers. * Fix pythontutor extraction. * Add README and landing page. * placeholder of profiles * Use figures of English version * Remove chapter paperbook
33 lines
926 B
Swift
33 lines
926 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 }
|
||
}
|
||
}
|