From bf1e5b6b8b73fed4ab1bfb40a1f362c255fe7029 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Fri, 5 Nov 2021 12:39:26 +0200 Subject: Improve prefix multiple support --- libbutl/prefix-map.hxx | 33 +++++++++++++++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) (limited to 'libbutl/prefix-map.hxx') diff --git a/libbutl/prefix-map.hxx b/libbutl/prefix-map.hxx index 9706ebd..0895d96 100644 --- a/libbutl/prefix-map.hxx +++ b/libbutl/prefix-map.hxx @@ -135,7 +135,6 @@ namespace butl const_iterator find_sup (const key_type&) const; - // As above but additionally evaluate a predicate on each matching entry // returning the one for which it returns true. // @@ -148,6 +147,26 @@ namespace butl find_sup_if (const key_type&, P) const; }; + template + struct prefix_multimap_common: prefix_map_common + { + typedef M map_type; + typedef typename map_type::key_type key_type; + typedef typename map_type::iterator iterator; + typedef typename map_type::const_iterator const_iterator; + + using prefix_map_common::prefix_map_common; + + // Find the most qualified entries that are super-prefixes of the + // specified prefix. + // + std::pair + sup_range (const key_type&); + + std::pair + sup_range (const key_type&) const; + }; + template ::delimiter_type D> struct prefix_map_impl: prefix_map_common { @@ -158,6 +177,16 @@ namespace butl : prefix_map_common (std::move (i), D) {} }; + template ::delimiter_type D> + struct prefix_multimap_impl: prefix_multimap_common + { + typedef typename prefix_multimap_common::value_type value_type; + + prefix_multimap_impl (): prefix_multimap_common (D) {} + prefix_multimap_impl (std::initializer_list i) + : prefix_multimap_common (std::move (i), D) {} + }; + template ::delimiter_type D> @@ -167,7 +196,7 @@ namespace butl typename T, typename compare_prefix::delimiter_type D> using prefix_multimap = - prefix_map_impl>, D>; + prefix_multimap_impl>, D>; } #include -- cgit v1.1