2024-03-25 19:15:40 +08:00
|
|
|
/**
|
|
|
|
* File: Vertex.kt
|
|
|
|
* Created Time: 2024-01-25
|
|
|
|
* Author: curtishd (1023632660@qq.com)
|
|
|
|
*/
|
|
|
|
|
|
|
|
package utils
|
|
|
|
|
|
|
|
/* 顶点类 */
|
2024-04-10 18:09:43 +08:00
|
|
|
class Vertex(val _val: Int) {
|
2024-03-25 19:15:40 +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-09 16:26:58 +08:00
|
|
|
fun vetsToVals(vets: MutableList<Vertex?>): MutableList<Int> {
|
|
|
|
val vals = mutableListOf<Int>()
|
2024-03-25 19:15:40 +08:00
|
|
|
for (vet in vets) {
|
2024-04-10 18:09:43 +08:00
|
|
|
vals.add(vet!!._val)
|
2024-03-25 19:15:40 +08:00
|
|
|
}
|
|
|
|
return vals
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|