From 0126775afa59257c9e87638a5cbc6b5e0d90f02b Mon Sep 17 00:00:00 2001 From: Jonathan Wakely Date: Fri, 5 Sep 2025 19:14:38 +0100 Subject: [PATCH] [flat.map.modifiers] Remove redundancy in 'insert(sorted_unique, i, j)' We can specify this in terms of the overload without the `sorted_unique` tag. That is consistent with how the equivalent functions in `flat_set` and `flat_multiset` are specified. --- source/containers.tex | 23 +---------------------- 1 file changed, 1 insertion(+), 22 deletions(-) diff --git a/source/containers.tex b/source/containers.tex index 337685a058..417fa3b397 100644 --- a/source/containers.tex +++ b/source/containers.tex @@ -17792,32 +17792,11 @@ \begin{itemdescr} \pnum \effects -Adds elements to \exposid{c} as if by: -\begin{codeblock} -for (; first != last; ++first) { - value_type value = *first; - @\exposid{c}@.keys.insert(@\exposid{c}@.keys.end(), std::move(value.first)); - @\exposid{c}@.values.insert(@\exposid{c}@.values.end(), std::move(value.second)); -} -\end{codeblock} -Then, merges the sorted range of newly added elements and -the sorted range of pre-existing elements into a single sorted range; and -finally erases the duplicate elements as if by: -\begin{codeblock} -auto zv = views::zip(@\exposid{c}@.keys, @\exposid{c}@.values); -auto it = ranges::unique(zv, @\exposid{key-equiv}@(@\exposid{compare}@)).begin(); -auto dist = distance(zv.begin(), it); -@\exposid{c}@.keys.erase(@\exposid{c}@.keys.begin() + dist, @\exposid{c}@.keys.end()); -@\exposid{c}@.values.erase(@\exposid{c}@.values.begin() + dist, @\exposid{c}@.values.end()); -\end{codeblock} +Equivalent to \tcode{insert(first, last)}. \pnum \complexity Linear in $N$, where $N$ is \tcode{size()} after the operation. - -\pnum -\remarks -Since this operation performs an in-place merge, it may allocate memory. \end{itemdescr} \indexlibrarymember{insert_range}{flat_map}%