Skip to content
132 changes: 72 additions & 60 deletions source/algorithms.tex
Original file line number Diff line number Diff line change
Expand Up @@ -10425,8 +10425,7 @@
and \tcode{proj1} and \tcode{proj2} be \tcode{identity\{\}}
for the overloads with no parameters by those names;
\item
$M$ be \tcode{last1 - first1} plus the number of elements in \range{first2}{last2}
that are not present in \range{first1}{last1};
$M$ be the number of elements in the sorted union (see below);
\item
\tcode{result_last} be \tcode{result + $M$}
for the overloads with no parameter \tcode{result_last} or \tcode{result_r};
Expand All @@ -10442,8 +10441,21 @@

\pnum
\effects
Constructs a sorted union of $N$ elements from the two ranges;
Constructs a sorted union of the elements from the two ranges;
that is, the set of elements that are present in one or both of the ranges.
If \range{first1}{last1} contains $m$ elements
that are equivalent to each other and
\range{first2}{last2} contains $n$ elements that are equivalent to them,
then all $m$ elements from the first range
are included in the union, in order, and
then the final $\max(n - m,0)$ elements from the second range
are included in the union, in order.
If, of those elements, $k$ elements from the first range
are copied to the output range,
then the first $\min(k,n)$ elements from the second range
are considered \term{skipped}.
Copies the first $N$ elements of the sorted union
to the range \range{result}{result + $N$}.

\pnum
\returns
Expand All @@ -10456,10 +10468,9 @@
for the overloads in namespace \tcode{ranges},
if $N$ is equal to $M$.
\item
Otherwise, \tcode{\{j1, j2, result_last\}}
Otherwise, \tcode{\{first1 + $A$, first2 + $B$, result_last\}}
for the overloads in namespace \tcode{ranges},
where the iterators \tcode{j1} and \tcode{j2}
point to positions past the last copied or skipped elements
where $A$ and $B$ are the numbers of copied or skipped elements
in \range{first1}{last1} and \range{first2}{last2}, respectively.
\end{itemize}

Expand All @@ -10471,14 +10482,6 @@
\pnum
\remarks
Stable\iref{algorithm.stable}.
If \range{first1}{last1} contains $m$ elements
that are equivalent to each other and
\range{first2}{last2} contains $n$ elements
that are equivalent to them,
then all $m$ elements from the first range
are copied to the output range, in order, and
then the final $\max(n - m, 0)$ elements from the second range
are copied to the output range, in order.
\end{itemdescr}

\rSec3[set.intersection]{\tcode{set_intersection}}
Expand Down Expand Up @@ -10555,8 +10558,7 @@
and \tcode{proj1} and \tcode{proj2} be \tcode{identity\{\}}
for the overloads with no parameters by those names;
\item
$M$ be the number of elements in \range{first1}{last1}
that are present in \range{first2}{last2};
$M$ be the number of elements in the sorted intersection (see below);
\item
\tcode{result_last} be \tcode{result + $M$}
for the overloads with no parameter \tcode{result_last} or \tcode{result_r};
Expand All @@ -10572,8 +10574,23 @@

\pnum
\effects
Constructs a sorted intersection of $N$ elements from the two ranges;
Constructs a sorted intersection of the elements from the two ranges;
that is, the set of elements that are present in both of the ranges.
If \range{first1}{last1} contains $m$ elements
that are equivalent to each other and
\range{first2}{last2} contains $n$ elements
that are equivalent to them,
the first $\min(m, n)$ elements
are included in the sorted intersection.
If, of those elements, $k$ elements from the first range
are copied to the output range,
then the first $k$ elements from the second range
are considered \term{skipped}.
If $N < M$, a non-copied element is also considered skipped
if it compares less than the $(N+1)^\text{th}$ element
of the sorted intersection.
Copies the first $N$ elements of the sorted intersection
to the range \range{result}{result + $N$}.

\pnum
\returns
Expand All @@ -10586,10 +10603,9 @@
for the overloads in namespace \tcode{ranges},
if $N$ is equal to $M$.
\item
Otherwise, \tcode{\{j1, j2, result_last\}}
Otherwise, \tcode{\{first1 + $A$, first2 + $B$, result_last\}}
for the overloads in namespace \tcode{ranges},
where the iterators \tcode{j1} and \tcode{j2}
point to positions past the last copied or skipped elements
where $A$ and $B$ are the numbers of copied or skipped elements
in \range{first1}{last1} and \range{first2}{last2}, respectively.
\end{itemize}

Expand All @@ -10601,12 +10617,6 @@
\pnum
\remarks
Stable\iref{algorithm.stable}.
If \range{first1}{last1} contains $m$ elements
that are equivalent to each other and
\range{first2}{last2} contains $n$ elements
that are equivalent to them,
the first $\min(m, n)$ elements
are copied from the first range to the output range, in order.
\end{itemdescr}

