1818
1919#include " osmtypes.hpp"
2020
21- #include < cassert>
2221#include < vector>
2322
23+ /* *
24+ * A list of OSM object ids. Internally this is a vector of ids.
25+ *
26+ * Some operations are only allowed when the list of ids is sorted and
27+ * without duplicates. Call sort_unique() to achieve this.
28+ */
2429class idlist_t
2530{
2631public:
@@ -51,20 +56,20 @@ class idlist_t
5156
5257 osmid_t operator [](std::size_t n) const noexcept { return m_list[n]; }
5358
54- void clear () { m_list.clear (); }
59+ void clear () noexcept { m_list.clear (); }
5560
5661 void push_back (osmid_t id) { m_list.push_back (id); }
5762
5863 void reserve (std::size_t size) { m_list.reserve (size); }
5964
60- osmid_t pop_id ()
61- {
62- assert (!m_list.empty ());
63- auto const id = m_list.back ();
64- m_list.pop_back ();
65- return id;
66- }
65+ /* *
66+ * Remove id at the end of the list and return it.
67+ *
68+ * \pre \code !m_list.empty()) \endcode
69+ */
70+ osmid_t pop_id ();
6771
72+ // / List are equal if they contain the same ids in the same order.
6873 friend bool operator ==(idlist_t const &lhs, idlist_t const &rhs) noexcept
6974 {
7075 return lhs.m_list == rhs.m_list ;
@@ -75,13 +80,22 @@ class idlist_t
7580 return !(lhs == rhs);
7681 }
7782
83+ /* *
84+ * Sort this list and remove duplicates.
85+ */
7886 void sort_unique ();
7987
88+ /* *
89+ * Merge other list into this one.
90+ *
91+ * \pre Both lists must be sorted and without duplicates.
92+ */
8093 void merge_sorted (idlist_t const &other);
8194
8295 /* *
83- * Remove all ids in this list that are also in the other list. Both
84- * lists must be sorted.
96+ * Remove all ids in this list that are also in the other list.
97+ *
98+ * \pre Both lists must be sorted and without duplicates.
8599 */
86100 void remove_ids_if_in (idlist_t const &other);
87101
0 commit comments