mirror of
https://gitlab.com/mfocko/Codeforces.git
synced 2024-12-22 11:51:24 +01:00
chore(cpp): rework reading collections
Signed-off-by: Matej Focko <mfocko@redhat.com>
This commit is contained in:
parent
e928da17af
commit
35e432c481
1 changed files with 11 additions and 6 deletions
|
@ -131,17 +131,22 @@ decltype(auto) y_combinator(Fun &&fun) {
|
||||||
#pragma endregion /* functional */
|
#pragma endregion /* functional */
|
||||||
|
|
||||||
#pragma region input
|
#pragma region input
|
||||||
template <typename T>
|
template <typename Container>
|
||||||
std::vector<T> load_vector(std::size_t size) {
|
void collect(Container &c, std::size_t size) {
|
||||||
std::vector<T> result{};
|
auto it = std::inserter(c, c.begin());
|
||||||
|
|
||||||
for (auto i = 0u; i < size; ++i) {
|
for (auto i = 0u; i < size; ++i) {
|
||||||
T x;
|
typename Container::value_type x;
|
||||||
std::cin >> x;
|
std::cin >> x;
|
||||||
result.push_back(std::move(x));
|
it = std::move(x);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
template <typename Container>
|
||||||
|
Container collect(std::size_t size) {
|
||||||
|
Container c{};
|
||||||
|
collect(c, size);
|
||||||
|
return c;
|
||||||
}
|
}
|
||||||
#pragma endregion /* input */
|
#pragma endregion /* input */
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue