mirror of
https://github.com/krahets/hello-algo.git
synced 2024-12-27 12:36:28 +08:00
30 lines
599 B
Dart
30 lines
599 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;
|
||
|
}
|
||
|
}
|