\rSec3[set.difference]{\tcode{set_difference}}
Expand Down Expand Up @@ -10682,8 +10692,7 @@
and \tcode{proj1} and \tcode{proj2} be \tcode{identity\{\}}
for the overloads with no parameters by those names;
\item
$M$ be the number of elements in \range{first1}{last1}
that are not present in \range{first2}{last2};
$M$ be the number of elements in the sorted difference (see below);
\item
\tcode{result_last} be \tcode{result + $M$}
for the overloads with no parameter \tcode{result_last} or \tcode{result_r};
Expand All @@ -10699,10 +10708,17 @@

\pnum
\effects
Copies $N$ elements of the range \range{first1}{last1}
which are not present in the range \range{first2}{last2}
Constructs a sorted difference between the elements from the two ranges;
that is, the set of elements that are present
in the range \range{first1}{last1} but not \range{first2}{last2}.
If \range{first1}{last1} contains $m$ elements
that are equivalent to each other and
\range{first2}{last2} contains $n$ elements
that are equivalent to them,
the last $\max(m - n, 0)$ elements from \range{first1}{last1}
are included in the sorted difference, in order.
Copies the first $N$ elements of the sorted difference
to the range \range{result}{result + $N$}.
The elements in the constructed range are sorted.

\pnum
\returns
Expand All @@ -10718,8 +10734,8 @@
Otherwise, \tcode{\{j1, result_last\}}
for the overloads in namespace \tcode{ranges},
where the iterator \tcode{j1}
points to the position past the last copied or skipped element
in \range{first1}{last1}.
points to the position of the element in \range{first1}{last1}
corresponding to the $(N+1)^\text{th}$ element of the sorted difference.
\end{itemize}

\pnum
Expand All @@ -10729,12 +10745,7 @@

\pnum
\remarks
If \range{first1}{last1} contains $m$ elements
that are equivalent to each other and
\range{first2}{last2} contains $n$ elements
that are equivalent to them,
the last $\max(m - n, 0)$ elements from \range{first1}{last1}
are copied to the output range, in order.
Stable\iref{algorithm.stable}.
\end{itemdescr}

\rSec3[set.symmetric.difference]{\tcode{set_symmetric_difference}}
Expand Down Expand Up @@ -10813,14 +10824,12 @@
and \tcode{proj1} and \tcode{proj2} be \tcode{identity\{\}}
for the overloads with no parameters by those names;
\item
$K$ be the number of elements in \range{first1}{last1} that are not present in \range{first2}{last2}.
\item
$M$ be the number of elements in \range{first2}{last2} that are not present in \range{first1}{last1}.
$M$ be the number of elements in the sorted symmetric difference (see below);
\item
\tcode{result_last} be \tcode{result + $M$ + $K$}
\tcode{result_last} be \tcode{result + $M$}
for the overloads with no parameter \tcode{result_last} or \tcode{result_r};
\item
$N$ be $\min(K + M, \ \tcode{result_last - result})$.
$N$ be $\min(M, \ \tcode{result_last - result})$.
\end{itemize}

\pnum
Expand All @@ -10831,12 +10840,24 @@

\pnum
\effects
Copies the elements of the range \range{first1}{last1}
that are not present in the range \range{first2}{last2},
and the elements of the range \range{first2}{last2}
that are not present in the range \range{first1}{last1}
Constructs a sorted symmetric difference of the elements from the two ranges;
that is, the set of elements that are present
in exactly one of \range{first1}{last1} and \range{first2}\range{last2}.
If \range{first1}{last1} contains $m$ elements
that are equivalent to each other and
\range{first2}{last2} contains $n$ elements
that are equivalent to them,
then $|m - n|$ of those elements are included in the symmetric difference:
the last $m - n$ of these elements from \range{first1}{last1},
in order, if $m > n$, and
the last $n - m$ of these elements from \range{first2}{last2},
in order, if $m < n$.
If $N < M$, a non-copied element is considered \term{skipped}
if it compares less than or equivalent to the $(N+1)^\text{th}$ element
of the sorted symmetric difference,
unless it is from the same range as that element and does not precede it.
Copies the first $N$ elements of the sorted symmetric difference
to the range \range{result}{result + $N$}.
The elements in the constructed range are sorted.

