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.
hello-algo/codes/dart/utils/vertex.dart

30 lines
596 B

/**
* 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;
}
}