You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.
/* *
* F i l e : V e r t e x . s w i f t
* C r e a t e d T i m e : 2 0 2 3 - 0 2 - 1 9
* A u t h o r : n u o m i 1 ( n u o m i 1 @ q q . c o m )
*/
/* 顶 点 类 */
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 )
}
/* 输 入 值 列 表 v a l s , 返 回 顶 点 列 表 v e t s */
public static func valsToVets ( vals : [ Int ] ) -> [ Vertex ] {
var vets : [ Vertex ] = [ ]
for val in vals {
vets . append ( Vertex ( val : val ) )
}
return vets
}
/* 输 入 顶 点 列 表 v e t s , 返 回 值 列 表 v a l s */
public static func vetsToVals ( vets : [ Vertex ] ) -> [ Int ] {
var vals : [ Int ] = [ ]
for vet in vets {
vals . append ( vet . val )
}
return vals
}
}