mirror of
https://github.com/krahets/hello-algo.git
synced 2026-11-26 05:33:40 +08:00
* Retranslate the complete English edition from Simplified Chinese * Polish three English explanations after reader-focused review
30 lines
631 B
Dart
30 lines
631 B
Dart
/**
|
|
* File: Vertex.dart
|
|
* Created Time: 2023-05-15
|
|
* Author: liuyuxin (gvenusleo@gmail.com)
|
|
*/
|
|
|
|
/* Vertex class */
|
|
class Vertex {
|
|
int val;
|
|
Vertex(this.val);
|
|
|
|
/* Given the list of values vals, return the list of vertices vets */
|
|
static List<Vertex> valsToVets(List<int> vals) {
|
|
List<Vertex> vets = [];
|
|
for (int i in vals) {
|
|
vets.add(Vertex(i));
|
|
}
|
|
return vets;
|
|
}
|
|
|
|
/* Given the list of vertices vets, return the list of values vals */
|
|
static List<int> vetsToVals(List<Vertex> vets) {
|
|
List<int> vals = [];
|
|
for (Vertex vet in vets) {
|
|
vals.add(vet.val);
|
|
}
|
|
return vals;
|
|
}
|
|
}
|