hello-algo/codes/java/utils/Vertex.java
Yudong Jin a005c6ebd3
Some improvements (#1073)
* Update avatar's link in the landing page

* Bug fixes

* Move assets folder from overrides to docs

* Reduce figures' corner radius

* Update copyright

* Update header image

* Krahets -> krahets

* Update the landing page
2024-02-07 22:21:18 +08:00

36 lines
813 B
Java

/**
* File: Vertex.java
* Created Time: 2023-02-15
* Author: krahets (krahets@163.com)
*/
package utils;
import java.util.*;
/* 顶点类 */
public class Vertex {
public int val;
public Vertex(int val) {
this.val = val;
}
/* 输入值列表 vals ,返回顶点列表 vets */
public static Vertex[] valsToVets(int[] vals) {
Vertex[] vets = new Vertex[vals.length];
for (int i = 0; i < vals.length; i++) {
vets[i] = new Vertex(vals[i]);
}
return vets;
}
/* 输入顶点列表 vets ,返回值列表 vals */
public static List<Integer> vetsToVals(List<Vertex> vets) {
List<Integer> vals = new ArrayList<>();
for (Vertex vet : vets) {
vals.add(vet.val);
}
return vals;
}
}