// Author: Juan Carlos De Abreu (jcabreur@gmail.com)
//
// This file provide some utilities functions related to std::vector.

#include "vector"

BEGIN_TEG_NAMESPACE();

// TODO: Make this function that work python style...
// Function to get the elements of the vector in a range.
template<class _T> std::vector<_T> subvector(
    const std::vector<_T>& param,
    const int& start = 0,
    const int& end = -1) {
  std::vector<_T> res;
  const int nParam = static_cast<int> (param.size());
  const int endPos = end == -1 ? nParam : end;
  for (int i = start; i < endPos; ++i) res.push_back(param[i]);
  return res;
}

// Function to join two vectors
template<class _T> std::vector<_T> join(
    const std::vector<_T>& v1, const std::vector<_T>& v2) {
  const int nElem1 = static_cast<int> (v1.size());
  const int nElem2 = static_cast<int> (v2.size());
  std::vector<_T> res(nElem1 + nElem2);
  for (int i = 0; i < nElem1; ++i) res[i] = v1[i];
  for (int i = 0; i < nElem2; ++i) res[nElem1 + i] = v2[i];
  return res;
}

END_TEG_NAMESPACE();
