aboutsummaryrefslogtreecommitdiff
path: root/libbutl/prefix-map.txx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2021-11-05 12:39:26 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2021-11-05 12:39:26 +0200
commitbf1e5b6b8b73fed4ab1bfb40a1f362c255fe7029 (patch)
tree105ce0dd13f67f80f932958bb16323f8067b67d3 /libbutl/prefix-map.txx
parent33b8b378fae1daa02550bc53c5e43c4dfc6819de (diff)
Improve prefix multiple support
Diffstat (limited to 'libbutl/prefix-map.txx')
-rw-r--r--libbutl/prefix-map.txx54
1 files changed, 54 insertions, 0 deletions
diff --git a/libbutl/prefix-map.txx b/libbutl/prefix-map.txx
index 502119a..80664bf 100644
--- a/libbutl/prefix-map.txx
+++ b/libbutl/prefix-map.txx
@@ -197,4 +197,58 @@ namespace butl
return i;
#endif
}
+
+ template <typename M>
+ auto prefix_multimap_common<M>::
+ sup_range (const key_type& k) -> std::pair<iterator, iterator>
+ {
+#if 0
+ // TODO (see above).
+#else
+ // First look for the exact match before making any copies.
+ //
+ auto r (this->equal_range (k));
+
+ if (r.first == r.second)
+ {
+ const auto& c (this->key_comp ());
+
+ for (key_type p (k); c.prefix (p); )
+ {
+ r = this->equal_range (p);
+ if (r.first != r.second)
+ break;
+ }
+ }
+
+ return r;
+#endif
+ }
+
+ template <typename M>
+ auto prefix_multimap_common<M>::
+ sup_range (const key_type& k) const -> std::pair<const_iterator, const_iterator>
+ {
+#if 0
+ // TODO (see above).
+#else
+ // First look for the exact match before making any copies.
+ //
+ auto r (this->equal_range (k));
+
+ if (r.first == r.second)
+ {
+ const auto& c (this->key_comp ());
+
+ for (key_type p (k); c.prefix (p); )
+ {
+ r = this->equal_range (p);
+ if (r.first != r.second)
+ break;
+ }
+ }
+
+ return r;
+#endif
+ }
}