kyopro-lib

This documentation is automatically generated by online-judge-tools/verification-helper

View on GitHub

:warning: Unzip function
(Mylib/Misc/unzip.cpp)

Operations

Requirements

Notes

Problems

References

Code

#pragma once
#include <initializer_list>
#include <tuple>
#include <utility>
#include <vector>

namespace haar_lib {
  template <typename T, typename U, size_t... I>
  void unzip_helper(T &ret, U &a, std::index_sequence<I...>) {
    (void) std::initializer_list<int>{(void(std::get<I>(ret).push_back(std::get<I>(a))), 0)...};
  }

  template <typename... Args>
  auto unzip(std::vector<std::tuple<Args...>> a) {
    const int N = a.size();
    std::tuple<std::vector<Args>...> ret;

    for (int i = 0; i < N; ++i) {
      unzip_helper(ret, a[i], std::make_index_sequence<sizeof...(Args)>());
    }

    return ret;
  }
}  // namespace haar_lib
#line 2 "Mylib/Misc/unzip.cpp"
#include <initializer_list>
#include <tuple>
#include <utility>
#include <vector>

namespace haar_lib {
  template <typename T, typename U, size_t... I>
  void unzip_helper(T &ret, U &a, std::index_sequence<I...>) {
    (void) std::initializer_list<int>{(void(std::get<I>(ret).push_back(std::get<I>(a))), 0)...};
  }

  template <typename... Args>
  auto unzip(std::vector<std::tuple<Args...>> a) {
    const int N = a.size();
    std::tuple<std::vector<Args>...> ret;

    for (int i = 0; i < N; ++i) {
      unzip_helper(ret, a[i], std::make_index_sequence<sizeof...(Args)>());
    }

    return ret;
  }
}  // namespace haar_lib
Back to top page