-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathto_vector.hpp
More file actions
46 lines (38 loc) · 803 Bytes
/
to_vector.hpp
File metadata and controls
46 lines (38 loc) · 803 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
// algocpp/type/to_vector.hpp
//
// This file is part of algocpp and is copyrighted by algocpp.
// If used, it must comply with the MIT License.
#ifndef ALGOCPP_TYPE_TO_VECTOR
#define ALGOCPP_TYPE_TO_VECTOR
#include <vector>
#include <array>
#include <list>
namespace algocpp
{
namespace type
{
template <typename T, std::size_t n>
inline std::vector<T> to_vector(std::array<T, n> v)
{
std::vector<T> result(v.size());
for (unsigned long long i = 0; i < v.size(); i++)
{
result[i] = v[i];
}
return result;
}
template <typename T>
inline std::vector<T> to_vector(std::list<T> v)
{
std::vector<T> result(v.size());
unsigned long long i = 0;
for (T x : v)
{
result[i] = x;
i++;
}
return result;
}
}
}
#endif // ALGOCPP_TYPE_TO_VECTOR