192 lines
6.3 KiB
Markdown
192 lines
6.3 KiB
Markdown
[hive.operations]
|
||
|
||
# 23 Containers library [[containers]](./#containers)
|
||
|
||
## 23.3 Sequence containers [[sequences]](sequences#hive.operations)
|
||
|
||
### 23.3.9 Class template hive [[hive]](hive#operations)
|
||
|
||
#### 23.3.9.5 Operations [hive.operations]
|
||
|
||
[1](#1)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L8790)
|
||
|
||
In this subclause,
|
||
arguments for a template parameter
|
||
named Predicate or BinaryPredicate shall meet the corresponding requirements in [[algorithms.requirements]](algorithms.requirements "26.2 Algorithms requirements")[.](#1.sentence-1)
|
||
|
||
The semantics of i + n and i - n,
|
||
where i is an iterator into the hive and n is an integer,
|
||
are the same as those of next(i, n) and prev(i, n), respectively[.](#1.sentence-2)
|
||
|
||
For sort, the definitions and requirements in [[alg.sorting]](alg.sorting "26.8 Sorting and related operations") apply[.](#1.sentence-3)
|
||
|
||
[ð](#lib:splice,hive)
|
||
|
||
`void splice(hive& x);
|
||
void splice(hive&& x);
|
||
`
|
||
|
||
[2](#2)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L8807)
|
||
|
||
*Preconditions*: get_allocator() == x.get_allocator() is true[.](#2.sentence-1)
|
||
|
||
[3](#3)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L8811)
|
||
|
||
*Effects*: If addressof(x) == this is true,
|
||
the behavior is erroneous and there are no effects[.](#3.sentence-1)
|
||
|
||
Otherwise, inserts the contents of x into *this andx becomes empty[.](#3.sentence-2)
|
||
|
||
Pointers and references to the moved elements of x now refer to those same elements but as members of *this[.](#3.sentence-3)
|
||
|
||
Iterators referring to the moved elements continue to refer to their elements,
|
||
but they now behave as iterators into *this, not into x[.](#3.sentence-4)
|
||
|
||
[4](#4)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L8822)
|
||
|
||
*Throws*: length_error if any of x's active blocks
|
||
are not within the bounds of *current-limits*[.](#4.sentence-1)
|
||
|
||
[5](#5)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L8827)
|
||
|
||
*Complexity*: Linear in the sum of
|
||
all element blocks in x plus all element blocks in *this[.](#5.sentence-1)
|
||
|
||
[6](#6)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L8832)
|
||
|
||
*Remarks*: Reserved blocks in x are not transferred into *this[.](#6.sentence-1)
|
||
|
||
If addressof(x) == this is false,
|
||
invalidates the past-the-end iterator for both x and *this[.](#6.sentence-2)
|
||
|
||
[ð](#lib:unique,hive)
|
||
|
||
`template<class BinaryPredicate = equal_to<T>>
|
||
size_type unique(BinaryPredicate binary_pred = BinaryPredicate());
|
||
`
|
||
|
||
[7](#7)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L8846)
|
||
|
||
*Preconditions*: binary_pred is an equivalence relation[.](#7.sentence-1)
|
||
|
||
[8](#8)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L8850)
|
||
|
||
*Effects*: Erases all but the first element
|
||
from every consecutive group of equivalent elements[.](#8.sentence-1)
|
||
|
||
That is, for a nonempty hive,
|
||
erases all elements referred to by the iterator i in the range [begin() + 1, end())
|
||
for which binary_pred(*i, *(i - 1)) is true[.](#8.sentence-2)
|
||
|
||
[9](#9)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L8859)
|
||
|
||
*Returns*: The number of elements erased[.](#9.sentence-1)
|
||
|
||
[10](#10)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L8863)
|
||
|
||
*Throws*: Nothing unless an exception is thrown by the predicate[.](#10.sentence-1)
|
||
|
||
[11](#11)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L8867)
|
||
|
||
*Complexity*: If empty() is false,
|
||
exactly size() - 1 applications of the corresponding predicate,
|
||
otherwise no applications of the predicate[.](#11.sentence-1)
|
||
|
||
[12](#12)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L8873)
|
||
|
||
*Remarks*: Invalidates references, pointers, and iterators
|
||
referring to the erased elements[.](#12.sentence-1)
|
||
|
||
If the last element in *this is erased,
|
||
also invalidates the past-the-end iterator[.](#12.sentence-2)
|
||
|
||
[ð](#lib:sort,hive)
|
||
|
||
`template<class Compare = less<T>>
|
||
void sort(Compare comp = Compare());
|
||
`
|
||
|
||
[13](#13)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L8888)
|
||
|
||
*Preconditions*: T is *Cpp17MoveInsertable* into hive,*Cpp17MoveAssignable*, and *Cpp17Swappable*[.](#13.sentence-1)
|
||
|
||
[14](#14)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L8893)
|
||
|
||
*Effects*: Sorts *this according to the comp function object[.](#14.sentence-1)
|
||
|
||
If an exception is thrown,
|
||
the order of the elements in *this is unspecified[.](#14.sentence-2)
|
||
|
||
[15](#15)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L8899)
|
||
|
||
*Complexity*: O(NlogN) comparisons, where N is size()[.](#15.sentence-1)
|
||
|
||
[16](#16)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L8903)
|
||
|
||
*Remarks*: May allocate[.](#16.sentence-1)
|
||
|
||
References, pointers, and iterators referring to elements in *this,
|
||
as well as the past-the-end iterator, may be invalidated[.](#16.sentence-2)
|
||
|
||
[*Note [1](#note-1)*:
|
||
|
||
Not required to be stable[[algorithm.stable]](algorithm.stable "16.4.6.8 Requirements for stable algorithms")[.](#16.sentence-3)
|
||
|
||
â *end note*]
|
||
|
||
[ð](#lib:get_iterator,hive)
|
||
|
||
`iterator get_iterator(const_pointer p) noexcept;
|
||
const_iterator get_iterator(const_pointer p) const noexcept;
|
||
`
|
||
|
||
[17](#17)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L8920)
|
||
|
||
*Preconditions*: p points to an element in *this[.](#17.sentence-1)
|
||
|
||
[18](#18)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L8924)
|
||
|
||
*Returns*: An iterator or const_iterator pointing to the same element as p[.](#18.sentence-1)
|
||
|
||
[19](#19)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L8929)
|
||
|
||
*Complexity*: Linear in the number of active blocks in *this[.](#19.sentence-1)
|