mirror of
https://github.com/krahets/hello-algo.git
synced 2024-12-26 15:06:29 +08:00
f62256bee1
* Modify method name to PascalCase(array and linked list) * Modify method name to PascalCase(backtracking) * Modify method name to PascalCase(computational complexity) * Modify method name to PascalCase(divide and conquer) * Modify method name to PascalCase(dynamic programming) * Modify method name to PascalCase(graph) * Modify method name to PascalCase(greedy) * Modify method name to PascalCase(hashing) * Modify method name to PascalCase(heap) * Modify method name to PascalCase(searching) * Modify method name to PascalCase(sorting) * Modify method name to PascalCase(stack and queue) * Modify method name to PascalCase(tree) * local check
33 lines
822 B
C#
33 lines
822 B
C#
/**
|
|
* File: Vertex.cs
|
|
* Created Time: 2023-02-06
|
|
* Author: zjkung1123 (zjkung1123@gmail.com), krahets (krahets@163.com)
|
|
*/
|
|
|
|
namespace hello_algo.utils;
|
|
|
|
/* 顶点类 */
|
|
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<int> VetsToVals(List<Vertex> vets) {
|
|
List<int> vals = new();
|
|
foreach (Vertex vet in vets) {
|
|
vals.Add(vet.val);
|
|
}
|
|
return vals;
|
|
}
|
|
}
|