Files
hello-algo/en/codes/javascript/modules/Vertex.js
Yudong Jin 14c314c08c Retranslate the complete English edition from Simplified Chinese (#2010)
* Retranslate the complete English edition from Simplified Chinese

* Polish three English explanations after reader-focused review
2026-10-31 03:35:51 +08:00

36 lines
723 B
JavaScript

/**
* File: Vertex.js
* Created Time: 2023-02-15
* Author: Zhuo Qinyue (1403450829@qq.com)
*/
/* Vertex class */
class Vertex {
val;
constructor(val) {
this.val = val;
}
/* Given the list of values vals, return the list of vertices vets */
static valsToVets(vals) {
const vets = [];
for (let i = 0; i < vals.length; i++) {
vets[i] = new Vertex(vals[i]);
}
return vets;
}
/* Given the list of vertices vets, return the list of values vals */
static vetsToVals(vets) {
const vals = [];
for (const vet of vets) {
vals.push(vet.val);
}
return vals;
}
}
module.exports = {
Vertex,
};