// Copyright 2018 Google LLC. All Rights Reserved.
/*
  Copyright (C) 2008 Steven L. Scott

  This library is free software; you can redistribute it and/or
  modify it under the terms of the GNU Lesser General Public
  License as published by the Free Software Foundation; either
  version 2.1 of the License, or (at your option) any later version.

  This library is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  Lesser General Public License for more details.

  You should have received a copy of the GNU Lesser General Public
  License along with this library; if not, write to the Free Software
  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
*/

#ifndef BOOM_UNMAP_HPP
#define BOOM_UNMAP_HPP
#include <map>
#include <vector>

namespace BOOM {

  template <class K, class V>
  std::vector<V> unmap_values(const std::map<K, V> &m) {
    std::vector<V> ans;
    unsigned int n = m.size();
    ans.reserve(n);
    for (typename std::map<K, V>::const_iterator it = m.begin(); it != m.end();
         ++it)
      ans.push_back(it->second);
    return ans;
  }

  template <class K, class V>
  std::vector<K> unmap_keys(const std::map<K, V> &m) {
    std::vector<K> ans;
    unsigned int n = m.size();
    ans.reserve(n);
    for (typename std::map<K, V>::const_iterator it = m.begin(); it != m.end();
         ++it)
      ans.push_back(it->first);
    return ans;
  }

}  // namespace BOOM
#endif  // BOOM_UNMAP_HPP
