mirror of
https://github.com/krahets/hello-algo.git
synced 2024-12-27 12:06:29 +08:00
30 lines
596 B
Dart
30 lines
596 B
Dart
|
/**
|
||
|
* File: Vertex.dart
|
||
|
* Created Time: 2023-05-15
|
||
|
* Author: liuyuxin (gvenusleo@gmail.com)
|
||
|
*/
|
||
|
|
||
|
/* 顶点类 */
|
||
|
class Vertex {
|
||
|
int val;
|
||
|
Vertex(this.val);
|
||
|
|
||
|
/* 输入值列表 vals ,返回顶点列表 vets */
|
||
|
static List<Vertex> valsToVets(List<int> vals) {
|
||
|
List<Vertex> vets = [];
|
||
|
for (int i in vals) {
|
||
|
vets.add(Vertex(i));
|
||
|
}
|
||
|
return vets;
|
||
|
}
|
||
|
|
||
|
/* 输入顶点列表 vets ,返回值列表 vals */
|
||
|
static List<int> vetsToVals(List<Vertex> vets) {
|
||
|
List<int> vals = [];
|
||
|
for (Vertex vet in vets) {
|
||
|
vals.add(vet.val);
|
||
|
}
|
||
|
return vals;
|
||
|
}
|
||
|
}
|