\pnum
\returns
Expand All @@ -10849,10 +10870,9 @@
for the overloads in namespace \tcode{ranges},
if $N$ is equal to $M + K$.
\item
Otherwise, \tcode{\{j1, j2, result_last\}}
Otherwise, \tcode{\{first1 + $A$, first2 + $B$, result_last\}}
for the overloads in namespace \tcode{ranges},
where the iterators \tcode{j1} and \tcode{j2}
point to positions past the last copied or skipped elements
where $A$ and $B$ are the numbers of copied or skipped elements
in \range{first1}{last1} and \range{first2}{last2}, respectively.
\end{itemize}

Expand All @@ -10864,14 +10884,6 @@
\pnum
\remarks
Stable\iref{algorithm.stable}.
If \range{first1}{last1} contains $m$ elements
that are equivalent to each other and
\range{first2}{last2} contains $n$ elements
that are equivalent to them,
then $|m - n|$ of those elements shall be copied to the output range:
the last $m - n$ of these elements from \range{first1}{last1} if $m > n$, and
the last $n - m$ of these elements from \range{first2}{last2} if $m < n$.
In either case, the elements are copied in order.
\end{itemdescr}

\rSec2[alg.heap.operations]{Heap operations}
Expand Down
26 changes: 19 additions & 7 deletions source/containers.tex
Original file line number Diff line number Diff line change
Expand Up @@ -7930,8 +7930,11 @@
that provides constant-time insertion and erasure operations.
Storage is automatically managed in multiple memory blocks,
referred to as \defnx{element blocks}{element block}.
Insertion position is determined by the container, and insertion
Insertion\iref{hive.modifiers} position is determined by the container, and insertion
may re-use the memory locations of erased elements.
\begin{note}
Construction and assignment are not considered to involve insertion operations.
\end{note}

\pnum
Element blocks which contain elements are referred to
Expand Down Expand Up @@ -8253,7 +8256,7 @@
\begin{itemdescr}
\pnum
\effects
Constructs a \tcode{hive} object with the elements of the range \tcode{rg},
Constructs a \tcode{hive} object equal to the range \tcode{rg},
using the specified allocator.
If the second overload is called,
also initializes \exposid{current-limits} with \tcode{block_limits}.
Expand All @@ -8276,7 +8279,7 @@

\pnum
\effects
Constructs a \tcode{hive} object with the elements of \tcode{x}.
Constructs a \tcode{hive} object equal to \tcode{x}.
If the second overload is called, uses \tcode{alloc}.
Initializes \exposid{current-limits} with \tcode{x.\exposid{current-limits}}.

Expand Down Expand Up @@ -8319,6 +8322,8 @@
\pnum
\ensures
\tcode{x.empty()} is \tcode{true}.
The relative order of the elements of \tcode{*this}
is the same as that of the elements of \tcode{x} prior to the call.

\pnum
\complexity
Expand All @@ -8340,7 +8345,7 @@

\pnum
\effects
Constructs a \tcode{hive} object with the elements of \tcode{il},
Constructs a \tcode{hive} object equal to \tcode{il},
using the specified allocator.
If the second overload is called,
also initializes \exposid{current-limits} with \tcode{block_limits}.
Expand All @@ -8364,7 +8369,8 @@
\pnum
\effects
All elements in \tcode{*this} are either copy-assigned to, or destroyed.
All elements in \tcode{x} are copied into \tcode{*this}.
All elements in \tcode{x} are copied into \tcode{*this},
maintaining their relative order.
\begin{note}
\exposid{current-limits} is unchanged.
\end{note}
Expand Down Expand Up @@ -8423,6 +8429,8 @@
\pnum
\ensures
\tcode{x.empty()} is \tcode{true}.
The relative order of the elements of \tcode{*this}
is the same as that of the elements of \tcode{x} prior to this call.

\pnum
\complexity
Expand Down Expand Up @@ -8479,7 +8487,6 @@

\pnum
\remarks
The size of the sequence is not changed.
All references, pointers, and iterators referring to elements in \tcode{*this},
as well as the past-the-end iterator, remain valid.
\end{itemdescr}
Expand Down Expand Up @@ -8533,7 +8540,10 @@
\effects
For the first overload, all reserved blocks are deallocated, and
\tcode{capacity()} is reduced accordingly.
For the second overload, \tcode{capacity()} is reduced to no less than \tcode{n}.
For the second overload,
if \tcode{n >= capacity()} is \tcode{true},
there are no effects;
otherwise, \tcode{capacity()} is reduced to no less than \tcode{n}.

\pnum
\complexity
Expand Down Expand Up @@ -8825,6 +8835,8 @@
\effects
If \tcode{addressof(x) == this} is \tcode{true},
the behavior is erroneous and there are no effects.
If an exceptions is thrown,
there are no effects.
Otherwise, inserts the contents of \tcode{x} into \tcode{*this} and
\tcode{x} becomes empty.
Pointers and references to the moved elements of \tcode{x}
Expand Down
Loading
Loading