cpp-algo-cases/utils/vertex.hpp

43 lines
679 B
C++
Raw Normal View History

2024-02-21 09:31:34 +08:00
/**
* File: vertex.hpp
* Created Time: 2023-03-02
* Author: krahets (krahets@163.com)
*/
#pragma once // <20><>ֹͷ<D6B9>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD>ظ<EFBFBD><D8B8><EFBFBD><EFBFBD><EFBFBD>
#include <vector>
using namespace std;
/* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
struct Vertex
{
int val;
Vertex(int x) : val(x)
{
}
};
/* <20><><EFBFBD><EFBFBD>ֵ<EFBFBD>б<EFBFBD> vals <20><><EFBFBD><EFBFBD><EFBFBD>ض<EFBFBD><D8B6><EFBFBD><EFBFBD>б<EFBFBD> vets */
vector<Vertex *> valsToVets(vector<int> vals)
{
vector<Vertex *> vets;
for (int val : vals)
{
vets.push_back(new Vertex(val));
}
return vets;
}
/* <20><><EFBFBD><EFBFBD><EBB6A5><EFBFBD>б<EFBFBD> vets <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD>б<EFBFBD> vals */
vector<int> vetsToVals(vector<Vertex *> vets)
{
vector<int> vals;
for (Vertex *vet : vets)
{
vals.push_back(vet->val);
}
return vals;
}