@@ -192,6 +192,30 @@ namespace osmium {
192192
193193 ~RelationsMapIndex () noexcept = default ;
194194
195+ /* *
196+ * Find the given relation id in the index and call the given
197+ * function with all parent relation ids.
198+ *
199+ * @code
200+ * osmium::unsigned_object_id_type member_id = 17;
201+ * index.for_each_parent(member_id, [](osmium::unsigned_object_id_type id) {
202+ * ...
203+ * });
204+ * @endcode
205+ *
206+ * @deprecated Use for_each() instead.
207+ *
208+ * Complexity: Logarithmic in the number of elements in the index.
209+ * (Lookup uses binary search.)
210+ */
211+ template <typename TFunc>
212+ void for_each_parent (const osmium::unsigned_object_id_type member_id, TFunc&& func) const {
213+ const auto parents = m_map.get (member_id);
214+ for (auto it = parents.first ; it != parents.second ; ++it) {
215+ func (it->value );
216+ }
217+ }
218+
195219 /* *
196220 * Find the given relation id in the index and call the given
197221 * function with all related relation ids.
@@ -349,6 +373,23 @@ namespace osmium {
349373 return m_map.size ();
350374 }
351375
376+ /* *
377+ * Build an index for member to parent lookups from the contents
378+ * of this stash and return it.
379+ *
380+ * After you get the index you can not use the stash any more!
381+ *
382+ * @deprecated Use build_member_to_parent_index() instead.
383+ */
384+ RelationsMapIndex build_index () {
385+ assert (m_valid && " You can't use the RelationsMap any more after calling build_index()" );
386+ m_map.sort_unique ();
387+ #ifndef NDEBUG
388+ m_valid = false ;
389+ #endif
390+ return RelationsMapIndex{std::move (m_map)};
391+ }
392+
352393 /* *
353394 * Build an index for member to parent lookups from the contents
354395 * of this stash and return it.
0 commit comments