2024-04-06 02:30:11 +08:00
|
|
|
/**
|
|
|
|
* File: Vertex.kt
|
|
|
|
* Created Time: 2024-01-25
|
|
|
|
* Author: curtishd (1023632660@qq.com)
|
|
|
|
*/
|
|
|
|
|
|
|
|
package utils
|
|
|
|
|
|
|
|
/* 頂點類別 */
|
2024-04-11 20:18:19 +08:00
|
|
|
class Vertex(val _val: Int) {
|
2024-04-06 02:30:11 +08:00
|
|
|
companion object {
|
|
|
|
/* 輸入值串列 vals ,返回頂點串列 vets */
|
|
|
|
fun valsToVets(vals: IntArray): Array<Vertex?> {
|
|
|
|
val vets = arrayOfNulls<Vertex>(vals.size)
|
|
|
|
for (i in vals.indices) {
|
|
|
|
vets[i] = Vertex(vals[i])
|
|
|
|
}
|
|
|
|
return vets
|
|
|
|
}
|
|
|
|
|
|
|
|
/* 輸入頂點串列 vets ,返回值串列 vals */
|
2024-04-11 20:18:19 +08:00
|
|
|
fun vetsToVals(vets: MutableList<Vertex?>): MutableList<Int> {
|
|
|
|
val vals = mutableListOf<Int>()
|
2024-04-06 02:30:11 +08:00
|
|
|
for (vet in vets) {
|
2024-04-11 20:18:19 +08:00
|
|
|
vals.add(vet!!._val)
|
2024-04-06 02:30:11 +08:00
|
|
|
}
|
|
|
|
return vals
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|