aboutsummaryrefslogtreecommitdiff
path: root/libbutl/prefix-map.mxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2018-01-19 09:06:39 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2018-01-19 09:06:39 +0200
commit3053f55528dbecb08ddb55fa94546a98af06e3e1 (patch)
tree6f9dc9fb9fe6c5593f1304f884d5c49c89bcad0b /libbutl/prefix-map.mxx
parent89bc63fb386f0e4d6e2b21c0d806da1e8de0a34d (diff)
Reimplement prefix_map::find_sup() to iterate over key, not entries
Diffstat (limited to 'libbutl/prefix-map.mxx')
-rw-r--r--libbutl/prefix-map.mxx14
1 files changed, 14 insertions, 0 deletions
diff --git a/libbutl/prefix-map.mxx b/libbutl/prefix-map.mxx
index 882f46e..85d7635 100644
--- a/libbutl/prefix-map.mxx
+++ b/libbutl/prefix-map.mxx
@@ -71,6 +71,20 @@ LIBBUTL_MODEXPORT namespace butl
compare (p.c_str (), pn, k.c_str (), pn == kn ? pn : pn + 1) == 0);
}
+ // If the key is not empty, convert the key to its prefix and return
+ // true. Return false otherwise.
+ //
+ bool
+ prefix (K& k) const
+ {
+ if (k.empty ())
+ return false;
+
+ size_type p (k.rfind (d_));
+ k.resize (p != K::npos ? p : 0);
+ return true;
+ }
+
protected:
int
compare (const C* x, size_type xn,