text: #ifndef OSMIUM_HISTORY_SPLITTER_TEST_TILESET_HPP
  #define OSMIUM_HISTORY_SPLITTER_TEST_TILESET_HPP
  
  /*
  
  This file is part of the Osmium History Splitter
  
  Copyright 2015 Matt Amos <zerebubuth@gmail.com>.
  
  Boost Software License - Version 1.0 - August 17th, 2003
  
  Permission is hereby granted, free of charge, to any person or organization
  obtaining a copy of the software and accompanying documentation covered by
  this license (the "Software") to use, reproduce, display, distribute,
  execute, and transmit the Software, and to prepare derivative works of the
  Software, and to permit third-parties to whom the Software is furnished to
  do so, all subject to the following:
  
  The copyright notices in the Software and this entire statement, including
  the above license grant, this restriction and the following disclaimer,
  must be included in all copies of the Software, in whole or in part, and
  all derivative works of the Software, unless such copies or derivative
  works are solely in the form of machine-executable object code generated by
  a source language processor.
  
  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
  SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
  FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
  ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
  DEALINGS IN THE SOFTWARE.
  
  */
  
  #include <map>
  #include <set>
  #include <osmium/osm/types.hpp>
  #include "splitter.hpp"
  
  template <typename Iterator>
  struct iter_pair_range {
    typedef std::pair<Iterator, Iterator> value_type;
    value_type m_pair;
  
    explicit iter_pair_range(value_type v) : m_pair(v) {}
  
    Iterator begin() const { return m_pair.first; }
    Iterator end()   const { return m_pair.second; }
  };
  
  struct tileset {
    typedef osmium::object_id_type key_type;
    typedef hsplitter::tile_t mapped_type;
    typedef std::set<mapped_type>::const_iterator const_iterator;
  
    tileset() : m_map(), m_empty(), m_frozen(false) {}
    tileset(tileset &&t) : m_map(std::move(t.m_map)), m_empty(), m_frozen(t.m_frozen) {}
    tileset(const tileset &) = delete;
  
    tileset &operator=(tileset &&t) { m_map = std::move(t.m_map); m_frozen = t.m_frozen; return *this; }
    tileset &operator=(const tileset &) = delete;
  
    inline void insert(key_type k, mapped_type v) {
      assert(!m_frozen);
      m_map[k].insert(v);
    }
  
    inline iter_pair_range<const_iterator> equal_range(key_type k) const {
      assert(m_frozen);
      auto itr = m_map.find(k);
      if (itr == m_map.end()) {
        return iter_pair_range<const_iterator>(std::make_pair(m_empty.end(), m_empty.end()));
      } else {
        return iter_pair_range<const_iterator>(std::make_pair(itr->second.begin(), itr->second.end()));
      }
    }
  
    void freeze() {
      assert(!m_frozen);
      m_frozen = true;
    }
  
    std::map<key_type, std::set<mapped_type> > m_map;
    const std::set<mapped_type> m_empty;
    bool m_frozen;
  };
  
  #endif /* OSMIUM_HISTORY_SPLITTER_TEST_TILESET_HPP */
  