Files
hello-algo/ja/codes/javascript/modules/Vertex.js
T
Yudong Jin 7257641e0e Retranslate the complete Japanese online edition from Chinese (#2008)
* Retranslate the complete Japanese online edition from Chinese

* Fit Japanese homepage labels and localize heading permalinks

* Point Japanese contribution instructions to the Japanese preview

* Replace locale conditionals with multilingual UI tables
2026-10-30 02:12:26 +08:00

36 lines
738 B
JavaScript

/**
* File: Vertex.js
* Created Time: 2023-02-15
* Author: Zhuo Qinyue ([email protected])
*/
/* 頂点クラス */
class Vertex {
val;
constructor(val) {
this.val = val;
}
/* 値のリスト vals を入力し、頂点のリスト vets を返す */
static valsToVets(vals) {
const vets = [];
for (let i = 0; i < vals.length; i++) {
vets[i] = new Vertex(vals[i]);
}
return vets;
}
/* 頂点のリスト vets を入力し、値のリスト vals を返す */
static vetsToVals(vets) {
const vals = [];
for (const vet of vets) {
vals.push(vet.val);
}
return vals;
}
}
module.exports = {
Vertex,
};