diff --git a/doc/compact_vector.md b/doc/compact_vector.md index e0edca5..ee2d85e 100644 --- a/doc/compact_vector.md +++ b/doc/compact_vector.md @@ -126,881 +126,880 @@ This container is inspired by [OpenFOAM's](https://openfoam.org/) container [`Li ### (constructor) -``` -compact_vector() - noexcept(std::is_nothrow_default_constructible::value); -``` -``` -explicit compact_vector(const Allocator& alloc) - noexcept(std::is_nothrow_copy_constructible::value); -``` +1. ``` + compact_vector() + noexcept(std::is_nothrow_default_constructible::value); + ``` +2. ``` + explicit compact_vector(const Allocator& alloc) + noexcept(std::is_nothrow_copy_constructible::value); + ``` -**Effects:** -Constructs an empty container. + **Effects:** + Constructs an empty container. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

-``` -explicit compact_vector(size_type n); -``` -``` -explicit compact_vector(size_type n, const Allocator& alloc); -``` +3. ``` + explicit compact_vector(size_type n); + ``` +4. ``` + explicit compact_vector(size_type n, const Allocator& alloc); + ``` -**Effects:** -Constructs the container with `n` default-constructed elements. + **Effects:** + Constructs the container with `n` default-constructed elements. -**Complexity:** -Linear in `n`. + **Complexity:** + Linear in `n`. -

+

-``` -compact_vector(size_type n, const T& value); -``` -``` -compact_vector(size_type n, const T& value, const Allocator& alloc); -``` +5. ``` + compact_vector(size_type n, const T& value); + ``` +6. ``` + compact_vector(size_type n, const T& value, const Allocator& alloc); + ``` -**Effects:** -Constructs the container with `n` copies of elements with value `value`. + **Effects:** + Constructs the container with `n` copies of elements with value `value`. -**Complexity:** -Linear in `n`. + **Complexity:** + Linear in `n`. -

+

-``` -template -compact_vector(InputIt first, InputIt last); -``` -``` -template -compact_vector(InputIt first, InputIt last, const Allocator& alloc); -``` +7. ``` + template + compact_vector(InputIt first, InputIt last); + ``` +8. ``` + template + compact_vector(InputIt first, InputIt last, const Allocator& alloc); + ``` -**Effects:** -Constructs the container with the contents of the range `[first, last)`. + **Effects:** + Constructs the container with the contents of the range `[first, last)`. -**Note:** -This overload participates in overload resolution only if `InputIt` satisfies requirements of [*LegacyInputIterator*](https://en.cppreference.com/w/cpp/named_req/InputIterator). + **Note:** + This overload participates in overload resolution only if `InputIt` satisfies requirements of [*LegacyInputIterator*](https://en.cppreference.com/w/cpp/named_req/InputIterator). -**Complexity:** -Linear in `std::distance(first, last)`. + **Complexity:** + Linear in `std::distance(first, last)`. -

+

-``` -compact_vector(std::initializer_list ilist); -``` -``` -compact_vector(std::initializer_list ilist, const Allocator& alloc); -``` +9. ``` + compact_vector(std::initializer_list ilist); + ``` +10. ``` + compact_vector(std::initializer_list ilist, const Allocator& alloc); + ``` -**Effects:** -Constructs the container with the contents of the initializer list `ilist`. + **Effects:** + Constructs the container with the contents of the initializer list `ilist`. -**Complexity:** -Linear in `ilist.size()`. + **Complexity:** + Linear in `ilist.size()`. -

+

-``` -compact_vector(const compact_vector& other); -``` -``` -compact_vector(const compact_vector& other, const Allocator& alloc); -``` +11. ``` + compact_vector(const compact_vector& other); + ``` +12. ``` + compact_vector(const compact_vector& other, const Allocator& alloc); + ``` -**Effects:** -Copy constructor. -Constructs the container with the copy of the contents of `other`. + **Effects:** + Copy constructor. + Constructs the container with the copy of the contents of `other`. -**Complexity:** -Linear in `other.size()`. + **Complexity:** + Linear in `other.size()`. -

+

-``` -compact_vector(compact_vector&& other); -``` -``` -compact_vector(compact_vector&& other, const Allocator& alloc); -``` +13. ``` + compact_vector(compact_vector&& other); + ``` +14. ``` + compact_vector(compact_vector&& other, const Allocator& alloc); + ``` -**Effects:** -Move constructor. -Constructs the container with the contents of `other` using move semantics. + **Effects:** + Move constructor. + Constructs the container with the contents of `other` using move semantics. -* First overload: - * `other` is guaranteed to be empty after the move. -* Second overload: - * `other` is not guaranteed to be empty after the move. - * `other` is in a valid but unspecified state after the move. + * Overload (13): + * `other` is guaranteed to be empty after the move. + * Overload (14): + * `other` is not guaranteed to be empty after the move. + * `other` is in a valid but unspecified state after the move. -**Complexity:** -Constant in the best case. Linear in `other.size()` in the worst case. + **Complexity:** + Constant in the best case. Linear in `other.size()` in the worst case. -

+

### (destructor) -``` -~compact_vector(); -``` +1. ``` + ~compact_vector(); + ``` -**Effects:** -Destructs the container. The destructors of the elements are called and the used storage is deallocated. + **Effects:** + Destructs the container. The destructors of the elements are called and the used storage is deallocated. -**Complexity:** -Linear in `size()`. + **Complexity:** + Linear in `size()`. -

+

### assign -``` -void assign(size_type n, const T& value); -``` +1. ``` + void assign(size_type n, const T& value); + ``` -**Effects:** -Replaces the contents of the container with `n` copies of value `value`. + **Effects:** + Replaces the contents of the container with `n` copies of value `value`. -

+

-``` -template -void assign(InputIt first, InputIt last); -``` +2. ``` + template + void assign(InputIt first, InputIt last); + ``` -**Effects:** -Replaces the contents of the container with the contents of the range `[first, last)`. + **Effects:** + Replaces the contents of the container with the contents of the range `[first, last)`. -**Note:** -This overload participates in overload resolution only if `InputIt` satisfies requirements of [*LegacyInputIterator*](https://en.cppreference.com/w/cpp/named_req/InputIterator). + **Note:** + This overload participates in overload resolution only if `InputIt` satisfies requirements of [*LegacyInputIterator*](https://en.cppreference.com/w/cpp/named_req/InputIterator). -**Note:** -The behavior is undefined if either `first` or `last` is an iterator into `*this`. + **Note:** + The behavior is undefined if either `first` or `last` is an iterator into `*this`. -

+

-``` -void assign(std::initializer_list ilist); -``` +3. ``` + void assign(std::initializer_list ilist); + ``` -**Effects:** -Replaces the contents of the container with the contents of the initializer list `ilist`. + **Effects:** + Replaces the contents of the container with the contents of the initializer list `ilist`. -

+

### operator= -``` -compact_vector& operator=(const compact_vector& other); -``` +1. ``` + compact_vector& operator=(const compact_vector& other); + ``` -**Effects:** -Copy assignment operator. -Replaces the contents with a copy of the contents of `other`. + **Effects:** + Copy assignment operator. + Replaces the contents with a copy of the contents of `other`. -**Returns:** -`*this()`. + **Returns:** + `*this()`. -

+

-``` -compact_vector& operator=(compact_vector&& other); -``` +2. ``` + compact_vector& operator=(compact_vector&& other); + ``` -**Effects:** -Move assignment operator. -Replaces the contents with those of `other` using move semantics. + **Effects:** + Move assignment operator. + Replaces the contents with those of `other` using move semantics. -`other` is not guaranteed to be empty after the move. + `other` is not guaranteed to be empty after the move. -`other` is in a valid but unspecified state after the move. + `other` is in a valid but unspecified state after the move. -**Returns:** -`*this()`. + **Returns:** + `*this()`. -

+

-``` -compact_vector& operator=(std::initializer_list ilist); -``` +3. ``` + compact_vector& operator=(std::initializer_list ilist); + ``` -**Effects:** -Replaces the contents with those identified by initializer list `ilist`. + **Effects:** + Replaces the contents with those identified by initializer list `ilist`. -**Returns:** -`*this()`. + **Returns:** + `*this()`. -

+

### get_allocator -``` -allocator_type get_allocator() const noexcept; -``` +1. ``` + allocator_type get_allocator() const noexcept; + ``` -**Effects:** -Returns the allocator associated with the container. + **Effects:** + Returns the allocator associated with the container. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

### begin, cbegin -``` -iterator begin() noexcept; -``` -``` -const_iterator begin() const noexcept; -``` -``` -const_iterator cbegin() const noexcept; -``` - -**Effects:** -Returns an iterator to the first element of the container. +1. ``` + iterator begin() noexcept; + ``` +2. ``` + const_iterator begin() const noexcept; + ``` +3. ``` + const_iterator cbegin() const noexcept; + ``` -If the container is empty, the returned iterator will be equal to `end()`. + **Effects:** + Returns an iterator to the first element of the container. + If the container is empty, the returned iterator will be equal to `end()`. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

### end, cend -``` -iterator end() noexcept; -``` -``` -const_iterator end() const noexcept; -``` -``` -const_iterator cend() const noexcept; -``` - -**Effects:** -Returns an iterator to the element following the last element of the container. +1. ``` + iterator end() noexcept; + ``` +2. ``` + const_iterator end() const noexcept; + ``` +3. ``` + const_iterator cend() const noexcept; + ``` -This element acts as a placeholder; attempting to access it results in undefined behavior. + **Effects:** + Returns an iterator to the element following the last element of the container. + This element acts as a placeholder; attempting to access it results in undefined behavior. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

### rbegin, crbegin -``` -reverse_iterator rbegin() noexcept; -``` -``` -const_reverse_iterator rbegin() const noexcept; -``` -``` -const_reverse_iterator crbegin() const noexcept; -``` +1. ``` + reverse_iterator rbegin() noexcept; + ``` +2. ``` + const_reverse_iterator rbegin() const noexcept; + ``` +3. ``` + const_reverse_iterator crbegin() const noexcept; + ``` -**Effects:** -Returns a reverse iterator to the first element of the reversed container. -It corresponds to the last element of the non-reversed container. -If the container is empty, the returned iterator is equal to `rend()`. + **Effects:** + Returns a reverse iterator to the first element of the reversed container. + It corresponds to the last element of the non-reversed container. + If the container is empty, the returned iterator is equal to `rend()`. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

### rend, crend -``` -reverse_iterator rend() noexcept; -``` -``` -const_reverse_iterator rend() const noexcept; -``` -``` -const_reverse_iterator crend() const noexcept; -``` +1. ``` + reverse_iterator rend() noexcept; + ``` +2. ``` + const_reverse_iterator rend() const noexcept; + ``` +3. ``` + const_reverse_iterator crend() const noexcept; + ``` -**Effects:** -Returns a reverse iterator to the element following the last element of the reversed container. -It corresponds to the element preceding the first element of the non-reversed container. -This element acts as a placeholder, attempting to access it results in undefined behavior. + **Effects:** + Returns a reverse iterator to the element following the last element of the reversed container. + It corresponds to the element preceding the first element of the non-reversed container. + This element acts as a placeholder, attempting to access it results in undefined behavior. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

### nth -``` -iterator nth(size_type pos) noexcept; -``` -``` -const_iterator nth(size_type pos) const noexcept; -``` +1. ``` + iterator nth(size_type pos) noexcept; + ``` +2. ``` + const_iterator nth(size_type pos) const noexcept; + ``` -**Preconditions:** -`pos <= size()` + **Preconditions:** + `pos <= size()` -**Effects:** -Returns an iterator to the element at position `pos`. -If `pos == size()`, the returned iterator is equal to `end()`. + **Effects:** + Returns an iterator to the element at position `pos`. -**Complexity:** -Constant. + If `pos == size()`, the returned iterator is equal to `end()`. -

+ **Complexity:** + Constant. + +

### index_of -``` -size_type index_of(const_iterator pos) const noexcept; -``` +1. ``` + size_type index_of(const_iterator pos) const noexcept; + ``` -**Preconditions:** -`cbegin() <= pos && pos <= cend()` + **Preconditions:** + `cbegin() <= pos && pos <= cend()` -**Effects:** -Returns position of the element pointed by iterator `pos`, i.e. `std::distance(begin(), pos)`. + **Effects:** + Returns position of the element pointed by iterator `pos`, i.e. `std::distance(begin(), pos)`. -If `pos == end()`, the returned value is equal to `size()`. + If `pos == end()`, the returned value is equal to `size()`. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

### empty -``` -bool empty() const noexcept; -``` +1. ``` + bool empty() const noexcept; + ``` -**Effects:** -Returns `true` if the container has no elements, i.e. whether `begin() == end()`. + **Effects:** + Returns `true` if the container has no elements, i.e. whether `begin() == end()`. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

### size -``` -size_type size() const noexcept; -``` +1. ``` + size_type size() const noexcept; + ``` -**Effects:** -Returns the number of elements in the container, i.e. `std::distance(begin(), end())`. + **Effects:** + Returns the number of elements in the container, i.e. `std::distance(begin(), end())`. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

### max_size -``` -size_type max_size() const noexcept; -``` +1. ``` + size_type max_size() const noexcept; + ``` -**Effects:** -Returns the maximum number of elements the container is able to hold, i.e. `std::distance(begin(), end())` for the largest container. + **Effects:** + Returns the maximum number of elements the container is able to hold, i.e. `std::distance(begin(), end())` for the largest container. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

### capacity -``` -size_type capacity() const noexcept; -``` +1. ``` + size_type capacity() const noexcept; + ``` -**Effects:** -Returns the number of elements that the container has currently allocated space for. + **Effects:** + Returns the number of elements that the container has currently allocated space for. -**Note:** -The call to this function is equivalent to `return size();`. -The equality `capacity() == size()` is always `true` for this container. + **Note:** + The call to this function is equivalent to `return size();`. + The equality `capacity() == size()` is always `true` for this container. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

### available -``` -size_type available() const noexcept; -``` +1. ``` + size_type available() const noexcept; + ``` -**Effects:** -Returns the number of elements that can be inserted into the container without requiring allocation of additional memory. It always returns zero. + **Effects:** + Returns the number of elements that can be inserted into the container without requiring allocation of additional memory. It always returns zero. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

### at -``` -reference at(size_type pos); -``` -``` -const_reference at(size_type pos) const; -``` +1. ``` + reference at(size_type pos); + ``` +2. ``` + const_reference at(size_type pos) const; + ``` -**Effects:** -Returns a reference to the element at specified location `pos`, with bounds checking. + **Effects:** + Returns a reference to the element at specified location `pos`, with bounds checking. -**Complexity:** -Constant. + **Complexity:** + Constant. -**Exceptions:** -`std::out_of_range` if `pos >= size()`. + **Exceptions:** + `std::out_of_range` if `pos >= size()`. -

+

### operator[] -``` -reference operator[](size_type pos) noexcept; -``` -``` -const_reference operator[](size_type pos) const noexcept; -``` +1. ``` + reference operator[](size_type pos) noexcept; + ``` +2. ``` + const_reference operator[](size_type pos) const noexcept; + ``` -**Preconditions:** -`pos < size()` + **Preconditions:** + `pos < size()` -**Effects:** -Returns a reference to the element at specified location pos. No bounds checking is performed. + **Effects:** + Returns a reference to the element at specified location pos. No bounds checking is performed. -**Note:** -This operator never inserts a new element into the container. + **Note:** + This operator never inserts a new element into the container. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

### front -``` -reference front() noexcept; -``` -``` -const_reference front() const noexcept; -``` +1. ``` + reference front() noexcept; + ``` +2. ``` + const_reference front() const noexcept; + ``` -**Preconditions:** -`!empty()` + **Preconditions:** + `!empty()` -**Effects:** -Returns a reference to the first element in the container. + **Effects:** + Returns a reference to the first element in the container. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

### back -``` -reference back() noexcept; -``` -``` -const_reference back() const noexcept; -``` +1. ``` + reference back() noexcept; + ``` +2. ``` + const_reference back() const noexcept; + ``` -**Preconditions:** -`!empty()` + **Preconditions:** + `!empty()` -**Effects:** -Returns a reference to the last element in the container. + **Effects:** + Returns a reference to the last element in the container. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

### data -``` -T* data() noexcept; -``` -``` -const T* data() const noexcept; -``` +1. ``` + T* data() noexcept; + ``` +2. ``` + const T* data() const noexcept; + ``` -**Effects:** -Returns pointer to the underlying array serving as element storage. The pointer is such that range `[data(), data() + size())` is always a valid range, even if the container is empty. `data()` is not dereferenceable if the container is empty. + **Effects:** + Returns pointer to the underlying array serving as element storage. The pointer is such that range `[data(), data() + size())` is always a valid range, even if the container is empty. `data()` is not dereferenceable if the container is empty. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

### clear -``` -void clear() noexcept; -``` +1. ``` + void clear() noexcept; + ``` -**Effects:** -Erases all elements from the container. -After this call, both `size()` and `capacity()` return zero. -Remember that equality `capacity() == size()` is always `true` for this container. + **Effects:** + Erases all elements from the container. + After this call, both `size()` and `capacity()` return zero. + Remember that equality `capacity() == size()` is always `true` for this container. -**Complexity:** -Linear in `size()`. + **Complexity:** + Linear in `size()`. -

+

### emplace -``` -template -iterator emplace(const_iterator pos, Args&&... args); -``` +1. ``` + template + iterator emplace(const_iterator pos, Args&&... args); + ``` -**Preconditions:** -`cbegin() <= pos && pos <= cend()` + **Preconditions:** + `cbegin() <= pos && pos <= cend()` -**Effects:** -Inserts a new element into the container at position `pos`. + **Effects:** + Inserts a new element into the container at position `pos`. -New element is constructed as `value_type(std::forward(args)...)`. + New element is constructed as `value_type(std::forward(args)...)`. -`args...` may directly or indirectly refer to a value in the container. + `args...` may directly or indirectly refer to a value in the container. -**Returns:** -Iterator to the inserted element. + **Returns:** + Iterator to the inserted element. -

+

### insert -``` -iterator insert(const_iterator pos, const T& value); -``` +1. ``` + iterator insert(const_iterator pos, const T& value); + ``` -**Preconditions:** -`cbegin() <= pos && pos <= cend()` + **Preconditions:** + `cbegin() <= pos && pos <= cend()` -**Effects:** -Inserts copy of `value` at position `pos`. + **Effects:** + Inserts copy of `value` at position `pos`. -**Returns:** -Iterator to the inserted element. + **Returns:** + Iterator to the inserted element. -

+

-``` -iterator insert(const_iterator pos, T&& value); -``` +2. ``` + iterator insert(const_iterator pos, T&& value); + ``` -**Preconditions:** -`cbegin() <= pos && pos <= cend()` + **Preconditions:** + `cbegin() <= pos && pos <= cend()` -**Effects:** -Inserts `value` using move semantics at position `pos`. + **Effects:** + Inserts `value` using move semantics at position `pos`. -**Returns:** -Iterator to the inserted element. + **Returns:** + Iterator to the inserted element. -

+

-``` -iterator insert(const_iterator pos, size_type n, const T& value); -``` +3. ``` + iterator insert(const_iterator pos, size_type n, const T& value); + ``` -**Preconditions:** -`cbegin() <= pos && pos <= cend()` + **Preconditions:** + `cbegin() <= pos && pos <= cend()` -**Effects:** -Inserts `n` copies of `value` before position `pos`. + **Effects:** + Inserts `n` copies of `value` before position `pos`. -**Returns:** -Iterator to the first element inserted, or `pos` if `n == 0`. + **Returns:** + Iterator to the first element inserted, or `pos` if `n == 0`. -

+

-``` -template -iterator insert(const_iterator pos, InputIt first, InputIt last); -``` +4. ``` + template + iterator insert(const_iterator pos, InputIt first, InputIt last); + ``` -**Preconditions:** -`cbegin() <= pos && pos <= cend()` + **Preconditions:** + `cbegin() <= pos && pos <= cend()` -**Effects:** -Inserts elements from the range `[first, last)` before position `pos`. + **Effects:** + Inserts elements from the range `[first, last)` before position `pos`. -**Note:** -This overload participates in overload resolution only if `InputIt` satisfies requirements of [*LegacyInputIterator*](https://en.cppreference.com/w/cpp/named_req/InputIterator). + **Note:** + This overload participates in overload resolution only if `InputIt` satisfies requirements of [*LegacyInputIterator*](https://en.cppreference.com/w/cpp/named_req/InputIterator). -**Note:** -The behavior is undefined if either `first` or `last` is an iterator into `*this`. + **Note:** + The behavior is undefined if either `first` or `last` is an iterator into `*this`. -**Returns:** -Iterator to the first element inserted, or `pos` if `first == last`. + **Returns:** + Iterator to the first element inserted, or `pos` if `first == last`. -

+

-``` -iterator insert(const_iterator pos, std::initializer_list ilist); -``` +5. ``` + iterator insert(const_iterator pos, std::initializer_list ilist); + ``` -**Preconditions:** -`cbegin() <= pos && pos <= cend()` + **Preconditions:** + `cbegin() <= pos && pos <= cend()` -**Effects:** -Inserts elements from initializer list `ilist` before position `pos`. + **Effects:** + Inserts elements from initializer list `ilist` before position `pos`. -**Returns:** -Iterator to the first element inserted, or `pos` if `ilist` is empty. + **Returns:** + Iterator to the first element inserted, or `pos` if `ilist` is empty. -

+

### emplace_back -``` -template -reference emplace_back(Args&&... args); -``` +1. ``` + template + reference emplace_back(Args&&... args); + ``` -**Effects:** -Inserts a new element at the end of container. + **Effects:** + Inserts a new element at the end of container. -New element is constructed as `value_type(std::forward(args)...)`. + New element is constructed as `value_type(std::forward(args)...)`. -**Returns:** -Reference to the inserted element. + **Returns:** + Reference to the inserted element. -

+

### push_back -``` -void push_back(const T& value); -``` +1. ``` + void push_back(const T& value); + ``` -**Effects:** -Inserts copy of `value` at the end of container. + **Effects:** + Inserts copy of `value` at the end of container. -

+

-``` -void push_back(T&& value); -``` +2. ``` + void push_back(T&& value); + ``` -**Effects:** -Inserts `value` using move semantics at the end of container. + **Effects:** + Inserts `value` using move semantics at the end of container. -

+

### pop_back -``` -void pop_back(); -``` +1. ``` + void pop_back(); + ``` -**Preconditions:** -`!empty()` + **Preconditions:** + `!empty()` -**Effects:** -Removes the last element of the container. + **Effects:** + Removes the last element of the container. -

+

### erase -``` -iterator erase(const_iterator pos); -``` +1. ``` + iterator erase(const_iterator pos); + ``` -**Preconditions:** -`cbegin() <= pos && pos < cend()` + **Preconditions:** + `cbegin() <= pos && pos < cend()` -**Effects:** -Removes the element at `pos`. + **Effects:** + Removes the element at `pos`. -**Returns:** -Iterator following the last removed element. + **Returns:** + Iterator following the last removed element. -If `pos` refers to the last element, then the `end()` iterator is returned. + If `pos` refers to the last element, then the `end()` iterator is returned. -

+

-``` -iterator erase(const_iterator first, const_iterator last); -``` +2. ``` + iterator erase(const_iterator first, const_iterator last); + ``` -**Preconditions:** -`cbegin() <= first && first <= last && last <= cend()` + **Preconditions:** + `cbegin() <= first && first <= last && last <= cend()` -**Effects:** -Removes the elements in the range `[first, last)`. + **Effects:** + Removes the elements in the range `[first, last)`. -**Returns:** -Iterator following the last removed element. + **Returns:** + Iterator following the last removed element. -If `last == end()` prior to removal, then the updated `end()` iterator is returned. + If `last == end()` prior to removal, then the updated `end()` iterator is returned. -If `[first, last)` is an empty range, then `last` is returned. + If `[first, last)` is an empty range, then `last` is returned. -

+

### resize -``` -void resize(size_type n); -``` +1. ``` + void resize(size_type n); + ``` -**Effects:** -Resizes the container to contain `n` elements. + **Effects:** + Resizes the container to contain `n` elements. -1. If the `size() > n`, the last `size() - n` elements are removed. -2. If the `size() < n`, additional default-constructed elements are inserted at the end of container. + 1. If the `size() > n`, the last `size() - n` elements are removed. + 2. If the `size() < n`, additional default-constructed elements are inserted at the end of container. -

+

-``` -void resize(size_type n, const T& value); -``` +2. ``` + void resize(size_type n, const T& value); + ``` -**Effects:** -Resizes the container to contain `n` elements. + **Effects:** + Resizes the container to contain `n` elements. -1. If the `size() > n`, the last `size() - n` elements are removed. -2. If the `size() < n`, additional copies of `value` are inserted at the end of container. + 1. If the `size() > n`, the last `size() - n` elements are removed. + 2. If the `size() < n`, additional copies of `value` are inserted at the end of container. -

+

### swap -``` -void swap(compact_vector& other); -``` +1. ``` + void swap(compact_vector& other); + ``` -**Preconditions:** -`allocator_traits::propagate_on_container_swap::value || get_allocator() == other.get_allocator()` + **Preconditions:** + `allocator_traits::propagate_on_container_swap::value || get_allocator() == other.get_allocator()` -**Effects:** -Exchanges the contents of the container with those of `other`. + **Effects:** + Exchanges the contents of the container with those of `other`. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

@@ -1008,217 +1007,217 @@ Constant. ### operator== -``` -template -bool operator== -( - const compact_vector& x, - const compact_vector& y -); -``` +1. ``` + template + bool operator== + ( + const compact_vector& x, + const compact_vector& y + ); + ``` -**Effects:** -Checks if the contents of `x` and `y` are equal. + **Effects:** + Checks if the contents of `x` and `y` are equal. -The contents of `x` and `y` are equal if the following conditions hold: -* `x.size() == y.size()` -* Each element in `x` compares equal with the element in `y` at the same position. + The contents of `x` and `y` are equal if the following conditions hold: + * `x.size() == y.size()` + * Each element in `x` compares equal with the element in `y` at the same position. -**Returns:** -`true` if the contents of the `x` and `y` are equal, `false` otherwise. + **Returns:** + `true` if the contents of the `x` and `y` are equal, `false` otherwise. -**Complexity:** -Constant if `x` and `y` are of different size, otherwise linear in the size of the container. + **Complexity:** + Constant if `x` and `y` are of different size, otherwise linear in the size of the container. -

+

### operator!= -``` -template -bool operator!= -( - const compact_vector& x, - const compact_vector& y -); -``` +1. ``` + template + bool operator!= + ( + const compact_vector& x, + const compact_vector& y + ); + ``` -**Effects:** -Checks if the contents of `x` and `y` are equal. + **Effects:** + Checks if the contents of `x` and `y` are equal. -For details see `operator==`. + For details see `operator==`. -**Returns:** -`true` if the contents of the `x` and `y` are not equal, `false` otherwise. + **Returns:** + `true` if the contents of the `x` and `y` are not equal, `false` otherwise. -**Complexity:** -Constant if `x` and `y` are of different size, otherwise linear in the size of the container. + **Complexity:** + Constant if `x` and `y` are of different size, otherwise linear in the size of the container. -

+

### operator< -``` -template -bool operator< -( - const compact_vector& x, - const compact_vector& y -); -``` +1. ``` + template + bool operator< + ( + const compact_vector& x, + const compact_vector& y + ); + ``` -**Effects:** -Compares the contents of `x` and `y` lexicographically. -The comparison is performed by a function `std::lexicographical_compare`. + **Effects:** + Compares the contents of `x` and `y` lexicographically. + The comparison is performed by a function `std::lexicographical_compare`. -**Returns:** -`true` if the contents of the `x` are lexicographically less than the contents of `y`, `false` otherwise. + **Returns:** + `true` if the contents of the `x` are lexicographically less than the contents of `y`, `false` otherwise. -**Complexity:** -Linear in the size of the container. + **Complexity:** + Linear in the size of the container. -

+

### operator> -``` -template -bool operator> -( - const compact_vector& x, - const compact_vector& y -); -``` +1. ``` + template + bool operator> + ( + const compact_vector& x, + const compact_vector& y + ); + ``` -**Effects:** -Compares the contents of `x` and `y` lexicographically. -The comparison is performed by a function `std::lexicographical_compare`. + **Effects:** + Compares the contents of `x` and `y` lexicographically. + The comparison is performed by a function `std::lexicographical_compare`. -**Returns:** -`true` if the contents of the `x` are lexicographically greater than the contents of `y`, `false` otherwise. + **Returns:** + `true` if the contents of the `x` are lexicographically greater than the contents of `y`, `false` otherwise. -**Complexity:** -Linear in the size of the container. + **Complexity:** + Linear in the size of the container. -

+

### operator<= -``` -template -bool operator<= -( - const compact_vector& x, - const compact_vector& y -); -``` +1. ``` + template + bool operator<= + ( + const compact_vector& x, + const compact_vector& y + ); + ``` -**Effects:** -Compares the contents of `x` and `y` lexicographically. -The comparison is performed by a function `std::lexicographical_compare`. + **Effects:** + Compares the contents of `x` and `y` lexicographically. + The comparison is performed by a function `std::lexicographical_compare`. -**Returns:** -`true` if the contents of the `x` are lexicographically less than or equal to the contents of `y`, `false` otherwise. + **Returns:** + `true` if the contents of the `x` are lexicographically less than or equal to the contents of `y`, `false` otherwise. -**Complexity:** -Linear in the size of the container. + **Complexity:** + Linear in the size of the container. -

+

### operator>= -``` -template -bool operator>= -( - const compact_vector& x, - const compact_vector& y -); -``` +1. ``` + template + bool operator>= + ( + const compact_vector& x, + const compact_vector& y + ); + ``` -**Effects:** -Compares the contents of `x` and `y` lexicographically. -The comparison is performed by a function `std::lexicographical_compare`. + **Effects:** + Compares the contents of `x` and `y` lexicographically. + The comparison is performed by a function `std::lexicographical_compare`. -**Returns:** -`true` if the contents of the `x` are lexicographically greater than or equal to the contents of `y`, `false` otherwise. + **Returns:** + `true` if the contents of the `x` are lexicographically greater than or equal to the contents of `y`, `false` otherwise. -**Complexity:** -Linear in the size of the container. + **Complexity:** + Linear in the size of the container. -

+

### swap -``` -template -void swap -( - compact_vector& x, - compact_vector& y -); -``` +1. ``` + template + void swap + ( + compact_vector& x, + compact_vector& y + ); + ``` -**Effects:** -Swaps the contents of `x` and `y`. Calls `x.swap(y)`. + **Effects:** + Swaps the contents of `x` and `y`. Calls `x.swap(y)`. -

+

### erase -``` -template -typename compact_vector::size_type - erase(compact_vector& c, const U& value); -``` +1. ``` + template + typename compact_vector::size_type + erase(compact_vector& c, const U& value); + ``` -**Effects:** -Erases all elements that compare equal to `value` from the container. + **Effects:** + Erases all elements that compare equal to `value` from the container. -**Returns:** -The number of erased elements. + **Returns:** + The number of erased elements. -**Complexity:** -Linear. + **Complexity:** + Linear. -

+

### erase_if -``` -template -typename compact_vector::size_type - erase_if(compact_vector& c, Predicate pred); -``` +1. ``` + template + typename compact_vector::size_type + erase_if(compact_vector& c, Predicate pred); + ``` -**Effects:** -Erases all elements that satisfy the predicate `pred` from the container. + **Effects:** + Erases all elements that satisfy the predicate `pred` from the container. -`pred` is unary predicate which returns `true` if the element should be removed. + `pred` is unary predicate which returns `true` if the element should be removed. -**Returns:** -The number of erased elements. + **Returns:** + The number of erased elements. -**Complexity:** -Linear. + **Complexity:** + Linear. -

+

diff --git a/doc/segmented_devector.md b/doc/segmented_devector.md index 2598772..919462a 100644 --- a/doc/segmented_devector.md +++ b/doc/segmented_devector.md @@ -108,9 +108,9 @@ Key differences between `segmented_vector` and `segmented_devector`: std::size_t N ``` - The size of the segments, i.e. the maximal number of elements that can fit into a segment. + Segment size, i.e. the maximal number of elements that can fit into a segment. - Must be greater than zero. + This parameter must be greater than zero. 3. ``` typename Allocator @@ -162,1094 +162,1093 @@ static constexpr size_type segment_capacity = N; ### (constructor) -``` -segmented_devector(); -``` -``` -explicit segmented_devector(const Allocator& alloc); -``` +1. ``` + segmented_devector(); + ``` +2. ``` + explicit segmented_devector(const Allocator& alloc); + ``` -**Effects:** -Constructs an empty container. + **Effects:** + Constructs an empty container. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

-``` -segmented_devector(size_type n); -``` -``` -explicit segmented_devector(size_type n, const Allocator& alloc); -``` +3. ``` + segmented_devector(size_type n); + ``` +4. ``` + explicit segmented_devector(size_type n, const Allocator& alloc); + ``` -**Effects:** -Constructs the container with `n` default-constructed elements. + **Effects:** + Constructs the container with `n` default-constructed elements. -**Complexity:** -Linear in `n`. + **Complexity:** + Linear in `n`. -

+

-``` -segmented_devector(size_type n, const T& value); -``` -``` -segmented_devector(size_type n, const T& value, const Allocator& alloc); -``` +5. ``` + segmented_devector(size_type n, const T& value); + ``` +6. ``` + segmented_devector(size_type n, const T& value, const Allocator& alloc); + ``` -**Effects:** -Constructs the container with `n` copies of elements with value `value`. + **Effects:** + Constructs the container with `n` copies of elements with value `value`. -**Complexity:** -Linear in `n`. + **Complexity:** + Linear in `n`. -

+

-``` -template -segmented_devector(InputIt first, InputIt last); -``` -``` -template -segmented_devector(InputIt first, InputIt last, const Allocator& alloc); -``` +7. ``` + template + segmented_devector(InputIt first, InputIt last); + ``` +8. ``` + template + segmented_devector(InputIt first, InputIt last, const Allocator& alloc); + ``` -**Effects:** -Constructs the container with the contents of the range `[first, last)`. + **Effects:** + Constructs the container with the contents of the range `[first, last)`. -**Note:** -This overload participates in overload resolution only if `InputIt` satisfies requirements of [*LegacyInputIterator*](https://en.cppreference.com/w/cpp/named_req/InputIterator). + **Note:** + This overload participates in overload resolution only if `InputIt` satisfies requirements of [*LegacyInputIterator*](https://en.cppreference.com/w/cpp/named_req/InputIterator). -**Complexity:** -Linear in `std::distance(first, last)`. + **Complexity:** + Linear in `std::distance(first, last)`. -

+

-``` -segmented_devector(std::initializer_list ilist); -``` -``` -segmented_devector(std::initializer_list ilist, const Allocator& alloc); -``` +9. ``` + segmented_devector(std::initializer_list ilist); + ``` +10. ``` + segmented_devector(std::initializer_list ilist, const Allocator& alloc); + ``` -**Effects:** -Constructs the container with the contents of the initializer list `ilist`. + **Effects:** + Constructs the container with the contents of the initializer list `ilist`. -**Complexity:** -Linear in `ilist.size()`. + **Complexity:** + Linear in `ilist.size()`. -

+

-``` -segmented_devector(const segmented_devector& other); -``` -``` -segmented_devector(const segmented_devector& other, const Allocator& alloc); -``` +11. ``` + segmented_devector(const segmented_devector& other); + ``` +12. ``` + segmented_devector(const segmented_devector& other, const Allocator& alloc); + ``` -**Effects:** -Copy constructor. -Constructs the container with the copy of the contents of `other`. + **Effects:** + Copy constructor. + Constructs the container with the copy of the contents of `other`. -**Complexity:** -Linear in `other.size()`. + **Complexity:** + Linear in `other.size()`. -

+

-``` -segmented_devector(segmented_devector&& other); -``` -``` -segmented_devector(segmented_devector&& other, const Allocator& alloc); -``` +13. ``` + segmented_devector(segmented_devector&& other); + ``` +14. ``` + segmented_devector(segmented_devector&& other, const Allocator& alloc); + ``` -**Effects:** -Move constructor. -Constructs the container with the contents of `other` using move semantics. + **Effects:** + Move constructor. + Constructs the container with the contents of `other` using move semantics. -* First overload: - * `other` is guaranteed to be empty after the move. -* Second overload: - * `other` is not guaranteed to be empty after the move. - * `other` is in a valid but unspecified state after the move. + * Overload (13): + * `other` is guaranteed to be empty after the move. + * Overload (14): + * `other` is not guaranteed to be empty after the move. + * `other` is in a valid but unspecified state after the move. -**Complexity:** + **Complexity:** -* First overload: Constant. -* Second overload: Constant if `alloc == other.get_alloc()`, otherwise linear. + * Overload (13): Constant. + * Overload (14): Constant if `alloc == other.get_alloc()`, otherwise linear. -

+

### (destructor) -``` -~segmented_devector(); -``` +1. ``` + ~segmented_devector(); + ``` -**Effects:** -Destructs the container. The destructors of the elements are called and the used storage is deallocated. + **Effects:** + Destructs the container. The destructors of the elements are called and the used storage is deallocated. -**Complexity:** -Linear in `size()`. + **Complexity:** + Linear in `size()`. -

+

### assign -``` -void assign(size_type n, const T& value); -``` +1. ``` + void assign(size_type n, const T& value); + ``` -**Effects:** -Replaces the contents of the container with `n` copies of value `value`. + **Effects:** + Replaces the contents of the container with `n` copies of value `value`. -**Complexity:** -Linear in `n`. + **Complexity:** + Linear in `n`. -

+

-``` -template -void assign(InputIt first, InputIt last); -``` +2. ``` + template + void assign(InputIt first, InputIt last); + ``` -**Effects:** -Replaces the contents of the container with the contents of the range `[first, last)`. + **Effects:** + Replaces the contents of the container with the contents of the range `[first, last)`. -**Note:** -This overload participates in overload resolution only if `InputIt` satisfies requirements of [*LegacyInputIterator*](https://en.cppreference.com/w/cpp/named_req/InputIterator). + **Note:** + This overload participates in overload resolution only if `InputIt` satisfies requirements of [*LegacyInputIterator*](https://en.cppreference.com/w/cpp/named_req/InputIterator). -**Note:** -The behavior is undefined if either `first` or `last` is an iterator into `*this`. + **Note:** + The behavior is undefined if either `first` or `last` is an iterator into `*this`. -**Complexity:** -Linear in `std::distance(first, last)`. + **Complexity:** + Linear in `std::distance(first, last)`. -

+

-``` -void assign(std::initializer_list ilist); -``` +3. ``` + void assign(std::initializer_list ilist); + ``` -**Effects:** -Replaces the contents of the container with the contents of the initializer list `ilist`. + **Effects:** + Replaces the contents of the container with the contents of the initializer list `ilist`. -**Complexity:** -Linear in `ilist.size()`. + **Complexity:** + Linear in `ilist.size()`. -

+

### operator= -``` -segmented_devector& operator=(const segmented_devector& other); -``` +1. ``` + segmented_devector& operator=(const segmented_devector& other); + ``` -**Effects:** -Copy assignment operator. -Replaces the contents with a copy of the contents of `other`. + **Effects:** + Copy assignment operator. + Replaces the contents with a copy of the contents of `other`. -**Returns:** -`*this`. + **Returns:** + `*this`. -

+

-``` -segmented_devector& operator=(segmented_devector&& other); -``` +2. ``` + segmented_devector& operator=(segmented_devector&& other); + ``` -**Effects:** -Move assignment operator. -Replaces the contents with those of `other` using move semantics. + **Effects:** + Move assignment operator. + Replaces the contents with those of `other` using move semantics. -`other` is not guaranteed to be empty after the move. + `other` is not guaranteed to be empty after the move. -`other` is in a valid but unspecified state after the move. + `other` is in a valid but unspecified state after the move. -**Returns:** -`*this`. + **Returns:** + `*this`. -

+

-``` -segmented_devector& operator=(std::initializer_list ilist); -``` +3. ``` + segmented_devector& operator=(std::initializer_list ilist); + ``` -**Effects:** -Replaces the contents with those identified by initializer list `ilist`. + **Effects:** + Replaces the contents with those identified by initializer list `ilist`. -**Returns:** -`*this`. + **Returns:** + `*this`. -

+

### get_allocator -``` -allocator_type get_allocator() const noexcept; -``` +1. ``` + allocator_type get_allocator() const noexcept; + ``` -**Effects:** -Returns the allocator associated with the container. + **Effects:** + Returns the allocator associated with the container. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

### begin, cbegin -``` -iterator begin() noexcept; -``` -``` -const_iterator begin() const noexcept; -``` -``` -const_iterator cbegin() const noexcept; -``` - -**Effects:** -Returns an iterator to the first element of the container. +1. ``` + iterator begin() noexcept; + ``` +2. ``` + const_iterator begin() const noexcept; + ``` +3. ``` + const_iterator cbegin() const noexcept; + ``` -If the container is empty, the returned iterator will be equal to `end()`. + **Effects:** + Returns an iterator to the first element of the container. + If the container is empty, the returned iterator will be equal to `end()`. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

### end, cend -``` -iterator end() noexcept; -``` -``` -const_iterator end() const noexcept; -``` -``` -const_iterator cend() const noexcept; -``` - -**Effects:** -Returns an iterator to the element following the last element of the container. +1. ``` + iterator end() noexcept; + ``` +2. ``` + const_iterator end() const noexcept; + ``` +3. ``` + const_iterator cend() const noexcept; + ``` -This element acts as a placeholder; attempting to access it results in undefined behavior. + **Effects:** + Returns an iterator to the element following the last element of the container. + This element acts as a placeholder; attempting to access it results in undefined behavior. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

### rbegin, crbegin -``` -reverse_iterator rbegin() noexcept; -``` -``` -const_reverse_iterator rbegin() const noexcept; -``` -``` -const_reverse_iterator crbegin() const noexcept; -``` +1. ``` + reverse_iterator rbegin() noexcept; + ``` +2. ``` + const_reverse_iterator rbegin() const noexcept; + ``` +3. ``` + const_reverse_iterator crbegin() const noexcept; + ``` -**Effects:** -Returns a reverse iterator to the first element of the reversed container. -It corresponds to the last element of the non-reversed container. -If the container is empty, the returned iterator is equal to `rend()`. + **Effects:** + Returns a reverse iterator to the first element of the reversed container. + It corresponds to the last element of the non-reversed container. + If the container is empty, the returned iterator is equal to `rend()`. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

### rend, crend -``` -reverse_iterator rend() noexcept; -``` -``` -const_reverse_iterator rend() const noexcept; -``` -``` -const_reverse_iterator crend() const noexcept; -``` +1. ``` + reverse_iterator rend() noexcept; + ``` +2. ``` + const_reverse_iterator rend() const noexcept; + ``` +3. ``` + const_reverse_iterator crend() const noexcept; + ``` -**Effects:** -Returns a reverse iterator to the element following the last element of the reversed container. -It corresponds to the element preceding the first element of the non-reversed container. -This element acts as a placeholder, attempting to access it results in undefined behavior. + **Effects:** + Returns a reverse iterator to the element following the last element of the reversed container. + It corresponds to the element preceding the first element of the non-reversed container. + This element acts as a placeholder, attempting to access it results in undefined behavior. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

### nth -``` -iterator nth(size_type pos) noexcept; -``` -``` -const_iterator nth(size_type pos) const noexcept; -``` +1. ``` + iterator nth(size_type pos) noexcept; + ``` +2. ``` + const_iterator nth(size_type pos) const noexcept; + ``` -**Preconditions:** -`pos <= size()` + **Preconditions:** + `pos <= size()` -**Effects:** -Returns an iterator to the element at position `pos`. -If `pos == size()`, the returned iterator is equal to `end()`. + **Effects:** + Returns an iterator to the element at position `pos`. -**Complexity:** -Constant. + If `pos == size()`, the returned iterator is equal to `end()`. -

+ **Complexity:** + Constant. + +

### index_of -``` -size_type index_of(const_iterator pos) const noexcept; -``` +1. ``` + size_type index_of(const_iterator pos) const noexcept; + ``` -**Preconditions:** -`cbegin() <= pos && pos <= cend()` + **Preconditions:** + `cbegin() <= pos && pos <= cend()` -**Effects:** -Returns position of the element pointed by iterator `pos`, i.e. `std::distance(begin(), pos)`. + **Effects:** + Returns position of the element pointed by iterator `pos`, i.e. `std::distance(begin(), pos)`. -If `pos == end()`, the returned value is equal to `size()`. + If `pos == end()`, the returned value is equal to `size()`. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

### empty -``` -bool empty() const noexcept; -``` +1. ``` + bool empty() const noexcept; + ``` -**Effects:** -Returns `true` if the container has no elements, i.e. whether `begin() == end()`. + **Effects:** + Returns `true` if the container has no elements, i.e. whether `begin() == end()`. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

### size -``` -size_type size() const noexcept; -``` +1. ``` + size_type size() const noexcept; + ``` -**Effects:** -Returns the number of elements in the container, i.e. `std::distance(begin(), end())`. + **Effects:** + Returns the number of elements in the container, i.e. `std::distance(begin(), end())`. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

### max_size -``` -size_type max_size() const noexcept; -``` +1. ``` + size_type max_size() const noexcept; + ``` -**Effects:** -Returns the maximum number of elements the container is able to hold, i.e. `std::distance(begin(), end())` for the largest container. + **Effects:** + Returns the maximum number of elements the container is able to hold, i.e. `std::distance(begin(), end())` for the largest container. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

### capacity -``` -size_type capacity() const noexcept; -``` +1. ``` + size_type capacity() const noexcept; + ``` -**Effects:** -Returns the number of elements that the container has currently allocated space for. + **Effects:** + Returns the number of elements that the container has currently allocated space for. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

### available_front -``` -size_type available() const noexcept; -``` +1. ``` + size_type available() const noexcept; + ``` -**Effects:** -Returns the number of elements that can be pushed to the front without requiring allocation of additional memory. + **Effects:** + Returns the number of elements that can be pushed to the front without requiring allocation of additional memory. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

### available_back -``` -size_type available() const noexcept; -``` +1. ``` + size_type available() const noexcept; + ``` -**Effects:** -Returns the number of elements that can be pushed to the back without requiring allocation of additional memory. + **Effects:** + Returns the number of elements that can be pushed to the back without requiring allocation of additional memory. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

### reserve_front -``` -void reserve_front(size_type new_capacity); -``` +1. ``` + void reserve_front(size_type new_capacity); + ``` -**Effects:** -Ensures that `n` elements can be pushed to the front without requiring allocation of additional memory, where `n` is `new_capacity - size()`. Otherwise, there are no effects. + **Effects:** + Ensures that `n` elements can be pushed to the front without requiring allocation of additional memory, where `n` is `new_capacity - size()`. Otherwise, there are no effects. -This function does not change size of the container. + This function does not change size of the container. -If the capacity is changed, all iterators to the elements are invalidated, but references and pointers to elements remain valid. Otherwise, no iterators or references are invalidated. + If the capacity is changed, all iterators to the elements are invalidated, but references and pointers to elements remain valid. Otherwise, no iterators or references are invalidated. -

+

### reserve_back -``` -void reserve_back(size_type new_capacity); -``` +1. ``` + void reserve_back(size_type new_capacity); + ``` -**Effects:** -Ensures that `n` elements can be pushed to the back without requiring allocation of additional memory, where `n` is `new_capacity - size()`. Otherwise, there are no effects. + **Effects:** + Ensures that `n` elements can be pushed to the back without requiring allocation of additional memory, where `n` is `new_capacity - size()`. Otherwise, there are no effects. -This function does not change size of the container. + This function does not change size of the container. -If the capacity is changed, all iterators to the elements are invalidated, but references and pointers to elements remain valid. Otherwise, no iterators or references are invalidated. + If the capacity is changed, all iterators to the elements are invalidated, but references and pointers to elements remain valid. Otherwise, no iterators or references are invalidated. -

+

### shrink_to_fit -``` -void shrink_to_fit(); -``` +1. ``` + void shrink_to_fit(); + ``` -**Effects:** -Tries to reduce memory usage by freeing unused memory. + **Effects:** + Tries to reduce memory usage by freeing unused memory. -This function does not change size of the container. + This function does not change size of the container. -If the capacity is changed, all iterators to the elements are invalidated, but references and pointers to elements remain valid. Otherwise, no iterators or references are invalidated. + If the capacity is changed, all iterators to the elements are invalidated, but references and pointers to elements remain valid. Otherwise, no iterators or references are invalidated. -

+

### at -``` -reference at(size_type pos); -``` -``` -const_reference at(size_type pos) const; -``` +1. ``` + reference at(size_type pos); + ``` +2. ``` + const_reference at(size_type pos) const; + ``` -**Effects:** -Returns a reference to the element at specified location `pos`, with bounds checking. + **Effects:** + Returns a reference to the element at specified location `pos`, with bounds checking. -**Complexity:** -Constant. + **Complexity:** + Constant. -**Exceptions:** -`std::out_of_range` if `pos >= size()`. + **Exceptions:** + `std::out_of_range` if `pos >= size()`. -

+

### operator[] -``` -reference operator[](size_type pos) noexcept; -``` -``` -const_reference operator[](size_type pos) const noexcept; -``` +1. ``` + reference operator[](size_type pos) noexcept; + ``` +2. ``` + const_reference operator[](size_type pos) const noexcept; + ``` -**Preconditions:** -`pos < size()` + **Preconditions:** + `pos < size()` -**Effects:** -Returns a reference to the element at specified location pos. No bounds checking is performed. + **Effects:** + Returns a reference to the element at specified location pos. No bounds checking is performed. -**Note:** -This operator never inserts a new element into the container. + **Note:** + This operator never inserts a new element into the container. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

### front -``` -reference front() noexcept; -``` -``` -const_reference front() const noexcept; -``` +1. ``` + reference front() noexcept; + ``` +2. ``` + const_reference front() const noexcept; + ``` -**Preconditions:** -`!empty()` + **Preconditions:** + `!empty()` -**Effects:** -Returns a reference to the first element in the container. + **Effects:** + Returns a reference to the first element in the container. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

### back -``` -reference back() noexcept; -``` -``` -const_reference back() const noexcept; -``` +1. ``` + reference back() noexcept; + ``` +2. ``` + const_reference back() const noexcept; + ``` -**Preconditions:** -`!empty()` + **Preconditions:** + `!empty()` -**Effects:** -Returns a reference to the last element in the container. + **Effects:** + Returns a reference to the last element in the container. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

### clear -``` -void clear() noexcept; -``` +1. ``` + void clear() noexcept; + ``` -**Effects:** -Erases all elements from the container. -After this call, `size()` returns zero and `capacity()` remains unchanged. + **Effects:** + Erases all elements from the container. + After this call, `size()` returns zero and `capacity()` remains unchanged. -**Complexity:** -Linear in `size()`. + **Complexity:** + Linear in `size()`. -

+

### emplace -``` -template -iterator emplace(const_iterator pos, Args&&... args); -``` +1. ``` + template + iterator emplace(const_iterator pos, Args&&... args); + ``` -**Preconditions:** -`cbegin() <= pos && pos <= cend()` + **Preconditions:** + `cbegin() <= pos && pos <= cend()` -**Effects:** -Inserts a new element into the container at position `pos`. + **Effects:** + Inserts a new element into the container at position `pos`. -New element is constructed as `value_type(std::forward(args)...)`. + New element is constructed as `value_type(std::forward(args)...)`. -`args...` may directly or indirectly refer to a value in the container. + `args...` may directly or indirectly refer to a value in the container. -**Returns:** -Iterator to the inserted element. + **Returns:** + Iterator to the inserted element. -**Complexity:** -Constant plus linear in `std::min(std::distance(begin(), pos), std::distance(pos, end()))`. + **Complexity:** + Constant plus linear in `std::min(std::distance(begin(), pos), std::distance(pos, end()))`. -

+

### insert -``` -iterator insert(const_iterator pos, const T& value); -``` +1. ``` + iterator insert(const_iterator pos, const T& value); + ``` -**Preconditions:** -`cbegin() <= pos && pos <= cend()` + **Preconditions:** + `cbegin() <= pos && pos <= cend()` -**Effects:** -Inserts copy of `value` at position `pos`. + **Effects:** + Inserts copy of `value` at position `pos`. -**Returns:** -Iterator to the inserted element. + **Returns:** + Iterator to the inserted element. -**Complexity:** -Constant plus linear in `std::min(std::distance(begin(), pos), std::distance(pos, end()))`. + **Complexity:** + Constant plus linear in `std::min(std::distance(begin(), pos), std::distance(pos, end()))`. -

+

-``` -iterator insert(const_iterator pos, T&& value); -``` +2. ``` + iterator insert(const_iterator pos, T&& value); + ``` -**Preconditions:** -`cbegin() <= pos && pos <= cend()` + **Preconditions:** + `cbegin() <= pos && pos <= cend()` -**Effects:** -Inserts `value` using move semantics at position `pos`. + **Effects:** + Inserts `value` using move semantics at position `pos`. -**Returns:** -Iterator to the inserted element. + **Returns:** + Iterator to the inserted element. -**Complexity:** -Constant plus linear in `std::min(std::distance(begin(), pos), std::distance(pos, end()))`. + **Complexity:** + Constant plus linear in `std::min(std::distance(begin(), pos), std::distance(pos, end()))`. -

+

-``` -iterator insert(const_iterator pos, size_type n, const T& value); -``` +3. ``` + iterator insert(const_iterator pos, size_type n, const T& value); + ``` -**Preconditions:** -`cbegin() <= pos && pos <= cend()` + **Preconditions:** + `cbegin() <= pos && pos <= cend()` -**Effects:** -Inserts `n` copies of `value` before position `pos`. + **Effects:** + Inserts `n` copies of `value` before position `pos`. -**Returns:** -Iterator to the first element inserted, or `pos` if `n == 0`. + **Returns:** + Iterator to the first element inserted, or `pos` if `n == 0`. -**Complexity:** -Linear in `n` plus linear in `std::min(std::distance(begin(), pos), std::distance(pos, end()))`. + **Complexity:** + Linear in `n` plus linear in `std::min(std::distance(begin(), pos), std::distance(pos, end()))`. -

+

-``` -template -iterator insert(const_iterator pos, InputIt first, InputIt last); -``` +4. ``` + template + iterator insert(const_iterator pos, InputIt first, InputIt last); + ``` -**Preconditions:** -`cbegin() <= pos && pos <= cend()` + **Preconditions:** + `cbegin() <= pos && pos <= cend()` -**Effects:** -Inserts elements from the range `[first, last)` before position `pos`. + **Effects:** + Inserts elements from the range `[first, last)` before position `pos`. -**Note:** -This overload participates in overload resolution only if `InputIt` satisfies requirements of [*LegacyInputIterator*](https://en.cppreference.com/w/cpp/named_req/InputIterator). + **Note:** + This overload participates in overload resolution only if `InputIt` satisfies requirements of [*LegacyInputIterator*](https://en.cppreference.com/w/cpp/named_req/InputIterator). -**Note:** -The behavior is undefined if either `first` or `last` is an iterator into `*this`. + **Note:** + The behavior is undefined if either `first` or `last` is an iterator into `*this`. -**Returns:** -Iterator to the first element inserted, or `pos` if `first == last`. + **Returns:** + Iterator to the first element inserted, or `pos` if `first == last`. -**Complexity:** -Linear in `std::distance(first, last)` plus linear in `std::min(std::distance(begin(), pos), std::distance(pos, end()))`. + **Complexity:** + Linear in `std::distance(first, last)` plus linear in `std::min(std::distance(begin(), pos), std::distance(pos, end()))`. -

+

-``` -iterator insert(const_iterator pos, std::initializer_list ilist); -``` +5. ``` + iterator insert(const_iterator pos, std::initializer_list ilist); + ``` -**Preconditions:** -`cbegin() <= pos && pos <= cend()` + **Preconditions:** + `cbegin() <= pos && pos <= cend()` -**Effects:** -Inserts elements from initializer list `ilist` before position `pos`. + **Effects:** + Inserts elements from initializer list `ilist` before position `pos`. -**Returns:** -Iterator to the first element inserted, or `pos` if `ilist` is empty. + **Returns:** + Iterator to the first element inserted, or `pos` if `ilist` is empty. -**Complexity:** -Linear in `ilist.size()` plus linear in `std::min(std::distance(begin(), pos), std::distance(pos, end()))`. + **Complexity:** + Linear in `ilist.size()` plus linear in `std::min(std::distance(begin(), pos), std::distance(pos, end()))`. -

+

### emplace_front -``` -template -reference emplace_front(Args&&... args); -``` +1. ``` + template + reference emplace_front(Args&&... args); + ``` -**Effects:** -Inserts a new element at the beginning of container. + **Effects:** + Inserts a new element at the beginning of container. -New element is constructed as `value_type(std::forward(args)...)`. + New element is constructed as `value_type(std::forward(args)...)`. -**Returns:** -Reference to the inserted element. + **Returns:** + Reference to the inserted element. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

### emplace_back -``` -template -reference emplace_back(Args&&... args); -``` +1. ``` + template + reference emplace_back(Args&&... args); + ``` -**Effects:** -Inserts a new element at the end of container. + **Effects:** + Inserts a new element at the end of container. -New element is constructed as `value_type(std::forward(args)...)`. + New element is constructed as `value_type(std::forward(args)...)`. -**Returns:** -Reference to the inserted element. + **Returns:** + Reference to the inserted element. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

### push_front -``` -void push_front(const T& value); -``` +1. ``` + void push_front(const T& value); + ``` -**Effects:** -Inserts copy of `value` at the beginning of container. + **Effects:** + Inserts copy of `value` at the beginning of container. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

-``` -void push_front(T&& value); -``` +2. ``` + void push_front(T&& value); + ``` -**Effects:** -Inserts `value` using move semantics at the beginning of container. + **Effects:** + Inserts `value` using move semantics at the beginning of container. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

### push_back -``` -void push_back(const T& value); -``` +1. ``` + void push_back(const T& value); + ``` -**Effects:** -Inserts copy of `value` at the end of container. + **Effects:** + Inserts copy of `value` at the end of container. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

-``` -void push_back(T&& value); -``` +2. ``` + void push_back(T&& value); + ``` -**Effects:** -Inserts `value` using move semantics at the end of container. + **Effects:** + Inserts `value` using move semantics at the end of container. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

### pop_front -``` -void pop_front(); -``` +1. ``` + void pop_front(); + ``` -**Preconditions:** -`!empty()` + **Preconditions:** + `!empty()` -**Effects:** -Removes the first element of the container. + **Effects:** + Removes the first element of the container. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

### pop_back -``` -void pop_back(); -``` +1. ``` + void pop_back(); + ``` -**Preconditions:** -`!empty()` + **Preconditions:** + `!empty()` -**Effects:** -Removes the last element of the container. + **Effects:** + Removes the last element of the container. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

### erase -``` -iterator erase(const_iterator pos); -``` +1. ``` + iterator erase(const_iterator pos); + ``` -**Preconditions:** -`cbegin() <= pos && pos < cend()` + **Preconditions:** + `cbegin() <= pos && pos < cend()` -**Effects:** -Removes the element at `pos`. + **Effects:** + Removes the element at `pos`. -**Returns:** -Iterator following the last removed element. + **Returns:** + Iterator following the last removed element. -If `pos` refers to the last element, then the `end()` iterator is returned. + If `pos` refers to the last element, then the `end()` iterator is returned. -

+

-``` -iterator erase(const_iterator first, const_iterator last); -``` +2. ``` + iterator erase(const_iterator first, const_iterator last); + ``` -**Preconditions:** -`cbegin() <= first && first <= last && last <= cend()` + **Preconditions:** + `cbegin() <= first && first <= last && last <= cend()` -**Effects:** -Removes the elements in the range `[first, last)`. + **Effects:** + Removes the elements in the range `[first, last)`. -**Returns:** -Iterator following the last removed element. + **Returns:** + Iterator following the last removed element. -If `last == end()` prior to removal, then the updated `end()` iterator is returned. + If `last == end()` prior to removal, then the updated `end()` iterator is returned. -If `[first, last)` is an empty range, then `last` is returned. + If `[first, last)` is an empty range, then `last` is returned. -

+

### resize -``` -void resize(size_type n); -``` +1. ``` + void resize(size_type n); + ``` -**Effects:** -Resizes the container to contain `n` elements. + **Effects:** + Resizes the container to contain `n` elements. -1. If the `size() > n`, the last `size() - n` elements are removed. -2. If the `size() < n`, additional default-constructed elements are inserted into container. Additional elements could be inserted both at the beginning and at the end of container. + 1. If the `size() > n`, the last `size() - n` elements are removed. + 2. If the `size() < n`, additional default-constructed elements are inserted into container. Additional elements could be inserted both at the beginning and at the end of container. -

+

-``` -void resize(size_type n, const T& value); -``` +2. ``` + void resize(size_type n, const T& value); + ``` -**Effects:** -Resizes the container to contain `n` elements. + **Effects:** + Resizes the container to contain `n` elements. -1. If the `size() > n`, the last `size() - n` elements are removed. -2. If the `size() < n`, additional copies of `value` are inserted into container. Additional elements could be inserted both at the beginning and at the end of container. + 1. If the `size() > n`, the last `size() - n` elements are removed. + 2. If the `size() < n`, additional copies of `value` are inserted into container. Additional elements could be inserted both at the beginning and at the end of container. -

+

### resize_front -``` -void resize_front(size_type n); -``` +1. ``` + void resize_front(size_type n); + ``` -**Effects:** -Resizes the container to contain `n` elements. + **Effects:** + Resizes the container to contain `n` elements. -1. If the `size() > n`, the first `size() - n` elements are removed. -2. If the `size() < n`, additional default-constructed elements are inserted at the beginning of container. + 1. If the `size() > n`, the first `size() - n` elements are removed. + 2. If the `size() < n`, additional default-constructed elements are inserted at the beginning of container. -

+

-``` -void resize_front(size_type n, const T& value); -``` +2. ``` + void resize_front(size_type n, const T& value); + ``` -**Effects:** -Resizes the container to contain `n` elements. + **Effects:** + Resizes the container to contain `n` elements. -1. If the `size() > n`, the first `size() - n` elements are removed. -2. If the `size() < n`, additional copies of `value` are inserted at the beginning of container. + 1. If the `size() > n`, the first `size() - n` elements are removed. + 2. If the `size() < n`, additional copies of `value` are inserted at the beginning of container. -

+

### resize_back -``` -void resize_back(size_type n); -``` +1. ``` + void resize_back(size_type n); + ``` -**Effects:** -Resizes the container to contain `n` elements. + **Effects:** + Resizes the container to contain `n` elements. -1. If the `size() > n`, the last `size() - n` elements are removed. -2. If the `size() < n`, additional default-constructed elements are inserted at the end of container. + 1. If the `size() > n`, the last `size() - n` elements are removed. + 2. If the `size() < n`, additional default-constructed elements are inserted at the end of container. -

+

-``` -void resize_back(size_type n, const T& value); -``` +2. ``` + void resize_back(size_type n, const T& value); + ``` -**Effects:** -Resizes the container to contain `n` elements. + **Effects:** + Resizes the container to contain `n` elements. -1. If the `size() > n`, the last `size() - n` elements are removed. -2. If the `size() < n`, additional copies of `value` are inserted at the end of container. + 1. If the `size() > n`, the last `size() - n` elements are removed. + 2. If the `size() < n`, additional copies of `value` are inserted at the end of container. -

+

### swap -``` -void swap(segmented_devector& other) noexcept; -``` +1. ``` + void swap(segmented_devector& other) noexcept; + ``` -**Preconditions:** -`allocator_traits::propagate_on_container_swap::value || get_allocator() == other.get_allocator()` + **Preconditions:** + `allocator_traits::propagate_on_container_swap::value || get_allocator() == other.get_allocator()` -**Effects:** -Exchanges the contents of the container with those of `other`. + **Effects:** + Exchanges the contents of the container with those of `other`. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

@@ -1257,217 +1256,217 @@ Constant. ### operator== -``` -template -bool operator== -( - const segmented_devector& x, - const segmented_devector& y -); -``` +1. ``` + template + bool operator== + ( + const segmented_devector& x, + const segmented_devector& y + ); + ``` -**Effects:** -Checks if the contents of `x` and `y` are equal. + **Effects:** + Checks if the contents of `x` and `y` are equal. -The contents of `x` and `y` are equal if the following conditions hold: -* `x.size() == y.size()` -* Each element in `x` compares equal with the element in `y` at the same position. + The contents of `x` and `y` are equal if the following conditions hold: + * `x.size() == y.size()` + * Each element in `x` compares equal with the element in `y` at the same position. -**Returns:** -`true` if the contents of the `x` and `y` are equal, `false` otherwise. + **Returns:** + `true` if the contents of the `x` and `y` are equal, `false` otherwise. -**Complexity:** -Constant if `x` and `y` are of different size, otherwise linear in the size of the container. + **Complexity:** + Constant if `x` and `y` are of different size, otherwise linear in the size of the container. -

+

### operator!= -``` -template -bool operator!= -( - const segmented_devector& x, - const segmented_devector& y -); -``` +1. ``` + template + bool operator!= + ( + const segmented_devector& x, + const segmented_devector& y + ); + ``` -**Effects:** -Checks if the contents of `x` and `y` are equal. + **Effects:** + Checks if the contents of `x` and `y` are equal. -For details see `operator==`. + For details see `operator==`. -**Returns:** -`true` if the contents of the `x` and `y` are not equal, `false` otherwise. + **Returns:** + `true` if the contents of the `x` and `y` are not equal, `false` otherwise. -**Complexity:** -Constant if `x` and `y` are of different size, otherwise linear in the size of the container. + **Complexity:** + Constant if `x` and `y` are of different size, otherwise linear in the size of the container. -

+

### operator< -``` -template -bool operator< -( - const segmented_devector& x, - const segmented_devector& y -); -``` +1. ``` + template + bool operator< + ( + const segmented_devector& x, + const segmented_devector& y + ); + ``` -**Effects:** -Compares the contents of `x` and `y` lexicographically. -The comparison is performed by a function `std::lexicographical_compare`. + **Effects:** + Compares the contents of `x` and `y` lexicographically. + The comparison is performed by a function `std::lexicographical_compare`. -**Returns:** -`true` if the contents of the `x` are lexicographically less than the contents of `y`, `false` otherwise. + **Returns:** + `true` if the contents of the `x` are lexicographically less than the contents of `y`, `false` otherwise. -**Complexity:** -Linear in the size of the container. + **Complexity:** + Linear in the size of the container. -

+

### operator> -``` -template -bool operator> -( - const segmented_devector& x, - const segmented_devector& y -); -``` +1. ``` + template + bool operator> + ( + const segmented_devector& x, + const segmented_devector& y + ); + ``` -**Effects:** -Compares the contents of `x` and `y` lexicographically. -The comparison is performed by a function `std::lexicographical_compare`. + **Effects:** + Compares the contents of `x` and `y` lexicographically. + The comparison is performed by a function `std::lexicographical_compare`. -**Returns:** -`true` if the contents of the `x` are lexicographically greater than the contents of `y`, `false` otherwise. + **Returns:** + `true` if the contents of the `x` are lexicographically greater than the contents of `y`, `false` otherwise. -**Complexity:** -Linear in the size of the container. + **Complexity:** + Linear in the size of the container. -

+

### operator<= -``` -template -bool operator<= -( - const segmented_devector& x, - const segmented_devector& y -); -``` +1. ``` + template + bool operator<= + ( + const segmented_devector& x, + const segmented_devector& y + ); + ``` -**Effects:** -Compares the contents of `x` and `y` lexicographically. -The comparison is performed by a function `std::lexicographical_compare`. + **Effects:** + Compares the contents of `x` and `y` lexicographically. + The comparison is performed by a function `std::lexicographical_compare`. -**Returns:** -`true` if the contents of the `x` are lexicographically less than or equal to the contents of `y`, `false` otherwise. + **Returns:** + `true` if the contents of the `x` are lexicographically less than or equal to the contents of `y`, `false` otherwise. -**Complexity:** -Linear in the size of the container. + **Complexity:** + Linear in the size of the container. -

+

### operator>= -``` -template -bool operator>= -( - const segmented_devector& x, - const segmented_devector& y -); -``` +1. ``` + template + bool operator>= + ( + const segmented_devector& x, + const segmented_devector& y + ); + ``` -**Effects:** -Compares the contents of `x` and `y` lexicographically. -The comparison is performed by a function `std::lexicographical_compare`. + **Effects:** + Compares the contents of `x` and `y` lexicographically. + The comparison is performed by a function `std::lexicographical_compare`. -**Returns:** -`true` if the contents of the `x` are lexicographically greater than or equal to the contents of `y`, `false` otherwise. + **Returns:** + `true` if the contents of the `x` are lexicographically greater than or equal to the contents of `y`, `false` otherwise. -**Complexity:** -Linear in the size of the container. + **Complexity:** + Linear in the size of the container. -

+

### swap -``` -template -void swap -( - segmented_devector& x, - segmented_devector& y -); -``` +1. ``` + template + void swap + ( + segmented_devector& x, + segmented_devector& y + ); + ``` -**Effects:** -Swaps the contents of `x` and `y`. Calls `x.swap(y)`. + **Effects:** + Swaps the contents of `x` and `y`. Calls `x.swap(y)`. -

+

### erase -``` -template -typename segmented_devector::size_type - erase(segmented_devector& c, const U& value); -``` +1. ``` + template + typename segmented_devector::size_type + erase(segmented_devector& c, const U& value); + ``` -**Effects:** -Erases all elements that compare equal to `value` from the container. + **Effects:** + Erases all elements that compare equal to `value` from the container. -**Returns:** -The number of erased elements. + **Returns:** + The number of erased elements. -**Complexity:** -Linear. + **Complexity:** + Linear. -

+

### erase_if -``` -template -typename segmented_devector::size_type - erase_if(segmented_devector& c, Predicate pred); -``` +1. ``` + template + typename segmented_devector::size_type + erase_if(segmented_devector& c, Predicate pred); + ``` -**Effects:** -Erases all elements that satisfy the predicate `pred` from the container. + **Effects:** + Erases all elements that satisfy the predicate `pred` from the container. -`pred` is unary predicate which returns `true` if the element should be removed. + `pred` is unary predicate which returns `true` if the element should be removed. -**Returns:** -The number of erased elements. + **Returns:** + The number of erased elements. -**Complexity:** -Linear. + **Complexity:** + Linear. -

+

diff --git a/doc/segmented_vector.md b/doc/segmented_vector.md index 212eda4..6f5773b 100644 --- a/doc/segmented_vector.md +++ b/doc/segmented_vector.md @@ -101,9 +101,9 @@ Key differences between `segmented_vector` and `segmented_devector`: std::size_t N ``` - The size of the segments, i.e. the maximal number of elements that can fit into a segment. + Segment size, i.e. the maximal number of elements that can fit into a segment. - Must be greater than zero. + This parameter must be greater than zero. 3. ``` typename Allocator @@ -155,932 +155,931 @@ static constexpr size_type segment_capacity = N; ### (constructor) -``` -segmented_vector(); -``` -``` -explicit segmented_vector(const Allocator& alloc); -``` +1. ``` + segmented_vector(); + ``` +2. ``` + explicit segmented_vector(const Allocator& alloc); + ``` -**Effects:** -Constructs an empty container. + **Effects:** + Constructs an empty container. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

-``` -segmented_vector(size_type n); -``` -``` -explicit segmented_vector(size_type n, const Allocator& alloc); -``` +3. ``` + segmented_vector(size_type n); + ``` +4. ``` + explicit segmented_vector(size_type n, const Allocator& alloc); + ``` -**Effects:** -Constructs the container with `n` default-constructed elements. + **Effects:** + Constructs the container with `n` default-constructed elements. -**Complexity:** -Linear in `n`. + **Complexity:** + Linear in `n`. -

+

-``` -segmented_vector(size_type n, const T& value); -``` -``` -segmented_vector(size_type n, const T& value, const Allocator& alloc); -``` +5. ``` + segmented_vector(size_type n, const T& value); + ``` +6. ``` + segmented_vector(size_type n, const T& value, const Allocator& alloc); + ``` -**Effects:** -Constructs the container with `n` copies of elements with value `value`. + **Effects:** + Constructs the container with `n` copies of elements with value `value`. -**Complexity:** -Linear in `n`. + **Complexity:** + Linear in `n`. -

+

-``` -template -segmented_vector(InputIt first, InputIt last); -``` -``` -template -segmented_vector(InputIt first, InputIt last, const Allocator& alloc); -``` +7. ``` + template + segmented_vector(InputIt first, InputIt last); + ``` +8. ``` + template + segmented_vector(InputIt first, InputIt last, const Allocator& alloc); + ``` -**Effects:** -Constructs the container with the contents of the range `[first, last)`. + **Effects:** + Constructs the container with the contents of the range `[first, last)`. -**Note:** -This overload participates in overload resolution only if `InputIt` satisfies requirements of [*LegacyInputIterator*](https://en.cppreference.com/w/cpp/named_req/InputIterator). + **Note:** + This overload participates in overload resolution only if `InputIt` satisfies requirements of [*LegacyInputIterator*](https://en.cppreference.com/w/cpp/named_req/InputIterator). -**Complexity:** -Linear in `std::distance(first, last)`. + **Complexity:** + Linear in `std::distance(first, last)`. -

+

-``` -segmented_vector(std::initializer_list ilist); -``` -``` -segmented_vector(std::initializer_list ilist, const Allocator& alloc); -``` +9. ``` + segmented_vector(std::initializer_list ilist); + ``` +10. ``` + segmented_vector(std::initializer_list ilist, const Allocator& alloc); + ``` -**Effects:** -Constructs the container with the contents of the initializer list `ilist`. + **Effects:** + Constructs the container with the contents of the initializer list `ilist`. -**Complexity:** -Linear in `ilist.size()`. + **Complexity:** + Linear in `ilist.size()`. -

+

-``` -segmented_vector(const segmented_vector& other); -``` -``` -segmented_vector(const segmented_vector& other, const Allocator& alloc); -``` +11. ``` + segmented_vector(const segmented_vector& other); + ``` +12. ``` + segmented_vector(const segmented_vector& other, const Allocator& alloc); + ``` -**Effects:** -Copy constructor. -Constructs the container with the copy of the contents of `other`. + **Effects:** + Copy constructor. + Constructs the container with the copy of the contents of `other`. -**Complexity:** -Linear in `other.size()`. + **Complexity:** + Linear in `other.size()`. -

+

-``` -segmented_vector(segmented_vector&& other); -``` -``` -segmented_vector(segmented_vector&& other, const Allocator& alloc); -``` +13. ``` + segmented_vector(segmented_vector&& other); + ``` +14. ``` + segmented_vector(segmented_vector&& other, const Allocator& alloc); + ``` -**Effects:** -Move constructor. -Constructs the container with the contents of `other` using move semantics. + **Effects:** + Move constructor. + Constructs the container with the contents of `other` using move semantics. -* First overload: - * `other` is guaranteed to be empty after the move. -* Second overload: - * `other` is not guaranteed to be empty after the move. - * `other` is in a valid but unspecified state after the move. + * Overload (13): + * `other` is guaranteed to be empty after the move. + * Overload (14): + * `other` is not guaranteed to be empty after the move. + * `other` is in a valid but unspecified state after the move. -**Complexity:** + **Complexity:** -* First overload: Constant. -* Second overload: Constant if `alloc == other.get_alloc()`, otherwise linear. + * Overload (13): Constant. + * Overload (14): Constant if `alloc == other.get_alloc()`, otherwise linear. -

+

### (destructor) -``` -~segmented_vector(); -``` +1. ``` + ~segmented_vector(); + ``` -**Effects:** -Destructs the container. The destructors of the elements are called and the used storage is deallocated. + **Effects:** + Destructs the container. The destructors of the elements are called and the used storage is deallocated. -**Complexity:** -Linear in `size()`. + **Complexity:** + Linear in `size()`. -

+

### assign -``` -void assign(size_type n, const T& value); -``` +1. ``` + void assign(size_type n, const T& value); + ``` -**Effects:** -Replaces the contents of the container with `n` copies of value `value`. + **Effects:** + Replaces the contents of the container with `n` copies of value `value`. -**Complexity:** -Linear in `n`. + **Complexity:** + Linear in `n`. -

+

-``` -template -void assign(InputIt first, InputIt last); -``` +2. ``` + template + void assign(InputIt first, InputIt last); + ``` -**Effects:** -Replaces the contents of the container with the contents of the range `[first, last)`. + **Effects:** + Replaces the contents of the container with the contents of the range `[first, last)`. -**Note:** -This overload participates in overload resolution only if `InputIt` satisfies requirements of [*LegacyInputIterator*](https://en.cppreference.com/w/cpp/named_req/InputIterator). + **Note:** + This overload participates in overload resolution only if `InputIt` satisfies requirements of [*LegacyInputIterator*](https://en.cppreference.com/w/cpp/named_req/InputIterator). -**Note:** -The behavior is undefined if either `first` or `last` is an iterator into `*this`. + **Note:** + The behavior is undefined if either `first` or `last` is an iterator into `*this`. -**Complexity:** -Linear in `std::distance(first, last)`. + **Complexity:** + Linear in `std::distance(first, last)`. -

+

-``` -void assign(std::initializer_list ilist); -``` +3. ``` + void assign(std::initializer_list ilist); + ``` -**Effects:** -Replaces the contents of the container with the contents of the initializer list `ilist`. + **Effects:** + Replaces the contents of the container with the contents of the initializer list `ilist`. -**Complexity:** -Linear in `ilist.size()`. + **Complexity:** + Linear in `ilist.size()`. -

+

### operator= -``` -segmented_vector& operator=(const segmented_vector& other); -``` +1. ``` + segmented_vector& operator=(const segmented_vector& other); + ``` -**Effects:** -Copy assignment operator. -Replaces the contents with a copy of the contents of `other`. + **Effects:** + Copy assignment operator. + Replaces the contents with a copy of the contents of `other`. -**Returns:** -`*this`. + **Returns:** + `*this`. -

+

-``` -segmented_vector& operator=(segmented_vector&& other); -``` +2. ``` + segmented_vector& operator=(segmented_vector&& other); + ``` -**Effects:** -Move assignment operator. -Replaces the contents with those of `other` using move semantics. + **Effects:** + Move assignment operator. + Replaces the contents with those of `other` using move semantics. -`other` is not guaranteed to be empty after the move. + `other` is not guaranteed to be empty after the move. -`other` is in a valid but unspecified state after the move. + `other` is in a valid but unspecified state after the move. -**Returns:** -`*this`. + **Returns:** + `*this`. -

+

-``` -segmented_vector& operator=(std::initializer_list ilist); -``` +3. ``` + segmented_vector& operator=(std::initializer_list ilist); + ``` -**Effects:** -Replaces the contents with those identified by initializer list `ilist`. + **Effects:** + Replaces the contents with those identified by initializer list `ilist`. -**Returns:** -`*this`. + **Returns:** + `*this`. -

+

### get_allocator -``` -allocator_type get_allocator() const noexcept; -``` +1. ``` + allocator_type get_allocator() const noexcept; + ``` -**Effects:** -Returns the allocator associated with the container. + **Effects:** + Returns the allocator associated with the container. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

### begin, cbegin -``` -iterator begin() noexcept; -``` -``` -const_iterator begin() const noexcept; -``` -``` -const_iterator cbegin() const noexcept; -``` - -**Effects:** -Returns an iterator to the first element of the container. +1. ``` + iterator begin() noexcept; + ``` +2. ``` + const_iterator begin() const noexcept; + ``` +3. ``` + const_iterator cbegin() const noexcept; + ``` -If the container is empty, the returned iterator will be equal to `end()`. + **Effects:** + Returns an iterator to the first element of the container. + If the container is empty, the returned iterator will be equal to `end()`. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

### end, cend -``` -iterator end() noexcept; -``` -``` -const_iterator end() const noexcept; -``` -``` -const_iterator cend() const noexcept; -``` - -**Effects:** -Returns an iterator to the element following the last element of the container. +1. ``` + iterator end() noexcept; + ``` +2. ``` + const_iterator end() const noexcept; + ``` +3. ``` + const_iterator cend() const noexcept; + ``` -This element acts as a placeholder; attempting to access it results in undefined behavior. + **Effects:** + Returns an iterator to the element following the last element of the container. + This element acts as a placeholder; attempting to access it results in undefined behavior. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

### rbegin, crbegin -``` -reverse_iterator rbegin() noexcept; -``` -``` -const_reverse_iterator rbegin() const noexcept; -``` -``` -const_reverse_iterator crbegin() const noexcept; -``` +1. ``` + reverse_iterator rbegin() noexcept; + ``` +2. ``` + const_reverse_iterator rbegin() const noexcept; + ``` +3. ``` + const_reverse_iterator crbegin() const noexcept; + ``` -**Effects:** -Returns a reverse iterator to the first element of the reversed container. -It corresponds to the last element of the non-reversed container. -If the container is empty, the returned iterator is equal to `rend()`. + **Effects:** + Returns a reverse iterator to the first element of the reversed container. + It corresponds to the last element of the non-reversed container. + If the container is empty, the returned iterator is equal to `rend()`. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

### rend, crend -``` -reverse_iterator rend() noexcept; -``` -``` -const_reverse_iterator rend() const noexcept; -``` -``` -const_reverse_iterator crend() const noexcept; -``` +1. ``` + reverse_iterator rend() noexcept; + ``` +2. ``` + const_reverse_iterator rend() const noexcept; + ``` +3. ``` + const_reverse_iterator crend() const noexcept; + ``` -**Effects:** -Returns a reverse iterator to the element following the last element of the reversed container. -It corresponds to the element preceding the first element of the non-reversed container. -This element acts as a placeholder, attempting to access it results in undefined behavior. + **Effects:** + Returns a reverse iterator to the element following the last element of the reversed container. + It corresponds to the element preceding the first element of the non-reversed container. + This element acts as a placeholder, attempting to access it results in undefined behavior. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

### nth -``` -iterator nth(size_type pos) noexcept; -``` -``` -const_iterator nth(size_type pos) const noexcept; -``` +1. ``` + iterator nth(size_type pos) noexcept; + ``` +2. ``` + const_iterator nth(size_type pos) const noexcept; + ``` -**Preconditions:** -`pos <= size()` + **Preconditions:** + `pos <= size()` -**Effects:** -Returns an iterator to the element at position `pos`. -If `pos == size()`, the returned iterator is equal to `end()`. + **Effects:** + Returns an iterator to the element at position `pos`. -**Complexity:** -Constant. + If `pos == size()`, the returned iterator is equal to `end()`. -

+ **Complexity:** + Constant. + +

### index_of -``` -size_type index_of(const_iterator pos) const noexcept; -``` +1. ``` + size_type index_of(const_iterator pos) const noexcept; + ``` -**Preconditions:** -`cbegin() <= pos && pos <= cend()` + **Preconditions:** + `cbegin() <= pos && pos <= cend()` -**Effects:** -Returns position of the element pointed by iterator `pos`, i.e. `std::distance(begin(), pos)`. + **Effects:** + Returns position of the element pointed by iterator `pos`, i.e. `std::distance(begin(), pos)`. -If `pos == end()`, the returned value is equal to `size()`. + If `pos == end()`, the returned value is equal to `size()`. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

### empty -``` -bool empty() const noexcept; -``` +1. ``` + bool empty() const noexcept; + ``` -**Effects:** -Returns `true` if the container has no elements, i.e. whether `begin() == end()`. + **Effects:** + Returns `true` if the container has no elements, i.e. whether `begin() == end()`. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

### size -``` -size_type size() const noexcept; -``` +1. ``` + size_type size() const noexcept; + ``` -**Effects:** -Returns the number of elements in the container, i.e. `std::distance(begin(), end())`. + **Effects:** + Returns the number of elements in the container, i.e. `std::distance(begin(), end())`. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

### max_size -``` -size_type max_size() const noexcept; -``` +1. ``` + size_type max_size() const noexcept; + ``` -**Effects:** -Returns the maximum number of elements the container is able to hold, i.e. `std::distance(begin(), end())` for the largest container. + **Effects:** + Returns the maximum number of elements the container is able to hold, i.e. `std::distance(begin(), end())` for the largest container. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

### capacity -``` -size_type capacity() const noexcept; -``` +1. ``` + size_type capacity() const noexcept; + ``` -**Effects:** -Returns the number of elements that the container has currently allocated space for. + **Effects:** + Returns the number of elements that the container has currently allocated space for. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

### available -``` -size_type available() const noexcept; -``` +1. ``` + size_type available() const noexcept; + ``` -**Effects:** -Returns the number of elements that can be inserted into the container without requiring allocation of additional memory. + **Effects:** + Returns the number of elements that can be inserted into the container without requiring allocation of additional memory. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

### reserve -``` -void reserve(size_type new_capacity); -``` +1. ``` + void reserve(size_type new_capacity); + ``` -**Effects:** -Tries to increase capacity by allocating additional memory. + **Effects:** + Tries to increase capacity by allocating additional memory. -If `new_capacity > capacity()`, the function allocates additional memory such that capacity becomes greater than or equal to `new_capacity`. Otherwise, the function does nothing. + If `new_capacity > capacity()`, the function allocates additional memory such that capacity becomes greater than or equal to `new_capacity`. Otherwise, the function does nothing. -This function does not change size of the container. + This function does not change size of the container. -If the capacity is changed, all iterators to the elements are invalidated, but references and pointers to elements remain valid. Otherwise, no iterators or references are invalidated. + If the capacity is changed, all iterators to the elements are invalidated, but references and pointers to elements remain valid. Otherwise, no iterators or references are invalidated. -

+

### shrink_to_fit -``` -void shrink_to_fit(); -``` +1. ``` + void shrink_to_fit(); + ``` -**Effects:** -Tries to reduce memory usage by freeing unused memory. + **Effects:** + Tries to reduce memory usage by freeing unused memory. -This function does not change size of the container. + This function does not change size of the container. -If the capacity is changed, all iterators to the elements are invalidated, but references and pointers to elements remain valid. Otherwise, no iterators or references are invalidated. + If the capacity is changed, all iterators to the elements are invalidated, but references and pointers to elements remain valid. Otherwise, no iterators or references are invalidated. -

+

### at -``` -reference at(size_type pos); -``` -``` -const_reference at(size_type pos) const; -``` +1. ``` + reference at(size_type pos); + ``` +2. ``` + const_reference at(size_type pos) const; + ``` -**Effects:** -Returns a reference to the element at specified location `pos`, with bounds checking. + **Effects:** + Returns a reference to the element at specified location `pos`, with bounds checking. -**Complexity:** -Constant. + **Complexity:** + Constant. -**Exceptions:** -`std::out_of_range` if `pos >= size()`. + **Exceptions:** + `std::out_of_range` if `pos >= size()`. -

+

### operator[] -``` -reference operator[](size_type pos) noexcept; -``` -``` -const_reference operator[](size_type pos) const noexcept; -``` +1. ``` + reference operator[](size_type pos) noexcept; + ``` +2. ``` + const_reference operator[](size_type pos) const noexcept; + ``` -**Preconditions:** -`pos < size()` + **Preconditions:** + `pos < size()` -**Effects:** -Returns a reference to the element at specified location pos. No bounds checking is performed. + **Effects:** + Returns a reference to the element at specified location pos. No bounds checking is performed. -**Note:** -This operator never inserts a new element into the container. + **Note:** + This operator never inserts a new element into the container. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

### front -``` -reference front() noexcept; -``` -``` -const_reference front() const noexcept; -``` +1. ``` + reference front() noexcept; + ``` +2. ``` + const_reference front() const noexcept; + ``` -**Preconditions:** -`!empty()` + **Preconditions:** + `!empty()` -**Effects:** -Returns a reference to the first element in the container. + **Effects:** + Returns a reference to the first element in the container. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

### back -``` -reference back() noexcept; -``` -``` -const_reference back() const noexcept; -``` +1. ``` + reference back() noexcept; + ``` +2. ``` + const_reference back() const noexcept; + ``` -**Preconditions:** -`!empty()` + **Preconditions:** + `!empty()` -**Effects:** -Returns a reference to the last element in the container. + **Effects:** + Returns a reference to the last element in the container. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

### clear -``` -void clear() noexcept; -``` +1. ``` + void clear() noexcept; + ``` -**Effects:** -Erases all elements from the container. -After this call, `size()` returns zero and `capacity()` remains unchanged. + **Effects:** + Erases all elements from the container. + After this call, `size()` returns zero and `capacity()` remains unchanged. -**Complexity:** -Linear in `size()`. + **Complexity:** + Linear in `size()`. -

+

### emplace -``` -template -iterator emplace(const_iterator pos, Args&&... args); -``` +1. ``` + template + iterator emplace(const_iterator pos, Args&&... args); + ``` -**Preconditions:** -`cbegin() <= pos && pos <= cend()` + **Preconditions:** + `cbegin() <= pos && pos <= cend()` -**Effects:** -Inserts a new element into the container at position `pos`. + **Effects:** + Inserts a new element into the container at position `pos`. -New element is constructed as `value_type(std::forward(args)...)`. + New element is constructed as `value_type(std::forward(args)...)`. -`args...` may directly or indirectly refer to a value in the container. + `args...` may directly or indirectly refer to a value in the container. -**Returns:** -Iterator to the inserted element. + **Returns:** + Iterator to the inserted element. -**Complexity:** -Constant plus linear in `std::distance(pos, end())`. + **Complexity:** + Constant plus linear in `std::distance(pos, end())`. -

+

### insert -``` -iterator insert(const_iterator pos, const T& value); -``` +1. ``` + iterator insert(const_iterator pos, const T& value); + ``` -**Preconditions:** -`cbegin() <= pos && pos <= cend()` + **Preconditions:** + `cbegin() <= pos && pos <= cend()` -**Effects:** -Inserts copy of `value` at position `pos`. + **Effects:** + Inserts copy of `value` at position `pos`. -**Returns:** -Iterator to the inserted element. + **Returns:** + Iterator to the inserted element. -**Complexity:** -Constant plus linear in `std::distance(pos, end())`. + **Complexity:** + Constant plus linear in `std::distance(pos, end())`. -

+

-``` -iterator insert(const_iterator pos, T&& value); -``` +2. ``` + iterator insert(const_iterator pos, T&& value); + ``` -**Preconditions:** -`cbegin() <= pos && pos <= cend()` + **Preconditions:** + `cbegin() <= pos && pos <= cend()` -**Effects:** -Inserts `value` using move semantics at position `pos`. + **Effects:** + Inserts `value` using move semantics at position `pos`. -**Returns:** -Iterator to the inserted element. + **Returns:** + Iterator to the inserted element. -**Complexity:** -Constant plus linear in `std::distance(pos, end())`. + **Complexity:** + Constant plus linear in `std::distance(pos, end())`. -

+

-``` -iterator insert(const_iterator pos, size_type n, const T& value); -``` +3. ``` + iterator insert(const_iterator pos, size_type n, const T& value); + ``` -**Preconditions:** -`cbegin() <= pos && pos <= cend()` + **Preconditions:** + `cbegin() <= pos && pos <= cend()` -**Effects:** -Inserts `n` copies of `value` before position `pos`. + **Effects:** + Inserts `n` copies of `value` before position `pos`. -**Returns:** -Iterator to the first element inserted, or `pos` if `n == 0`. + **Returns:** + Iterator to the first element inserted, or `pos` if `n == 0`. -**Complexity:** -Linear in `n` plus linear in `std::distance(pos, end())`. + **Complexity:** + Linear in `n` plus linear in `std::distance(pos, end())`. -

+

-``` -template -iterator insert(const_iterator pos, InputIt first, InputIt last); -``` +4. ``` + template + iterator insert(const_iterator pos, InputIt first, InputIt last); + ``` -**Preconditions:** -`cbegin() <= pos && pos <= cend()` + **Preconditions:** + `cbegin() <= pos && pos <= cend()` -**Effects:** -Inserts elements from the range `[first, last)` before position `pos`. + **Effects:** + Inserts elements from the range `[first, last)` before position `pos`. -**Note:** -This overload participates in overload resolution only if `InputIt` satisfies requirements of [*LegacyInputIterator*](https://en.cppreference.com/w/cpp/named_req/InputIterator). + **Note:** + This overload participates in overload resolution only if `InputIt` satisfies requirements of [*LegacyInputIterator*](https://en.cppreference.com/w/cpp/named_req/InputIterator). -**Note:** -The behavior is undefined if either `first` or `last` is an iterator into `*this`. + **Note:** + The behavior is undefined if either `first` or `last` is an iterator into `*this`. -**Returns:** -Iterator to the first element inserted, or `pos` if `first == last`. + **Returns:** + Iterator to the first element inserted, or `pos` if `first == last`. -**Complexity:** -Linear in `std::distance(first, last)` plus linear in `std::distance(pos, end())`. + **Complexity:** + Linear in `std::distance(first, last)` plus linear in `std::distance(pos, end())`. -

+

-``` -iterator insert(const_iterator pos, std::initializer_list ilist); -``` +5. ``` + iterator insert(const_iterator pos, std::initializer_list ilist); + ``` -**Preconditions:** -`cbegin() <= pos && pos <= cend()` + **Preconditions:** + `cbegin() <= pos && pos <= cend()` -**Effects:** -Inserts elements from initializer list `ilist` before position `pos`. + **Effects:** + Inserts elements from initializer list `ilist` before position `pos`. -**Returns:** -Iterator to the first element inserted, or `pos` if `ilist` is empty. + **Returns:** + Iterator to the first element inserted, or `pos` if `ilist` is empty. -**Complexity:** -Linear in `ilist.size()` plus linear in `std::distance(pos, end())`. + **Complexity:** + Linear in `ilist.size()` plus linear in `std::distance(pos, end())`. -

+

### emplace_back -``` -template -reference emplace_back(Args&&... args); -``` +1. ``` + template + reference emplace_back(Args&&... args); + ``` -**Effects:** -Inserts a new element at the end of container. + **Effects:** + Inserts a new element at the end of container. -New element is constructed as `value_type(std::forward(args)...)`. + New element is constructed as `value_type(std::forward(args)...)`. -**Returns:** -Reference to the inserted element. + **Returns:** + Reference to the inserted element. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

### push_back -``` -void push_back(const T& value); -``` +1. ``` + void push_back(const T& value); + ``` -**Effects:** -Inserts copy of `value` at the end of container. + **Effects:** + Inserts copy of `value` at the end of container. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

-``` -void push_back(T&& value); -``` +2. ``` + void push_back(T&& value); + ``` -**Effects:** -Inserts `value` using move semantics at the end of container. + **Effects:** + Inserts `value` using move semantics at the end of container. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

### pop_back -``` -void pop_back(); -``` +1. ``` + void pop_back(); + ``` -**Preconditions:** -`!empty()` + **Preconditions:** + `!empty()` -**Effects:** -Removes the last element of the container. + **Effects:** + Removes the last element of the container. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

### erase -``` -iterator erase(const_iterator pos); -``` +1. ``` + iterator erase(const_iterator pos); + ``` -**Preconditions:** -`cbegin() <= pos && pos < cend()` + **Preconditions:** + `cbegin() <= pos && pos < cend()` -**Effects:** -Removes the element at `pos`. + **Effects:** + Removes the element at `pos`. -**Returns:** -Iterator following the last removed element. + **Returns:** + Iterator following the last removed element. -If `pos` refers to the last element, then the `end()` iterator is returned. + If `pos` refers to the last element, then the `end()` iterator is returned. -

+

-``` -iterator erase(const_iterator first, const_iterator last); -``` +2. ``` + iterator erase(const_iterator first, const_iterator last); + ``` -**Preconditions:** -`cbegin() <= first && first <= last && last <= cend()` + **Preconditions:** + `cbegin() <= first && first <= last && last <= cend()` -**Effects:** -Removes the elements in the range `[first, last)`. + **Effects:** + Removes the elements in the range `[first, last)`. -**Returns:** -Iterator following the last removed element. + **Returns:** + Iterator following the last removed element. -If `last == end()` prior to removal, then the updated `end()` iterator is returned. + If `last == end()` prior to removal, then the updated `end()` iterator is returned. -If `[first, last)` is an empty range, then `last` is returned. + If `[first, last)` is an empty range, then `last` is returned. -

+

### resize -``` -void resize(size_type n); -``` +1. ``` + void resize(size_type n); + ``` -**Effects:** -Resizes the container to contain `n` elements. + **Effects:** + Resizes the container to contain `n` elements. -1. If the `size() > n`, the last `size() - n` elements are removed. -2. If the `size() < n`, additional default-constructed elements are inserted at the end of container. + 1. If the `size() > n`, the last `size() - n` elements are removed. + 2. If the `size() < n`, additional default-constructed elements are inserted at the end of container. -

+

-``` -void resize(size_type n, const T& value); -``` +2. ``` + void resize(size_type n, const T& value); + ``` -**Effects:** -Resizes the container to contain `n` elements. + **Effects:** + Resizes the container to contain `n` elements. -1. If the `size() > n`, the last `size() - n` elements are removed. -2. If the `size() < n`, additional copies of `value` are inserted at the end of container. + 1. If the `size() > n`, the last `size() - n` elements are removed. + 2. If the `size() < n`, additional copies of `value` are inserted at the end of container. -

+

### swap -``` -void swap(segmented_vector& other) noexcept; -``` +1. ``` + void swap(segmented_vector& other) noexcept; + ``` -**Preconditions:** -`allocator_traits::propagate_on_container_swap::value || get_allocator() == other.get_allocator()` + **Preconditions:** + `allocator_traits::propagate_on_container_swap::value || get_allocator() == other.get_allocator()` -**Effects:** -Exchanges the contents of the container with those of `other`. + **Effects:** + Exchanges the contents of the container with those of `other`. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

@@ -1088,217 +1087,217 @@ Constant. ### operator== -``` -template -bool operator== -( - const segmented_vector& x, - const segmented_vector& y -); -``` +1. ``` + template + bool operator== + ( + const segmented_vector& x, + const segmented_vector& y + ); + ``` -**Effects:** -Checks if the contents of `x` and `y` are equal. + **Effects:** + Checks if the contents of `x` and `y` are equal. -The contents of `x` and `y` are equal if the following conditions hold: -* `x.size() == y.size()` -* Each element in `x` compares equal with the element in `y` at the same position. + The contents of `x` and `y` are equal if the following conditions hold: + * `x.size() == y.size()` + * Each element in `x` compares equal with the element in `y` at the same position. -**Returns:** -`true` if the contents of the `x` and `y` are equal, `false` otherwise. + **Returns:** + `true` if the contents of the `x` and `y` are equal, `false` otherwise. -**Complexity:** -Constant if `x` and `y` are of different size, otherwise linear in the size of the container. + **Complexity:** + Constant if `x` and `y` are of different size, otherwise linear in the size of the container. -

+

### operator!= -``` -template -bool operator!= -( - const segmented_vector& x, - const segmented_vector& y -); -``` +1. ``` + template + bool operator!= + ( + const segmented_vector& x, + const segmented_vector& y + ); + ``` -**Effects:** -Checks if the contents of `x` and `y` are equal. + **Effects:** + Checks if the contents of `x` and `y` are equal. -For details see `operator==`. + For details see `operator==`. -**Returns:** -`true` if the contents of the `x` and `y` are not equal, `false` otherwise. + **Returns:** + `true` if the contents of the `x` and `y` are not equal, `false` otherwise. -**Complexity:** -Constant if `x` and `y` are of different size, otherwise linear in the size of the container. + **Complexity:** + Constant if `x` and `y` are of different size, otherwise linear in the size of the container. -

+

### operator< -``` -template -bool operator< -( - const segmented_vector& x, - const segmented_vector& y -); -``` +1. ``` + template + bool operator< + ( + const segmented_vector& x, + const segmented_vector& y + ); + ``` -**Effects:** -Compares the contents of `x` and `y` lexicographically. -The comparison is performed by a function `std::lexicographical_compare`. + **Effects:** + Compares the contents of `x` and `y` lexicographically. + The comparison is performed by a function `std::lexicographical_compare`. -**Returns:** -`true` if the contents of the `x` are lexicographically less than the contents of `y`, `false` otherwise. + **Returns:** + `true` if the contents of the `x` are lexicographically less than the contents of `y`, `false` otherwise. -**Complexity:** -Linear in the size of the container. + **Complexity:** + Linear in the size of the container. -

+

### operator> -``` -template -bool operator> -( - const segmented_vector& x, - const segmented_vector& y -); -``` +1. ``` + template + bool operator> + ( + const segmented_vector& x, + const segmented_vector& y + ); + ``` -**Effects:** -Compares the contents of `x` and `y` lexicographically. -The comparison is performed by a function `std::lexicographical_compare`. + **Effects:** + Compares the contents of `x` and `y` lexicographically. + The comparison is performed by a function `std::lexicographical_compare`. -**Returns:** -`true` if the contents of the `x` are lexicographically greater than the contents of `y`, `false` otherwise. + **Returns:** + `true` if the contents of the `x` are lexicographically greater than the contents of `y`, `false` otherwise. -**Complexity:** -Linear in the size of the container. + **Complexity:** + Linear in the size of the container. -

+

### operator<= -``` -template -bool operator<= -( - const segmented_vector& x, - const segmented_vector& y -); -``` +1. ``` + template + bool operator<= + ( + const segmented_vector& x, + const segmented_vector& y + ); + ``` -**Effects:** -Compares the contents of `x` and `y` lexicographically. -The comparison is performed by a function `std::lexicographical_compare`. + **Effects:** + Compares the contents of `x` and `y` lexicographically. + The comparison is performed by a function `std::lexicographical_compare`. -**Returns:** -`true` if the contents of the `x` are lexicographically less than or equal to the contents of `y`, `false` otherwise. + **Returns:** + `true` if the contents of the `x` are lexicographically less than or equal to the contents of `y`, `false` otherwise. -**Complexity:** -Linear in the size of the container. + **Complexity:** + Linear in the size of the container. -

+

### operator>= -``` -template -bool operator>= -( - const segmented_vector& x, - const segmented_vector& y -); -``` +1. ``` + template + bool operator>= + ( + const segmented_vector& x, + const segmented_vector& y + ); + ``` -**Effects:** -Compares the contents of `x` and `y` lexicographically. -The comparison is performed by a function `std::lexicographical_compare`. + **Effects:** + Compares the contents of `x` and `y` lexicographically. + The comparison is performed by a function `std::lexicographical_compare`. -**Returns:** -`true` if the contents of the `x` are lexicographically greater than or equal to the contents of `y`, `false` otherwise. + **Returns:** + `true` if the contents of the `x` are lexicographically greater than or equal to the contents of `y`, `false` otherwise. -**Complexity:** -Linear in the size of the container. + **Complexity:** + Linear in the size of the container. -

+

### swap -``` -template -void swap -( - segmented_vector& x, - segmented_vector& y -); -``` +1. ``` + template + void swap + ( + segmented_vector& x, + segmented_vector& y + ); + ``` -**Effects:** -Swaps the contents of `x` and `y`. Calls `x.swap(y)`. + **Effects:** + Swaps the contents of `x` and `y`. Calls `x.swap(y)`. -

+

### erase -``` -template -typename segmented_vector::size_type - erase(segmented_vector& c, const U& value); -``` +1. ``` + template + typename segmented_vector::size_type + erase(segmented_vector& c, const U& value); + ``` -**Effects:** -Erases all elements that compare equal to `value` from the container. + **Effects:** + Erases all elements that compare equal to `value` from the container. -**Returns:** -The number of erased elements. + **Returns:** + The number of erased elements. -**Complexity:** -Linear. + **Complexity:** + Linear. -

+

### erase_if -``` -template -typename segmented_vector::size_type - erase_if(segmented_vector& c, Predicate pred); -``` +1. ``` + template + typename segmented_vector::size_type + erase_if(segmented_vector& c, Predicate pred); + ``` -**Effects:** -Erases all elements that satisfy the predicate `pred` from the container. + **Effects:** + Erases all elements that satisfy the predicate `pred` from the container. -`pred` is unary predicate which returns `true` if the element should be removed. + `pred` is unary predicate which returns `true` if the element should be removed. -**Returns:** -The number of erased elements. + **Returns:** + The number of erased elements. -**Complexity:** -Linear. + **Complexity:** + Linear. -

+

diff --git a/doc/small_flat_map.md b/doc/small_flat_map.md index 61363c8..c7c3433 100644 --- a/doc/small_flat_map.md +++ b/doc/small_flat_map.md @@ -110,7 +110,8 @@ Iterators to elements of `sfl::small_flat_map` are random access iterators and t std::size_t N ``` - Size of the internal statically allocated array. + Size of the internal statically allocated array, i.e. the maximal number of elements that can fit into this array. + This parameter can be zero. 4. ``` @@ -186,1292 +187,1329 @@ static constexpr size_type static_capacity = N; ### (constructor) -``` -small_flat_map() - noexcept( +1. ``` + small_flat_map() noexcept( std::is_nothrow_default_constructible::value && std::is_nothrow_default_constructible::value ); -``` -``` -explicit small_flat_map(const Compare& comp) - noexcept( + ``` +2. ``` + explicit small_flat_map(const Compare& comp) noexcept( std::is_nothrow_default_constructible::value && std::is_nothrow_copy_constructible::value ); -``` -``` -explicit small_flat_map(const Allocator& alloc) - noexcept( + ``` +3. ``` + explicit small_flat_map(const Allocator& alloc) noexcept( std::is_nothrow_copy_constructible::value && std::is_nothrow_default_constructible::value ); -``` -``` -explicit small_flat_map(const Compare& comp, const Allocator& alloc) - noexcept( + ``` +4. ``` + explicit small_flat_map(const Compare& comp, const Allocator& alloc) noexcept( std::is_nothrow_copy_constructible::value && std::is_nothrow_copy_constructible::value ); -``` + ``` -**Effects:** -Constructs an empty container. + **Effects:** + Constructs an empty container. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

-``` -template -small_flat_map(InputIt first, InputIt last); -``` -``` -template -small_flat_map(InputIt first, InputIt last, const Compare& comp); -``` -``` -template -small_flat_map(InputIt first, InputIt last, const Allocator& alloc); -``` -``` -template -small_flat_map(InputIt first, InputIt last, const Compare& comp, const Allocator& alloc); -``` +5. ``` + template + small_flat_map(InputIt first, InputIt last); + ``` +6. ``` + template + small_flat_map(InputIt first, InputIt last, const Compare& comp); + ``` +7. ``` + template + small_flat_map(InputIt first, InputIt last, const Allocator& alloc); + ``` +8. ``` + template + small_flat_map(InputIt first, InputIt last, const Compare& comp, const Allocator& alloc); + ``` -**Effects:** -Constructs an empty container and inserts elements from the range `[first, last)`. + **Effects:** + Constructs an empty container and inserts elements from the range `[first, last)`. -**Note:** -This overload participates in overload resolution only if `InputIt` satisfies requirements of [*LegacyInputIterator*](https://en.cppreference.com/w/cpp/named_req/InputIterator). + **Note:** + These overloads participate in overload resolution only if `InputIt` satisfies requirements of [*LegacyInputIterator*](https://en.cppreference.com/w/cpp/named_req/InputIterator). -**Complexity:** -Linear in `std::distance(first, last)`. + **Complexity:** + Linear in `std::distance(first, last)`. -

+

-``` -small_flat_map(std::initializer_list ilist); -``` -``` -small_flat_map(std::initializer_list ilist, const Compare& comp); -``` -``` -small_flat_map(std::initializer_list ilist, const Allocator& alloc); -``` -``` -small_flat_map(std::initializer_list ilist, const Compare& comp, const Allocator& alloc); -``` +9. ``` + small_flat_map(std::initializer_list ilist); + ``` +10. ``` + small_flat_map(std::initializer_list ilist, const Compare& comp); + ``` +11. ``` + small_flat_map(std::initializer_list ilist, const Allocator& alloc); + ``` +12. ``` + small_flat_map(std::initializer_list ilist, const Compare& comp, const Allocator& alloc); + ``` -**Effects:** -Constructs an empty container and inserts elements from the initializer list `ilist`. + **Effects:** + Constructs an empty container and inserts elements from the initializer list `ilist`. -**Complexity:** -Linear in `ilist.size()`. + **Complexity:** + Linear in `ilist.size()`. -

+

-``` -small_flat_map(const small_flat_map& other); -``` -``` -small_flat_map(const small_flat_map& other, const Allocator& alloc); -``` +13. ``` + small_flat_map(const small_flat_map& other); + ``` +14. ``` + small_flat_map(const small_flat_map& other, const Allocator& alloc); + ``` -**Effects:** -Copy constructor. -Constructs the container with the copy of the contents of `other`. + **Effects:** + Copy constructor. + Constructs the container with the copy of the contents of `other`. -**Complexity:** -Linear in `other.size()`. + **Complexity:** + Linear in `other.size()`. -

+

-``` -small_flat_map(small_flat_map&& other); -``` -``` -small_flat_map(small_flat_map&& other, const Allocator& alloc); -``` +15. ``` + small_flat_map(small_flat_map&& other); + ``` +16. ``` + small_flat_map(small_flat_map&& other, const Allocator& alloc); + ``` -**Effects:** -Move constructor. -Constructs the container with the contents of `other` using move semantics. + **Effects:** + Move constructor. + Constructs the container with the contents of `other` using move semantics. -`other` is not guaranteed to be empty after the move. + `other` is not guaranteed to be empty after the move. -`other` is in a valid but unspecified state after the move. + `other` is in a valid but unspecified state after the move. -**Complexity:** -Constant in the best case. Linear in `N` in the worst case. + **Complexity:** + Constant in the best case. Linear in `N` in the worst case. -

+

### (destructor) -``` -~small_flat_map(); -``` +1. ``` + ~small_flat_map(); + ``` -**Effects:** -Destructs the container. The destructors of the elements are called and the used storage is deallocated. + **Effects:** + Destructs the container. The destructors of the elements are called and the used storage is deallocated. -**Complexity:** -Linear in `size()`. + **Complexity:** + Linear in `size()`. -

+

### operator= -``` -small_flat_map& operator=(const small_flat_map& other); -``` +1. ``` + small_flat_map& operator=(const small_flat_map& other); + ``` -**Effects:** -Copy assignment operator. -Replaces the contents with a copy of the contents of `other`. + **Effects:** + Copy assignment operator. + Replaces the contents with a copy of the contents of `other`. -**Returns:** -`*this()`. + **Returns:** + `*this()`. -**Complexity:** -Linear in `this->size()` plus linear in `other.size()`. + **Complexity:** + Linear in `this->size()` plus linear in `other.size()`. -

+

-``` -small_flat_map& operator=(small_flat_map&& other); -``` +2. ``` + small_flat_map& operator=(small_flat_map&& other); + ``` -**Effects:** -Move assignment operator. -Replaces the contents with those of `other` using move semantics. + **Effects:** + Move assignment operator. + Replaces the contents with those of `other` using move semantics. -`other` is not guaranteed to be empty after the move. + `other` is not guaranteed to be empty after the move. -`other` is in a valid but unspecified state after the move. + `other` is in a valid but unspecified state after the move. -**Returns:** -`*this()`. + **Returns:** + `*this()`. -**Complexity:** + **Complexity:** -* The best case: Linear in `this->size()` plus constant. -* The worst case: Linear in `this->size()` plus linear in `other.size()`. + * The best case: Linear in `this->size()` plus constant. + * The worst case: Linear in `this->size()` plus linear in `other.size()`. -

+

-``` -small_flat_map& operator=(std::initializer_list ilist); -``` +3. ``` + small_flat_map& operator=(std::initializer_list ilist); + ``` -**Effects:** -Replaces the contents with those identified by initializer list `ilist`. + **Effects:** + Replaces the contents with those identified by initializer list `ilist`. -**Returns:** -`*this()`. + **Returns:** + `*this()`. -**Complexity:** -Linear in `this->size()` plus linear in `ilist.size()`. + **Complexity:** + Linear in `this->size()` plus linear in `ilist.size()`. -

+

### get_allocator -``` -allocator_type get_allocator() const noexcept; -``` +1. ``` + allocator_type get_allocator() const noexcept; + ``` -**Effects:** -Returns the allocator associated with the container. + **Effects:** + Returns the allocator associated with the container. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

### key_comp -``` -key_compare key_comp() const; -``` +1. ``` + key_compare key_comp() const; + ``` -**Effects:** -Returns the function object that compares the keys, which is a copy of this container's constructor argument `comp`. + **Effects:** + Returns the function object that compares the keys, which is a copy of this container's constructor argument `comp`. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

### value_comp -``` -value_compare value_comp() const; -``` +1. ``` + value_compare value_comp() const; + ``` -**Effects:** -Returns a function object that compares objects of type `value_type`. + **Effects:** + Returns a function object that compares objects of type `value_type`. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

### begin, cbegin -``` -iterator begin() noexcept; -``` -``` -const_iterator begin() const noexcept; -``` -``` -const_iterator cbegin() const noexcept; -``` - -**Effects:** -Returns an iterator to the first element of the container. +1. ``` + iterator begin() noexcept; + ``` +2. ``` + const_iterator begin() const noexcept; + ``` +3. ``` + const_iterator cbegin() const noexcept; + ``` -If the container is empty, the returned iterator will be equal to `end()`. + **Effects:** + Returns an iterator to the first element of the container. + If the container is empty, the returned iterator will be equal to `end()`. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

### end, cend -``` -iterator end() noexcept; -``` -``` -const_iterator end() const noexcept; -``` -``` -const_iterator cend() const noexcept; -``` - -**Effects:** -Returns an iterator to the element following the last element of the container. +1. ``` + iterator end() noexcept; + ``` +2. ``` + const_iterator end() const noexcept; + ``` +3. ``` + const_iterator cend() const noexcept; + ``` -This element acts as a placeholder; attempting to access it results in undefined behavior. + **Effects:** + Returns an iterator to the element following the last element of the container. + This element acts as a placeholder; attempting to access it results in undefined behavior. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

### rbegin, crbegin -``` -reverse_iterator rbegin() noexcept; -``` -``` -const_reverse_iterator rbegin() const noexcept; -``` -``` -const_reverse_iterator crbegin() const noexcept; -``` +1. ``` + reverse_iterator rbegin() noexcept; + ``` +2. ``` + const_reverse_iterator rbegin() const noexcept; + ``` +3. ``` + const_reverse_iterator crbegin() const noexcept; + ``` -**Effects:** -Returns a reverse iterator to the first element of the reversed container. -It corresponds to the last element of the non-reversed container. -If the container is empty, the returned iterator is equal to `rend()`. + **Effects:** + Returns a reverse iterator to the first element of the reversed container. + It corresponds to the last element of the non-reversed container. + If the container is empty, the returned iterator is equal to `rend()`. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

### rend, crend -``` -reverse_iterator rend() noexcept; -``` -``` -const_reverse_iterator rend() const noexcept; -``` -``` -const_reverse_iterator crend() const noexcept; -``` +1. ``` + reverse_iterator rend() noexcept; + ``` +2. ``` + const_reverse_iterator rend() const noexcept; + ``` +3. ``` + const_reverse_iterator crend() const noexcept; + ``` -**Effects:** -Returns a reverse iterator to the element following the last element of the reversed container. -It corresponds to the element preceding the first element of the non-reversed container. -This element acts as a placeholder, attempting to access it results in undefined behavior. + **Effects:** + Returns a reverse iterator to the element following the last element of the reversed container. + It corresponds to the element preceding the first element of the non-reversed container. + This element acts as a placeholder, attempting to access it results in undefined behavior. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

### nth -``` -iterator nth(size_type pos) noexcept; -``` -``` -const_iterator nth(size_type pos) const noexcept; -``` +1. ``` + iterator nth(size_type pos) noexcept; + ``` +2. ``` + const_iterator nth(size_type pos) const noexcept; + ``` -**Preconditions:** -`pos <= size()` + **Preconditions:** + `pos <= size()` -**Effects:** -Returns an iterator to the element at position `pos`. -If `pos == size()`, the returned iterator is equal to `end()`. + **Effects:** + Returns an iterator to the element at position `pos`. -**Complexity:** -Constant. + If `pos == size()`, the returned iterator is equal to `end()`. -

+ **Complexity:** + Constant. + +

### index_of -``` -size_type index_of(const_iterator pos) const noexcept; -``` +1. ``` + size_type index_of(const_iterator pos) const noexcept; + ``` -**Preconditions:** -`cbegin() <= pos && pos <= cend()` + **Preconditions:** + `cbegin() <= pos && pos <= cend()` -**Effects:** -Returns position of the element pointed by iterator `pos`, i.e. `std::distance(begin(), pos)`. + **Effects:** + Returns position of the element pointed by iterator `pos`, i.e. `std::distance(begin(), pos)`. -If `pos == end()`, the returned value is equal to `size()`. + If `pos == end()`, the returned value is equal to `size()`. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

### empty -``` -bool empty() const noexcept; -``` +1. ``` + bool empty() const noexcept; + ``` -**Effects:** -Returns `true` if the container has no elements, i.e. whether `begin() == end()`. + **Effects:** + Returns `true` if the container has no elements, i.e. whether `begin() == end()`. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

### size -``` -size_type size() const noexcept; -``` +1. ``` + size_type size() const noexcept; + ``` -**Effects:** -Returns the number of elements in the container, i.e. `std::distance(begin(), end())`. + **Effects:** + Returns the number of elements in the container, i.e. `std::distance(begin(), end())`. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

### max_size -``` -size_type max_size() const noexcept; -``` +1. ``` + size_type max_size() const noexcept; + ``` -**Effects:** -Returns the maximum number of elements the container is able to hold, i.e. `std::distance(begin(), end())` for the largest container. + **Effects:** + Returns the maximum number of elements the container is able to hold, i.e. `std::distance(begin(), end())` for the largest container. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

### capacity -``` -size_type capacity() const noexcept; -``` +1. ``` + size_type capacity() const noexcept; + ``` -**Effects:** -Returns the number of elements that the container has currently allocated space for. + **Effects:** + Returns the number of elements that the container has currently allocated space for. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

### available -``` -size_type available() const noexcept; -``` +1. ``` + size_type available() const noexcept; + ``` -**Effects:** -Returns the number of elements that can be inserted into the container without requiring allocation of additional memory. + **Effects:** + Returns the number of elements that can be inserted into the container without requiring allocation of additional memory. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

### reserve -``` -void reserve(size_type new_cap); -``` +1. ``` + void reserve(size_type new_cap); + ``` -**Effects:** -Tries to increase capacity by allocating additional memory. + **Effects:** + Tries to increase capacity by allocating additional memory. -If `new_cap > capacity()`, the function allocates memory for new storage of capacity equal to the value of `new_cap`, moves elements from old storage to new storage, and deallocates memory used by old storage. Otherwise, the function does nothing. + If `new_cap > capacity()`, the function allocates memory for new storage of capacity equal to the value of `new_cap`, moves elements from old storage to new storage, and deallocates memory used by old storage. Otherwise, the function does nothing. -This function does not change size of the container. + This function does not change size of the container. -If the capacity is changed, all iterators and all references to the elements are invalidated. Otherwise, no iterators or references are invalidated. + If the capacity is changed, all iterators and all references to the elements are invalidated. Otherwise, no iterators or references are invalidated. -**Complexity:** -Linear. + **Complexity:** + Linear. -**Exceptions:** + **Exceptions:** -* `Allocator::allocate` may throw. -* `T`'s move or copy constructor may throw. + * `Allocator::allocate` may throw. + * `T`'s move or copy constructor may throw. -If an exception is thrown: + If an exception is thrown: -* If type `T` has available `noexcept` move constructor: - * This function has no effects (strong exception guarantee). -* Else if type `T` has available copy constructor: - * This function has no effects (strong exception guarantee). -* Else if type `T` has available throwing move constructor: - * Container is changed but in valid state (basic exception guarantee). + * If type `T` has available `noexcept` move constructor: + * This function has no effects (strong exception guarantee). + * Else if type `T` has available copy constructor: + * This function has no effects (strong exception guarantee). + * Else if type `T` has available throwing move constructor: + * Container is changed but in valid state (basic exception guarantee). -

+

### shrink_to_fit -``` -void shrink_to_fit(); -``` +1. ``` + void shrink_to_fit(); + ``` -**Effects:** -Tries to reduce memory usage by freeing unused memory. + **Effects:** + Tries to reduce memory usage by freeing unused memory. -1. If `size() > N && size() < capacity()`, the function allocates memory for new storage of capacity equal to the value of `size()`, moves elements from old storage to new storage, and deallocates memory used by old storage. -2. If `size() <= N && N < capacity()`, the function sets new storage to be internal statically allocated array of capacity `N`, moves elements from old storage to new storage, and deallocates memory used by old storage. -3. Otherwise the function does nothing. + 1. If `size() > N && size() < capacity()`, the function allocates memory for new storage of capacity equal to the value of `size()`, moves elements from old storage to new storage, and deallocates memory used by old storage. -This function does not change size of the container. + 2. If `size() <= N && N < capacity()`, the function sets new storage to be internal statically allocated array of capacity `N`, moves elements from old storage to new storage, and deallocates memory used by old storage. -If the capacity is changed, all iterators and all references to the elements are invalidated. Otherwise, no iterators or references are invalidated. + 3. Otherwise the function does nothing. -**Complexity:** -Linear. + This function does not change size of the container. -**Exceptions:** + If the capacity is changed, all iterators and all references to the elements are invalidated. Otherwise, no iterators or references are invalidated. -* `Allocator::allocate` may throw. -* `T`'s move or copy constructor may throw. + **Complexity:** + Linear. -If an exception is thrown: + **Exceptions:** -* If type `T` has available `noexcept` move constructor: - * This function has no effects (strong exception guarantee). -* Else if type `T` has available copy constructor: - * This function has no effects (strong exception guarantee). -* Else if type `T` has available throwing move constructor: - * Container is changed but in valid state (basic exception guarantee). + * `Allocator::allocate` may throw. + * `T`'s move or copy constructor may throw. -

+ If an exception is thrown: + + * If type `T` has available `noexcept` move constructor: + * This function has no effects (strong exception guarantee). + * Else if type `T` has available copy constructor: + * This function has no effects (strong exception guarantee). + * Else if type `T` has available throwing move constructor: + * Container is changed but in valid state (basic exception guarantee). + +

### clear -``` -void clear() noexcept; -``` +1. ``` + void clear() noexcept; + ``` -**Effects:** -Erases all elements from the container. -After this call, `size()` returns zero and `capacity()` remains unchanged. + **Effects:** + Erases all elements from the container. + After this call, `size()` returns zero and `capacity()` remains unchanged. -**Complexity:** -Linear in `size()`. + **Complexity:** + Linear in `size()`. -

+

### emplace -``` -template -std::pair emplace(Args&&... args); -``` +1. ``` + template + std::pair emplace(Args&&... args); + ``` -**Effects:** -Inserts a new element into the container only if the container does not already contain an element with an equivalent key. + **Effects:** + Inserts new element into the container if the container doesn't already contain an element with an equivalent key. -New element is constructed as `value_type(std::forward(args)...)`. + New element is constructed as `value_type(std::forward(args)...)`. -The element may be constructed even if there already is an element with the key in the container, in which case the newly constructed element will be destroyed immediately. + The element may be constructed even if there already is an element with the key in the container, in which case the newly constructed element will be destroyed immediately. -**Returns:** -Pair consisting of an iterator to the inserted element, or the already-existing element if no insertion happened, and a `bool` denoting whether the insertion took place (`true` if insertion happened, `false` if it did not). + **Returns:** + The iterator component points to the inserted element or to the already existing element. The `bool` component is `true` if insertion happened and `false` if it did not. -

+

### emplace_hint -``` -template -iterator emplace_hint(const_iterator hint, Args&&... args); -``` +1. ``` + template + iterator emplace_hint(const_iterator hint, Args&&... args); + ``` -**Preconditions:** -`cbegin() <= hint && hint <= cend()` + **Preconditions:** + `cbegin() <= hint && hint <= cend()` -**Effects:** -Inserts a new element into the container only if the container does not already contain an element with an equivalent key. + **Effects:** + Inserts new element into the container if the container doesn't already contain an element with an equivalent key. -New element is constructed as `value_type(std::forward(args)...)`. + New element is constructed as `value_type(std::forward(args)...)`. -The element may be constructed even if there already is an element with the key in the container, in which case the newly constructed element will be destroyed immediately. + The element may be constructed even if there already is an element with the key in the container, in which case the newly constructed element will be destroyed immediately. -Iterator `hint` is used as a suggestion where to start to search insert position. + Iterator `hint` is used as a suggestion where to start to search insert position. -**Returns:** -Iterator to the inserted element or to the already existing element. + **Returns:** + Iterator to the inserted element or to the already existing element. -

+

### insert -``` -std::pair insert(const value_type& value); -``` +1. ``` + std::pair insert(const value_type& value); + ``` -**Effects:** -Inserts copy of `value` only if the container does not already contain an element with an key equivalent to the key of `value`. + **Effects:** + Inserts copy of `value` if the container doesn't already contain an element with an equivalent key. -**Returns:** -Pair consisting of an iterator to the inserted element, or the already-existing element if no insertion happened, and a `bool` denoting whether the insertion took place (`true` if insertion happened, `false` if it did not). + **Returns:** + The iterator component points to the inserted element or to the already existing element. The `bool` component is `true` if insertion happened and `false` if it did not. -

+

-``` -std::pair insert(value_type&& value); -``` +2. ``` + std::pair insert(value_type&& value); + ``` -**Effects:** -Inserts `value` using move semantics only if the container does not already contain an element with an key equivalent to the key of `value`. + **Effects:** + Inserts `value` using move semantics if the container doesn't already contain an element with an equivalent key. -**Returns:** -Pair consisting of an iterator to the inserted element, or the already-existing element if no insertion happened, and a `bool` denoting whether the insertion took place (`true` if insertion happened, `false` if it did not). + **Returns:** + The iterator component points to the inserted element or to the already existing element. The `bool` component is `true` if insertion happened and `false` if it did not. -

+

-``` -template -std::pair insert(P&& value); -``` +3. ``` + template + std::pair insert(P&& value); + ``` -**Effects:** -Inserts a new element into the container only if the container does not already contain an element with an equivalent key. + **Effects:** + Inserts new element into the container if the container doesn't already contain an element with an equivalent key. -New element is constructed as `value_type(std::forward

(value))`. + New element is constructed as `value_type(std::forward

(value))`. -**Note:** -This overload participates in overload resolution only if `std::is_constructible::value` is `true`. + **Note:** + This overload participates in overload resolution only if `std::is_constructible::value` is `true`. -**Returns:** -Pair consisting of an iterator to the inserted element, or the already-existing element if no insertion happened, and a `bool` denoting whether the insertion took place (`true` if insertion happened, `false` if it did not). + **Returns:** + The iterator component points to the inserted element or to the already existing element. The `bool` component is `true` if insertion happened and `false` if it did not. -

+

-``` -iterator insert(const_iterator hint, const value_type& value); -``` +4. ``` + iterator insert(const_iterator hint, const value_type& value); + ``` -**Preconditions:** -`cbegin() <= hint && hint <= cend()` + **Preconditions:** + `cbegin() <= hint && hint <= cend()` -**Effects:** -Inserts copy of `value` only if the container does not already contain an element with an key equivalent to the key of `value`. + **Effects:** + Inserts copy of `value` if the container doesn't already contain an element with an equivalent key. -Iterator `hint` is used as a suggestion where to start to search insert position. + Iterator `hint` is used as a suggestion where to start to search insert position. -**Returns:** -Iterator to the inserted element or to the already existing element. + **Returns:** + Iterator to the inserted element or to the already existing element. -

+

-``` -iterator insert(const_iterator hint, value_type&& value); -``` +5. ``` + iterator insert(const_iterator hint, value_type&& value); + ``` -**Preconditions:** -`cbegin() <= hint && hint <= cend()` + **Preconditions:** + `cbegin() <= hint && hint <= cend()` -**Effects:** -Inserts `value` using move semantics only if the container does not already contain an element with an key equivalent to the key of `value`. + **Effects:** + Inserts `value` using move semantics if the container doesn't already contain an element with an equivalent key. -Iterator `hint` is used as a suggestion where to start to search insert position. + Iterator `hint` is used as a suggestion where to start to search insert position. -**Returns:** -Iterator to the inserted element or to the already existing element. + **Returns:** + Iterator to the inserted element or to the already existing element. -

+

-``` -template -iterator insert(const_iterator hint, P&& value); -``` +6. ``` + template + iterator insert(const_iterator hint, P&& value); + ``` -**Preconditions:** -`cbegin() <= hint && hint <= cend()` + **Preconditions:** + `cbegin() <= hint && hint <= cend()` -**Effects:** -Inserts a new element into the container only if the container does not already contain an element with an equivalent key. + **Effects:** + Inserts new element into the container if the container doesn't already contain an element with an equivalent key. -New element is constructed as `value_type(std::forward

(value))`. + New element is constructed as `value_type(std::forward

(value))`. -Iterator `hint` is used as a suggestion where to start to search insert position. + Iterator `hint` is used as a suggestion where to start to search insert position. -**Note:** -This overload participates in overload resolution only if `std::is_constructible::value` is `true`. + **Note:** + This overload participates in overload resolution only if `std::is_constructible::value` is `true`. -**Returns:** -Iterator to the inserted element or to the already existing element. + **Returns:** + Iterator to the inserted element or to the already existing element. -

+

-``` -template -void insert(InputIt first, InputIt last); -``` +7. ``` + template + void insert(InputIt first, InputIt last); + ``` -**Effects:** -Inserts elements from range `[first, last)`. + **Effects:** + Inserts elements from range `[first, last)`. -The call to this function is equivalent to: -``` -while (first != last) -{ - insert(*first); - ++first; -} -``` + The call to this function is equivalent to: + ``` + while (first != last) + { + insert(*first); + ++first; + } + ``` -**Note:** -This overload participates in overload resolution only if `InputIt` satisfies requirements of [*LegacyInputIterator*](https://en.cppreference.com/w/cpp/named_req/InputIterator). + **Note:** + This overload participates in overload resolution only if `InputIt` satisfies requirements of [*LegacyInputIterator*](https://en.cppreference.com/w/cpp/named_req/InputIterator). -

+

-``` -void insert(std::initializer_list ilist); -``` +8. ``` + void insert(std::initializer_list ilist); + ``` -**Effects:** -Inserts elements from initializer list `ilist`. + **Effects:** + Inserts elements from initializer list `ilist`. -The call to this function is equivalent to: -``` -insert(ilist.begin(), ilist.end()); -``` + The call to this function is equivalent to `insert(ilist.begin(), ilist.end())`. -

+

### insert_or_assign -``` -template -std::pair insert_or_assign(const Key& key, M&& obj); -``` -``` -template -std::pair insert_or_assign(Key&& key, M&& obj); -``` +1. ``` + template + std::pair insert_or_assign(const Key& key, M&& obj); + ``` +2. ``` + template + std::pair insert_or_assign(Key&& key, M&& obj); + ``` +3. ``` + template + std::pair insert_or_assign(K&& key, M&& obj); + ``` -**Effects:** -If a key equivalent to `key` already exists in the container, assigns `std::forward(obj)` to the mapped type corresponding to the key `key`. If the key does not exist, inserts the new element. - -* If the first overload is used, the new element is constructed as - ``` - value_type( std::piecewise_construct, - std::forward_as_tuple(key), - std::forward_as_tuple(std::forward(obj)) ) - ``` -* If the second overload is used, the new element is constructed as - ``` - value_type( std::piecewise_construct, - std::forward_as_tuple(std::move(key)), - std::forward_as_tuple(std::forward(obj)) ) - ``` - -**Note:** -This overload participates in overload resolution only if `std::is_assignable_v` is `true`. - -**Returns:** -A pair of iterator and `bool`: -* The iterator component points at the element that was inserted or updated. -* The `bool` component is `true` if the insertion took place and `false` if the assignment took place. + **Effects:** + If a key equivalent to `key` already exists in the container, assigns `std::forward(obj)` to the mapped type corresponding to the key `key`. If the key does not exist, inserts the new element. -

+ * **Overload (1):** New element is constructed as + ``` + value_type( std::piecewise_construct, + std::forward_as_tuple(key), + std::forward_as_tuple(std::forward(obj)) ) + ``` + **Note:** This overload participates in overload resolution only if `std::is_assignable_v` is `true`. -``` -template -iterator insert_or_assign(const_iterator hint, const Key& key, M&& obj); -``` -``` -template -iterator insert_or_assign(const_iterator hint, Key&& key, M&& obj); -``` + * **Overload (2):** New element is constructed as -**Preconditions:** -`cbegin() <= hint && hint <= cend()` + ``` + value_type( std::piecewise_construct, + std::forward_as_tuple(std::move(key)), + std::forward_as_tuple(std::forward(obj)) ) + ``` -**Effects:** -Same as `insert_or_assign` overloads that do not take `hint`. + **Note:** This overload participates in overload resolution only if `std::is_assignable_v` is `true`. -Iterator `hint` is used as a suggestion where to start to search insert position. + * **Overload (3):** New element is constructed as -**Note:** -This overload participates in overload resolution only if `std::is_assignable_v` is `true`. + ``` + value_type( std::piecewise_construct, + std::forward_as_tuple(std::forward(key)), + std::forward_as_tuple(std::forward(obj)) ) + ``` -**Returns:** -Iterator to the element that was inserted or updated. + **Note:** This overload participates in overload resolution only if all following conditions are satisfied: + 1. `Compare::is_transparent` exists and is a valid type. It allows calling this function without constructing an instance of `Key`. + 2. `std::is_assignable_v` is `true`. -

+ **Returns:** + The iterator component points to the inserted element or to the updated element. The `bool` component is `true` if insertion took place and `false` if assignment took place. +

-### try_emplace -``` -template -std::pair try_emplace(const Key& key, Args&&... args); -``` -``` -template -std::pair try_emplace(Key&& key, Args&&... args); -``` +4. ``` + template + iterator insert_or_assign(const_iterator hint, const Key& key, M&& obj); + ``` +5. ``` + template + iterator insert_or_assign(const_iterator hint, Key&& key, M&& obj); + ``` +6. ``` + template + iterator insert_or_assign(const_iterator hint, K&& key, M&& obj); + ``` -**Effects:** -If a key equivalent to `key` already exists in the container, does nothing. Otherwise, behaves like `emplace`. - -* If the first overload is used, the new element is constructed as - ``` - value_type( std::piecewise_construct, - std::forward_as_tuple(key), - std::forward_as_tuple(std::forward(args)...) ) - ``` -* If the second overload is used, the new element is constructed as - ``` - value_type( std::piecewise_construct, - std::forward_as_tuple(std::move(key)), - std::forward_as_tuple(std::forward(args)...) ) - ``` - -**Returns:** -A pair of iterator and `bool`: -* The iterator component points at the inserted element or to the already existing element. -* The `bool` component is `true` if insertion happened and `false` if it did not. + **Preconditions:** + `cbegin() <= hint && hint <= cend()` -

+ **Effects:** + If a key equivalent to `key` already exists in the container, assigns `std::forward(obj)` to the mapped type corresponding to the key `key`. If the key does not exist, inserts the new element. + Iterator `hint` is used as a suggestion where to start to search insert position. + * **Overload (4):** New element is constructed as -``` -template -iterator try_emplace(const_iterator hint, const Key& key, Args&&... args); -``` -``` -template -iterator try_emplace(const_iterator hint, Key&& key, Args&&... args); -``` + ``` + value_type( std::piecewise_construct, + std::forward_as_tuple(key), + std::forward_as_tuple(std::forward(obj)) ) + ``` -**Preconditions:** -`cbegin() <= hint && hint <= cend()` + **Note:** This overload participates in overload resolution only if `std::is_assignable_v` is `true`. -**Effects:** -Same as `try_emplace` overloads that do not take `hint`. + * **Overload (5):** New element is constructed as -Iterator `hint` is used as a suggestion where to start to search insert position. + ``` + value_type( std::piecewise_construct, + std::forward_as_tuple(std::move(key)), + std::forward_as_tuple(std::forward(obj)) ) + ``` -**Returns:** -Iterator to the inserted element or to the already existing element. + **Note:** This overload participates in overload resolution only if `std::is_assignable_v` is `true`. -

+ * **Overload (6):** New element is constructed as + ``` + value_type( std::piecewise_construct, + std::forward_as_tuple(std::forward(key)), + std::forward_as_tuple(std::forward(obj)) ) + ``` + **Note:** This overload participates in overload resolution only if all following conditions are satisfied: + 1. `Compare::is_transparent` exists and is a valid type. It allows calling this function without constructing an instance of `Key`. + 2. `std::is_assignable_v` is `true`. -### erase + **Returns:** + Iterator to the element that was inserted or updated. -``` -iterator erase(iterator pos); -``` -``` -iterator erase(const_iterator pos); -``` +

-**Preconditions:** -`cbegin() <= pos && pos < cend()` -**Effects:** -Removes the element at `pos`. -**Returns:** -Iterator following the last removed element. +### try_emplace -

+1. ``` + template + std::pair try_emplace(const Key& key, Args&&... args); + ``` +2. ``` + template + std::pair try_emplace(Key&& key, Args&&... args); + ``` +3. ``` + template + std::pair try_emplace(K&& key, Args&&... args); + ``` + **Effects:** + If a key equivalent to `key` already exists in the container, does nothing. + Otherwise, inserts a new element into the container. + * **Overload (1):** Behaves like `emplace` except that the element is constructed as -``` -iterator erase(const_iterator first, const_iterator last); -``` + ``` + value_type( std::piecewise_construct, + std::forward_as_tuple(key), + std::forward_as_tuple(std::forward(args)...) ) + ``` -**Preconditions:** -`cbegin() <= first && first <= last && last <= cend()` + * **Overload (2):** Behaves like `emplace` except that the element is constructed as -**Effects:** -Removes the elements in the range `[first, last)`. + ``` + value_type( std::piecewise_construct, + std::forward_as_tuple(std::move(key)), + std::forward_as_tuple(std::forward(args)...) ) + ``` -**Returns:** -Iterator following the last removed element. + * **Overload (3):** Behaves like `emplace` except that the element is constructed as -

+ ``` + value_type( std::piecewise_construct, + std::forward_as_tuple(std::forward(key)), + std::forward_as_tuple(std::forward(args)...) ) + ``` + **Note:** This overload participates in overload resolution only if all following conditions are satisfied: + 1. `Compare::is_transparent` exists and is a valid type. It allows calling this function without constructing an instance of `Key`. + 2. `std::is_convertible_v` is `false`. + 3. `std::is_convertible_v` is `false`. + **Returns:** + The iterator component points to the inserted element or to the already existing element. The `bool` component is `true` if insertion happened and `false` if it did not. -``` -size_type erase(const Key& key); -``` +

-**Effects:** -Removes the element (if one exists) with the key equivalent to `key`. -**Returns:** -Number of elements removed (0 or 1). -

+4. ``` + template + iterator try_emplace(const_iterator hint, const Key& key, Args&&... args); + ``` +5. ``` + template + iterator try_emplace(const_iterator hint, Key&& key, Args&&... args); + ``` +6. ``` + template + iterator try_emplace(const_iterator hint, K&& key, Args&&... args); + ``` + **Preconditions:** + `cbegin() <= hint && hint <= cend()` + **Effects:** + If a key equivalent to `key` already exists in the container, does nothing. + Otherwise, inserts a new element into the container. -``` -template -size_type erase(K&& x); -``` + Iterator `hint` is used as a suggestion where to start to search insert position. -**Effects:** -Removes the element (if one exists) with key that compares equivalent to the value `x`. + * **Overload (4):** Behaves like `emplace_hint` except that the element is constructed as -**Note:** -This overload participates in overload resolution only if `Compare::is_transparent` exists and is a valid type. It allows calling this function without constructing an instance of `Key`. + ``` + value_type( std::piecewise_construct, + std::forward_as_tuple(key), + std::forward_as_tuple(std::forward(args)...) ) + ``` -**Returns:** -Number of elements removed (0 or 1). + * **Overload (5):** Behaves like `emplace_hint` except that the element is constructed as -

+ ``` + value_type( std::piecewise_construct, + std::forward_as_tuple(std::move(key)), + std::forward_as_tuple(std::forward(args)...) ) + ``` + * **Overload (6):** Behaves like `emplace_hint` except that the element is constructed as + ``` + value_type( std::piecewise_construct, + std::forward_as_tuple(std::forward(key)), + std::forward_as_tuple(std::forward(args)...) ) + ``` -### swap + **Note:** This overload participates in overload resolution only if `Compare::is_transparent` exists and is a valid type. It allows calling this function without constructing an instance of `Key`. -``` -void swap(small_flat_map& other); -``` + **Returns:** + Iterator to the inserted element or to the already existing element. -**Preconditions:** -`allocator_traits::propagate_on_container_swap::value || get_allocator() == other.get_allocator()` +

-**Effects:** -Exchanges the contents of the container with those of `other`. -**Complexity:** -Constant in the best case. Linear in `this->size()` plus linear in `other.size()` in the worst case. -

+### erase +1. ``` + iterator erase(iterator pos); + ``` +2. ``` + iterator erase(const_iterator pos); + ``` + **Preconditions:** + `cbegin() <= pos && pos < cend()` -### lower_bound + **Effects:** + Removes the element at `pos`. -``` -iterator lower_bound(const Key& key); -``` -``` -const_iterator lower_bound(const Key& key) const; -``` + **Returns:** + Iterator following the last removed element. -**Effects:** -Returns an iterator pointing to the first element with key that is not less than `key`, or `end()` if such an element is not found. +

-**Complexity:** -Logarithmic in `size()`. -

+3. ``` + iterator erase(const_iterator first, const_iterator last); + ``` + **Preconditions:** + `cbegin() <= first && first <= last && last <= cend()` -``` -template -iterator lower_bound(const K& x); -``` -``` -template -const_iterator lower_bound(const K& x) const; -``` + **Effects:** + Removes the elements in the range `[first, last)`. -**Effects:** -Returns an iterator pointing to the first element with key that compares not less to the value `x`, or `end()` if such an element is not found. + **Returns:** + Iterator following the last removed element. -**Note:** -This overload participates in overload resolution only if `Compare::is_transparent` exists and is a valid type. It allows calling this function without constructing an instance of `Key`. +

-**Complexity:** -Logarithmic in `size()`. -

+4. ``` + size_type erase(const Key& key); + ``` +5. ``` + template + size_type erase(K&& x); + ``` + **Effects:** + Removes the element (if one exists) with the key equivalent to `key` or `x`. -### upper_bound + **Note:** + Overload (5) participates in overload resolution only if `Compare::is_transparent` exists and is a valid type. It allows calling this function without constructing an instance of `Key`. -``` -iterator upper_bound(const Key& key); -``` -``` -const_iterator upper_bound(const Key& key) const; -``` + **Returns:** + Number of elements removed (0 or 1). -**Effects:** -Returns an iterator pointing to the first element with key that is greater than `key`, or `end()` if such an element is not found. +

-**Complexity:** -Logarithmic in `size()`. -

+### swap +1. ``` + void swap(small_flat_map& other); + ``` -``` -template -iterator upper_bound(const K& x); -``` -``` -template -const_iterator upper_bound(const K& x) const; -``` + **Preconditions:** + `allocator_traits::propagate_on_container_swap::value || get_allocator() == other.get_allocator()` -**Effects:** -Returns an iterator pointing to the first element with key that compares greater to the value `x`, or `end()` if such an element is not found. + **Effects:** + Exchanges the contents of the container with those of `other`. -**Note:** -This overload participates in overload resolution only if `Compare::is_transparent` exists and is a valid type. It allows calling this function without constructing an instance of `Key`. + **Complexity:** + Constant in the best case. Linear in `this->size()` plus linear in `other.size()` in the worst case. -**Complexity:** -Logarithmic in `size()`. +

-

+### lower_bound -### equal_range +1. ``` + iterator lower_bound(const Key& key); + ``` +2. ``` + const_iterator lower_bound(const Key& key) const; + ``` +3. ``` + template + iterator lower_bound(const K& x); + ``` +4. ``` + template + const_iterator lower_bound(const K& x) const; + ``` -``` -std::pair equal_range(const Key& key); -``` -``` -std::pair equal_range(const Key& key) const; -``` + **Effects:** + Returns an iterator pointing to the first element with key that compares **not less than** `key` or `x`. Returns `end()` if no such element is found. -**Effects:** -Returns a range containing all elements with the key that is equal to `key`: -* The first iterator in pair points to the first element that is not less than `key`, or `end()` if such an element does not exist. -* The second iterator in pair points to the first element that is greater that `key`, or `end()` is such an element does not exist. + **Note:** + Overloads (3) and (4) participate in overload resolution only if `Compare::is_transparent` exists and is a valid type. It allows calling these functions without constructing an instance of `Key`. -**Complexity:** -Logarithmic in `size()`. + **Complexity:** + Logarithmic in `size()`. -

+

-``` -template -std::pair equal_range(const K& x); -``` -``` -template -std::pair equal_range(const K& x) const; -``` +### upper_bound -**Effects:** -Returns a range containing all elements with the key that compares equal to the value `x`: -* The first iterator in pair points to the first element that compares not less to the value `x`, or `end()` if such an element does not exist. -* The second iterator in pair points to the first element that compares greater to the value `x`, or `end()` is such an element does not exist. +1. ``` + iterator upper_bound(const Key& key); + ``` +2. ``` + const_iterator upper_bound(const Key& key) const; + ``` +3. ``` + template + iterator upper_bound(const K& x); + ``` +4. ``` + template + const_iterator upper_bound(const K& x) const; + ``` -**Note:** -This overload participates in overload resolution only if `Compare::is_transparent` exists and is a valid type. It allows calling this function without constructing an instance of `Key`. + **Effects:** + Returns an iterator pointing to the first element with key that compares **greater than** `key` or `x`. Returns `end()` if no such element is found. -**Complexity:** -Logarithmic in `size()`. + **Note:** + Overloads (3) and (4) participate in overload resolution only if `Compare::is_transparent` exists and is a valid type. It allows calling these functions without constructing an instance of `Key`. -

+ **Complexity:** + Logarithmic in `size()`. +

-### find -``` -iterator find(const Key& key); -``` -``` -const_iterator find(const Key& key) const; -``` - -**Effects:** -Returns an iterator to an element with key equivalent to `key`, or `end()` if such an element is not found. - -**Complexity:** -Logarithmic in `size()`. - -

+### equal_range +1. ``` + std::pair equal_range(const Key& key); + ``` +2. ``` + std::pair equal_range(const Key& key) const; + ``` +3. ``` + template + std::pair equal_range(const K& x); + ``` +4. ``` + template + std::pair equal_range(const K& x) const; + ``` + **Effects:** + Returns a range containing all elements with key that compares equivalent to `key` or `x`. + * The first iterator in pair points to the first element that compares **not less than** `key` or `x`. It is equal to `end()` if no such element is found. + * The second iterator in pair points to the first element that compares **greater than** `key` or `x`. It is equal to `end()` is no such element is found. -``` -template -iterator find(const K& x); -``` -``` -template -const_iterator find(const K& x) const; -``` + **Note:** + Overloads (3) and (4) participate in overload resolution only if `Compare::is_transparent` exists and is a valid type. It allows calling these functions without constructing an instance of `Key`. -**Effects:** -Returns an iterator to an element with key that compares equivalent to `x`, or `end()` if such an element is not found. + **Complexity:** + Logarithmic in `size()`. -**Note:** -This overload participates in overload resolution only if `Compare::is_transparent` exists and is a valid type. It allows calling this function without constructing an instance of `Key`. +

-**Complexity:** -Logarithmic in `size()`. -

+### find +1. ``` + iterator find(const Key& key); + ``` +2. ``` + const_iterator find(const Key& key) const; + ``` +3. ``` + template + iterator find(const K& x); + ``` +4. ``` + template + const_iterator find(const K& x) const; + ``` -### count + **Effects:** + Returns an iterator pointing to the element with key equivalent to `key` or `x`. Returns `end()` if no such element is found. -``` -size_type count(const Key& key) const; -``` + **Note:** + Overloads (3) and (4) participate in overload resolution only if `Compare::is_transparent` exists and is a valid type. It allows calling these functions without constructing an instance of `Key`. -**Effects:** -Returns the number of elements with key equivalent to `key`, which is either 1 or 0 since this container does not allow duplicates. + **Complexity:** + Logarithmic in `size()`. -**Complexity:** -Logarithmic in `size()`. +

-

+### count -``` -template -size_type count(const K& x) const; -``` +1. ``` + size_type count(const Key& key) const; + ``` +2. ``` + template + size_type count(const K& x) const; + ``` -**Effects:** -Returns the number of elements with key that compares equivalent to `x`, which is either 1 or 0 since this container does not allow duplicates. + **Effects:** + Returns the number of elements with key equivalent to `key` or `x`, which is either 1 or 0 since this container does not allow duplicates. -**Note:** -This overload participates in overload resolution only if `Compare::is_transparent` exists and is a valid type. It allows calling this function without constructing an instance of `Key`. + **Note:** + Overload (2) participates in overload resolution only if `Compare::is_transparent` exists and is a valid type. It allows calling this function without constructing an instance of `Key`. -**Complexity:** -Logarithmic in `size()`. + **Complexity:** + Logarithmic in `size()`. -

+

### contains -``` -bool contains(const Key& key) const; -``` - -**Effects:** -Returns `true` if the container contains an element with key equivalent to `key`, otherwise returns `false`. +1. ``` + bool contains(const Key& key) const; + ``` +2. ``` + template + bool contains(const K& x) const; + ``` -**Complexity:** -Logarithmic in `size()`. + **Effects:** + Returns `true` if the container contains an element with key equivalent to `key` or `x`, otherwise returns `false`. -

+ **Note:** + Overload (2) participates in overload resolution only if `Compare::is_transparent` exists and is a valid type. It allows calling this function without constructing an instance of `Key`. + **Complexity:** + Logarithmic in `size()`. +

-``` -template -bool contains(const K& x) const; -``` -**Effects:** -Returns `true` if the container contains an element with the key that compares equivalent to `x`, otherwise returns `false`. -**Note:** -This overload participates in overload resolution only if `Compare::is_transparent` exists and is a valid type. It allows calling this function without constructing an instance of `Key`. +### at -**Complexity:** -Logarithmic in `size()`. +1. ``` + T& at(const Key& key); + ``` +2. ``` + const T& at(const Key& key) const; + ``` +3. ``` + template + const T& at(const K& x) const; + ``` -

+ **Effects:** + Returns a reference to the mapped value of the element with key equivalent to `key` or `x`. If no such element exists, an exception of type `std::out_of_range` is thrown. + **Note:** + Overload (3) participates in overload resolution only if `Compare::is_transparent` exists and is a valid type. It allows calling this function without constructing an instance of `Key`. + **Complexity:** + Logarithmic in `size()`. -### at + **Exceptions:** + `std::out_of_range` if the container does not have an element with the specified key. -``` -T& at(const Key& key); -``` -``` -const T& at(const Key& key) const; -``` +

-**Effects:** -Returns a reference to the mapped value of the element with key equivalent to `key`. If no such element exists, an exception of type `std::out_of_range` is thrown. -**Complexity:** -Logarithmic in `size()`. -**Exceptions:** -`std::out_of_range` if the container does not have an element with the specified key. +### operator[] -

+1. ``` + T& operator[](const Key& key); + ``` +2. ``` + T& operator[](Key&& key); + ``` +3. ``` + template + T& operator[](const K& x); + ``` +4. ``` + template + T& operator[](K&& x); + ``` + **Effects:** + Returns a reference to the value that is mapped to a key equivalent to `key` or `x`, performing an insertion if such key does not already exist. + * Overload (1) is equivalent to + `return try_emplace(key).first->second;` -### operator[] + * Overload (2) is equivalent to + `return try_emplace(std::move(key)).first->second;` -``` -T& operator[](const Key& key); -``` -``` -T& operator[](Key&& key); -``` + * Overload (3) is equivalent to + `return try_emplace(x).first->second;` -**Effects:** -Returns a reference to the value that is mapped to a key equivalent to `key`, performing an insertion if such key does not already exist. + * Overload (4) is equivalent to + `return try_emplace(std::forward(x)).first->second;` -* The first overload is equivalent to: - ``` - return try_emplace(key).first->second; - ``` -* The second overload is equivalent to: - ``` - return try_emplace(std::move(key)).first->second; - ``` + **Note:** + Overloads (3) and (4) participate in overload resolution only if `Compare::is_transparent` exists and is a valid type. It allows calling these functions without constructing an instance of `Key`. -**Complexity:** -Logarithmic in `size()`. + **Complexity:** + Logarithmic in `size()`. -

+

### data -``` -value_type* data() noexcept; -``` -``` -const value_type* data() const noexcept; -``` +1. ``` + value_type* data() noexcept; + ``` +2. ``` + const value_type* data() const noexcept; + ``` -**Effects:** -Returns pointer to the underlying array serving as element storage. The pointer is such that range `[data(), data() + size())` is always a valid range, even if the container is empty. `data()` is not dereferenceable if the container is empty. + **Effects:** + Returns pointer to the underlying array serving as element storage. The pointer is such that range `[data(), data() + size())` is always a valid range, even if the container is empty. `data()` is not dereferenceable if the container is empty. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

@@ -1479,186 +1517,186 @@ Constant. ### operator== -``` -template -bool operator== -( - const small_flat_map& x, - const small_flat_map& y -); -``` +1. ``` + template + bool operator== + ( + const small_flat_map& x, + const small_flat_map& y + ); + ``` -**Effects:** -Checks if the contents of `x` and `y` are equal. + **Effects:** + Checks if the contents of `x` and `y` are equal. -The contents of `x` and `y` are equal if the following conditions hold: -* `x.size() == y.size()` -* Each element in `x` compares equal with the element in `y` at the same position. + The contents of `x` and `y` are equal if the following conditions hold: + * `x.size() == y.size()` + * Each element in `x` compares equal with the element in `y` at the same position. -The comparison is performed by `std::equal`. -This comparison ignores the container's ordering `Compare`. + The comparison is performed by `std::equal`. + This comparison ignores the container's ordering `Compare`. -**Returns:** -Returns `true` if the contents of the `x` and `y` are equal, `false` otherwise. + **Returns:** + Returns `true` if the contents of the `x` and `y` are equal, `false` otherwise. -

+

### operator!= -``` -template -bool operator!= -( - const small_flat_map& x, - const small_flat_map& y -); -``` +1. ``` + template + bool operator!= + ( + const small_flat_map& x, + const small_flat_map& y + ); + ``` -**Effects:** -Checks if the contents of `x` and `y` are equal. + **Effects:** + Checks if the contents of `x` and `y` are equal. -For details see `operator==`. + For details see `operator==`. -**Returns:** -Returns `true` if the contents of the `x` and `y` are not equal, `false` otherwise. + **Returns:** + Returns `true` if the contents of the `x` and `y` are not equal, `false` otherwise. -

+

### operator< -``` -template -bool operator< -( - const small_flat_map& x, - const small_flat_map& y -); -``` +1. ``` + template + bool operator< + ( + const small_flat_map& x, + const small_flat_map& y + ); + ``` -**Effects:** -Compares the contents of `x` and `y` lexicographically. -The comparison is performed by a function `std::lexicographical_compare`. -This comparison ignores the container's ordering `Compare`. + **Effects:** + Compares the contents of `x` and `y` lexicographically. + The comparison is performed by a function `std::lexicographical_compare`. + This comparison ignores the container's ordering `Compare`. -**Returns:** -`true` if the contents of the `x` are lexicographically less than the contents of `y`, `false` otherwise. + **Returns:** + `true` if the contents of the `x` are lexicographically less than the contents of `y`, `false` otherwise. -

+

### operator> -``` -template -bool operator> -( - const small_flat_map& x, - const small_flat_map& y -); -``` +1. ``` + template + bool operator> + ( + const small_flat_map& x, + const small_flat_map& y + ); + ``` -**Effects:** -Compares the contents of lhs and rhs lexicographically. + **Effects:** + Compares the contents of lhs and rhs lexicographically. -The comparison is performed by a function `std::lexicographical_compare`. -This comparison ignores the container's ordering `Compare`. + The comparison is performed by a function `std::lexicographical_compare`. + This comparison ignores the container's ordering `Compare`. -**Returns:** -`true` if the contents of the `x` are lexicographically greater than the contents of `y`, `false` otherwise. + **Returns:** + `true` if the contents of the `x` are lexicographically greater than the contents of `y`, `false` otherwise. -

+

### operator<= -``` -template -bool operator<= -( - const small_flat_map& x, - const small_flat_map& y -); -``` +1. ``` + template + bool operator<= + ( + const small_flat_map& x, + const small_flat_map& y + ); + ``` -**Effects:** -Compares the contents of `x` and `y` lexicographically. -The comparison is performed by a function `std::lexicographical_compare`. -This comparison ignores the container's ordering `Compare`. + **Effects:** + Compares the contents of `x` and `y` lexicographically. + The comparison is performed by a function `std::lexicographical_compare`. + This comparison ignores the container's ordering `Compare`. -**Returns:** -`true` if the contents of the `x` are lexicographically less than or equal to the contents of `y`, `false` otherwise. + **Returns:** + `true` if the contents of the `x` are lexicographically less than or equal to the contents of `y`, `false` otherwise. -

+

### operator>= -``` -template -bool operator>= -( - const small_flat_map& x, - const small_flat_map& y -); -``` +1. ``` + template + bool operator>= + ( + const small_flat_map& x, + const small_flat_map& y + ); + ``` -**Effects:** -Compares the contents of `x` and `y` lexicographically. -The comparison is performed by a function `std::lexicographical_compare`. -This comparison ignores the container's ordering `Compare`. + **Effects:** + Compares the contents of `x` and `y` lexicographically. + The comparison is performed by a function `std::lexicographical_compare`. + This comparison ignores the container's ordering `Compare`. -**Returns:** -`true` if the contents of the `x` are lexicographically greater than or equal to the contents of `y`, `false` otherwise. + **Returns:** + `true` if the contents of the `x` are lexicographically greater than or equal to the contents of `y`, `false` otherwise. -

+

### swap -``` -template -void swap -( - small_flat_map& x, - small_flat_map& y -); -``` +1. ``` + template + void swap + ( + small_flat_map& x, + small_flat_map& y + ); + ``` -**Effects:** -Swaps the contents of `x` and `y`. Calls `x.swap(y)`. + **Effects:** + Swaps the contents of `x` and `y`. Calls `x.swap(y)`. -

+

### erase_if -``` -template -typename small_flat_map::size_type - erase_if(small_flat_map& c, Predicate pred) -``` +1. ``` + template + typename small_flat_map::size_type + erase_if(small_flat_map& c, Predicate pred) + ``` -**Effects:** -Erases all elements that satisfy the predicate `pred` from the container. + **Effects:** + Erases all elements that satisfy the predicate `pred` from the container. -`pred` is unary predicate which returns `true` if the element should be removed. + `pred` is unary predicate which returns `true` if the element should be removed. -**Returns:** -The number of erased elements. + **Returns:** + The number of erased elements. -**Complexity:** -Linear. + **Complexity:** + Linear. -

+

diff --git a/doc/small_flat_multimap.md b/doc/small_flat_multimap.md index 6fe6cf1..5fa8751 100644 --- a/doc/small_flat_multimap.md +++ b/doc/small_flat_multimap.md @@ -106,7 +106,8 @@ Iterators to elements of `sfl::small_flat_multimap` are random access iterators std::size_t N ``` - Size of the internal statically allocated array. + Size of the internal statically allocated array, i.e. the maximal number of elements that can fit into this array. + This parameter can be zero. 4. ``` @@ -182,1112 +183,1028 @@ static constexpr size_type static_capacity = N; ### (constructor) -``` -small_flat_multimap() - noexcept( +1. ``` + small_flat_multimap() noexcept( std::is_nothrow_default_constructible::value && std::is_nothrow_default_constructible::value ); -``` -``` -explicit small_flat_multimap(const Compare& comp) - noexcept( + ``` +2. ``` + explicit small_flat_multimap(const Compare& comp) noexcept( std::is_nothrow_default_constructible::value && std::is_nothrow_copy_constructible::value ); -``` -``` -explicit small_flat_multimap(const Allocator& alloc) - noexcept( + ``` +3. ``` + explicit small_flat_multimap(const Allocator& alloc) noexcept( std::is_nothrow_copy_constructible::value && std::is_nothrow_default_constructible::value ); -``` -``` -explicit small_flat_multimap(const Compare& comp, const Allocator& alloc) - noexcept( + ``` +4. ``` + explicit small_flat_multimap(const Compare& comp, const Allocator& alloc) noexcept( std::is_nothrow_copy_constructible::value && std::is_nothrow_copy_constructible::value ); -``` + ``` -**Effects:** -Constructs an empty container. + **Effects:** + Constructs an empty container. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

-``` -template -small_flat_multimap(InputIt first, InputIt last); -``` -``` -template -small_flat_multimap(InputIt first, InputIt last, const Compare& comp); -``` -``` -template -small_flat_multimap(InputIt first, InputIt last, const Allocator& alloc); -``` -``` -template -small_flat_multimap(InputIt first, InputIt last, const Compare& comp, const Allocator& alloc); -``` +5. ``` + template + small_flat_multimap(InputIt first, InputIt last); + ``` +6. ``` + template + small_flat_multimap(InputIt first, InputIt last, const Compare& comp); + ``` +7. ``` + template + small_flat_multimap(InputIt first, InputIt last, const Allocator& alloc); + ``` +8. ``` + template + small_flat_multimap(InputIt first, InputIt last, const Compare& comp, const Allocator& alloc); + ``` -**Effects:** -Constructs an empty container and inserts elements from the range `[first, last)`. + **Effects:** + Constructs an empty container and inserts elements from the range `[first, last)`. -**Note:** -This overload participates in overload resolution only if `InputIt` satisfies requirements of [*LegacyInputIterator*](https://en.cppreference.com/w/cpp/named_req/InputIterator). + **Note:** + These overloads participate in overload resolution only if `InputIt` satisfies requirements of [*LegacyInputIterator*](https://en.cppreference.com/w/cpp/named_req/InputIterator). -**Complexity:** -Linear in `std::distance(first, last)`. + **Complexity:** + Linear in `std::distance(first, last)`. -

+

-``` -small_flat_multimap(std::initializer_list ilist); -``` -``` -small_flat_multimap(std::initializer_list ilist, const Compare& comp); -``` -``` -small_flat_multimap(std::initializer_list ilist, const Allocator& alloc); -``` -``` -small_flat_multimap(std::initializer_list ilist, const Compare& comp, const Allocator& alloc); -``` +9. ``` + small_flat_multimap(std::initializer_list ilist); + ``` +10. ``` + small_flat_multimap(std::initializer_list ilist, const Compare& comp); + ``` +11. ``` + small_flat_multimap(std::initializer_list ilist, const Allocator& alloc); + ``` +12. ``` + small_flat_multimap(std::initializer_list ilist, const Compare& comp, const Allocator& alloc); + ``` -**Effects:** -Constructs an empty container and inserts elements from the initializer list `ilist`. + **Effects:** + Constructs an empty container and inserts elements from the initializer list `ilist`. -**Complexity:** -Linear in `ilist.size()`. + **Complexity:** + Linear in `ilist.size()`. -

+

-``` -small_flat_multimap(const small_flat_multimap& other); -``` -``` -small_flat_multimap(const small_flat_multimap& other, const Allocator& alloc); -``` +13. ``` + small_flat_multimap(const small_flat_multimap& other); + ``` +14. ``` + small_flat_multimap(const small_flat_multimap& other, const Allocator& alloc); + ``` -**Effects:** -Copy constructor. -Constructs the container with the copy of the contents of `other`. + **Effects:** + Copy constructor. + Constructs the container with the copy of the contents of `other`. -**Complexity:** -Linear in `other.size()`. + **Complexity:** + Linear in `other.size()`. -

+

-``` -small_flat_multimap(small_flat_multimap&& other); -``` -``` -small_flat_multimap(small_flat_multimap&& other, const Allocator& alloc); -``` +15. ``` + small_flat_multimap(small_flat_multimap&& other); + ``` +16. ``` + small_flat_multimap(small_flat_multimap&& other, const Allocator& alloc); + ``` -**Effects:** -Move constructor. -Constructs the container with the contents of `other` using move semantics. + **Effects:** + Move constructor. + Constructs the container with the contents of `other` using move semantics. -`other` is not guaranteed to be empty after the move. + `other` is not guaranteed to be empty after the move. -`other` is in a valid but unspecified state after the move. + `other` is in a valid but unspecified state after the move. -**Complexity:** -Constant in the best case. Linear in `N` in the worst case. + **Complexity:** + Constant in the best case. Linear in `N` in the worst case. -

+

### (destructor) -``` -~small_flat_multimap(); -``` +1. ``` + ~small_flat_multimap(); + ``` -**Effects:** -Destructs the container. The destructors of the elements are called and the used storage is deallocated. + **Effects:** + Destructs the container. The destructors of the elements are called and the used storage is deallocated. -**Complexity:** -Linear in `size()`. + **Complexity:** + Linear in `size()`. -

+

### operator= -``` -small_flat_multimap& operator=(const small_flat_multimap& other); -``` +1. ``` + small_flat_multimap& operator=(const small_flat_multimap& other); + ``` -**Effects:** -Copy assignment operator. -Replaces the contents with a copy of the contents of `other`. + **Effects:** + Copy assignment operator. + Replaces the contents with a copy of the contents of `other`. -**Returns:** -`*this()`. + **Returns:** + `*this()`. -**Complexity:** -Linear in `this->size()` plus linear in `other.size()`. + **Complexity:** + Linear in `this->size()` plus linear in `other.size()`. -

+

-``` -small_flat_multimap& operator=(small_flat_multimap&& other); -``` +2. ``` + small_flat_multimap& operator=(small_flat_multimap&& other); + ``` -**Effects:** -Move assignment operator. -Replaces the contents with those of `other` using move semantics. + **Effects:** + Move assignment operator. + Replaces the contents with those of `other` using move semantics. -`other` is not guaranteed to be empty after the move. + `other` is not guaranteed to be empty after the move. -`other` is in a valid but unspecified state after the move. + `other` is in a valid but unspecified state after the move. -**Returns:** -`*this()`. + **Returns:** + `*this()`. -**Complexity:** + **Complexity:** -* The best case: Linear in `this->size()` plus constant. -* The worst case: Linear in `this->size()` plus linear in `other.size()`. + * The best case: Linear in `this->size()` plus constant. + * The worst case: Linear in `this->size()` plus linear in `other.size()`. -

+

-``` -small_flat_multimap& operator=(std::initializer_list ilist); -``` +3. ``` + small_flat_multimap& operator=(std::initializer_list ilist); + ``` -**Effects:** -Replaces the contents with those identified by initializer list `ilist`. + **Effects:** + Replaces the contents with those identified by initializer list `ilist`. -**Returns:** -`*this()`. + **Returns:** + `*this()`. -**Complexity:** -Linear in `this->size()` plus linear in `ilist.size()`. + **Complexity:** + Linear in `this->size()` plus linear in `ilist.size()`. -

+

### get_allocator -``` -allocator_type get_allocator() const noexcept; -``` +1. ``` + allocator_type get_allocator() const noexcept; + ``` -**Effects:** -Returns the allocator associated with the container. + **Effects:** + Returns the allocator associated with the container. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

### key_comp -``` -key_compare key_comp() const; -``` +1. ``` + key_compare key_comp() const; + ``` -**Effects:** -Returns the function object that compares the keys, which is a copy of this container's constructor argument `comp`. + **Effects:** + Returns the function object that compares the keys, which is a copy of this container's constructor argument `comp`. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

### value_comp -``` -value_compare value_comp() const; -``` +1. ``` + value_compare value_comp() const; + ``` -**Effects:** -Returns a function object that compares objects of type `value_type`. + **Effects:** + Returns a function object that compares objects of type `value_type`. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

### begin, cbegin -``` -iterator begin() noexcept; -``` -``` -const_iterator begin() const noexcept; -``` -``` -const_iterator cbegin() const noexcept; -``` - -**Effects:** -Returns an iterator to the first element of the container. +1. ``` + iterator begin() noexcept; + ``` +2. ``` + const_iterator begin() const noexcept; + ``` +3. ``` + const_iterator cbegin() const noexcept; + ``` -If the container is empty, the returned iterator will be equal to `end()`. + **Effects:** + Returns an iterator to the first element of the container. + If the container is empty, the returned iterator will be equal to `end()`. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

### end, cend -``` -iterator end() noexcept; -``` -``` -const_iterator end() const noexcept; -``` -``` -const_iterator cend() const noexcept; -``` - -**Effects:** -Returns an iterator to the element following the last element of the container. +1. ``` + iterator end() noexcept; + ``` +2. ``` + const_iterator end() const noexcept; + ``` +3. ``` + const_iterator cend() const noexcept; + ``` -This element acts as a placeholder; attempting to access it results in undefined behavior. + **Effects:** + Returns an iterator to the element following the last element of the container. + This element acts as a placeholder; attempting to access it results in undefined behavior. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

### rbegin, crbegin -``` -reverse_iterator rbegin() noexcept; -``` -``` -const_reverse_iterator rbegin() const noexcept; -``` -``` -const_reverse_iterator crbegin() const noexcept; -``` +1. ``` + reverse_iterator rbegin() noexcept; + ``` +2. ``` + const_reverse_iterator rbegin() const noexcept; + ``` +3. ``` + const_reverse_iterator crbegin() const noexcept; + ``` -**Effects:** -Returns a reverse iterator to the first element of the reversed container. -It corresponds to the last element of the non-reversed container. -If the container is empty, the returned iterator is equal to `rend()`. + **Effects:** + Returns a reverse iterator to the first element of the reversed container. + It corresponds to the last element of the non-reversed container. + If the container is empty, the returned iterator is equal to `rend()`. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

### rend, crend -``` -reverse_iterator rend() noexcept; -``` -``` -const_reverse_iterator rend() const noexcept; -``` -``` -const_reverse_iterator crend() const noexcept; -``` +1. ``` + reverse_iterator rend() noexcept; + ``` +2. ``` + const_reverse_iterator rend() const noexcept; + ``` +3. ``` + const_reverse_iterator crend() const noexcept; + ``` -**Effects:** -Returns a reverse iterator to the element following the last element of the reversed container. -It corresponds to the element preceding the first element of the non-reversed container. -This element acts as a placeholder, attempting to access it results in undefined behavior. + **Effects:** + Returns a reverse iterator to the element following the last element of the reversed container. + It corresponds to the element preceding the first element of the non-reversed container. + This element acts as a placeholder, attempting to access it results in undefined behavior. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

### nth -``` -iterator nth(size_type pos) noexcept; -``` -``` -const_iterator nth(size_type pos) const noexcept; -``` +1. ``` + iterator nth(size_type pos) noexcept; + ``` +2. ``` + const_iterator nth(size_type pos) const noexcept; + ``` -**Preconditions:** -`pos <= size()` + **Preconditions:** + `pos <= size()` -**Effects:** -Returns an iterator to the element at position `pos`. -If `pos == size()`, the returned iterator is equal to `end()`. + **Effects:** + Returns an iterator to the element at position `pos`. -**Complexity:** -Constant. + If `pos == size()`, the returned iterator is equal to `end()`. -

+ **Complexity:** + Constant. + +

### index_of -``` -size_type index_of(const_iterator pos) const noexcept; -``` +1. ``` + size_type index_of(const_iterator pos) const noexcept; + ``` -**Preconditions:** -`cbegin() <= pos && pos <= cend()` + **Preconditions:** + `cbegin() <= pos && pos <= cend()` -**Effects:** -Returns position of the element pointed by iterator `pos`, i.e. `std::distance(begin(), pos)`. + **Effects:** + Returns position of the element pointed by iterator `pos`, i.e. `std::distance(begin(), pos)`. -If `pos == end()`, the returned value is equal to `size()`. + If `pos == end()`, the returned value is equal to `size()`. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

### empty -``` -bool empty() const noexcept; -``` +1. ``` + bool empty() const noexcept; + ``` -**Effects:** -Returns `true` if the container has no elements, i.e. whether `begin() == end()`. + **Effects:** + Returns `true` if the container has no elements, i.e. whether `begin() == end()`. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

### size -``` -size_type size() const noexcept; -``` +1. ``` + size_type size() const noexcept; + ``` -**Effects:** -Returns the number of elements in the container, i.e. `std::distance(begin(), end())`. + **Effects:** + Returns the number of elements in the container, i.e. `std::distance(begin(), end())`. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

### max_size -``` -size_type max_size() const noexcept; -``` +1. ``` + size_type max_size() const noexcept; + ``` -**Effects:** -Returns the maximum number of elements the container is able to hold, i.e. `std::distance(begin(), end())` for the largest container. + **Effects:** + Returns the maximum number of elements the container is able to hold, i.e. `std::distance(begin(), end())` for the largest container. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

### capacity -``` -size_type capacity() const noexcept; -``` +1. ``` + size_type capacity() const noexcept; + ``` -**Effects:** -Returns the number of elements that the container has currently allocated space for. + **Effects:** + Returns the number of elements that the container has currently allocated space for. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

### available -``` -size_type available() const noexcept; -``` +1. ``` + size_type available() const noexcept; + ``` -**Effects:** -Returns the number of elements that can be inserted into the container without requiring allocation of additional memory. + **Effects:** + Returns the number of elements that can be inserted into the container without requiring allocation of additional memory. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

### reserve -``` -void reserve(size_type new_cap); -``` +1. ``` + void reserve(size_type new_cap); + ``` -**Effects:** -Tries to increase capacity by allocating additional memory. + **Effects:** + Tries to increase capacity by allocating additional memory. -If `new_cap > capacity()`, the function allocates memory for new storage of capacity equal to the value of `new_cap`, moves elements from old storage to new storage, and deallocates memory used by old storage. Otherwise, the function does nothing. + If `new_cap > capacity()`, the function allocates memory for new storage of capacity equal to the value of `new_cap`, moves elements from old storage to new storage, and deallocates memory used by old storage. Otherwise, the function does nothing. -This function does not change size of the container. + This function does not change size of the container. -If the capacity is changed, all iterators and all references to the elements are invalidated. Otherwise, no iterators or references are invalidated. + If the capacity is changed, all iterators and all references to the elements are invalidated. Otherwise, no iterators or references are invalidated. -**Complexity:** -Linear. + **Complexity:** + Linear. -**Exceptions:** + **Exceptions:** -* `Allocator::allocate` may throw. -* `T`'s move or copy constructor may throw. + * `Allocator::allocate` may throw. + * `T`'s move or copy constructor may throw. -If an exception is thrown: + If an exception is thrown: -* If type `T` has available `noexcept` move constructor: - * This function has no effects (strong exception guarantee). -* Else if type `T` has available copy constructor: - * This function has no effects (strong exception guarantee). -* Else if type `T` has available throwing move constructor: - * Container is changed but in valid state (basic exception guarantee). + * If type `T` has available `noexcept` move constructor: + * This function has no effects (strong exception guarantee). + * Else if type `T` has available copy constructor: + * This function has no effects (strong exception guarantee). + * Else if type `T` has available throwing move constructor: + * Container is changed but in valid state (basic exception guarantee). -

+

### shrink_to_fit -``` -void shrink_to_fit(); -``` +1. ``` + void shrink_to_fit(); + ``` -**Effects:** -Tries to reduce memory usage by freeing unused memory. + **Effects:** + Tries to reduce memory usage by freeing unused memory. -1. If `size() > N && size() < capacity()`, the function allocates memory for new storage of capacity equal to the value of `size()`, moves elements from old storage to new storage, and deallocates memory used by old storage. -2. If `size() <= N && N < capacity()`, the function sets new storage to be internal statically allocated array of capacity `N`, moves elements from old storage to new storage, and deallocates memory used by old storage. -3. Otherwise the function does nothing. + 1. If `size() > N && size() < capacity()`, the function allocates memory for new storage of capacity equal to the value of `size()`, moves elements from old storage to new storage, and deallocates memory used by old storage. -This function does not change size of the container. + 2. If `size() <= N && N < capacity()`, the function sets new storage to be internal statically allocated array of capacity `N`, moves elements from old storage to new storage, and deallocates memory used by old storage. -If the capacity is changed, all iterators and all references to the elements are invalidated. Otherwise, no iterators or references are invalidated. + 3. Otherwise the function does nothing. -**Complexity:** -Linear. + This function does not change size of the container. -**Exceptions:** + If the capacity is changed, all iterators and all references to the elements are invalidated. Otherwise, no iterators or references are invalidated. -* `Allocator::allocate` may throw. -* `T`'s move or copy constructor may throw. + **Complexity:** + Linear. -If an exception is thrown: + **Exceptions:** -* If type `T` has available `noexcept` move constructor: - * This function has no effects (strong exception guarantee). -* Else if type `T` has available copy constructor: - * This function has no effects (strong exception guarantee). -* Else if type `T` has available throwing move constructor: - * Container is changed but in valid state (basic exception guarantee). + * `Allocator::allocate` may throw. + * `T`'s move or copy constructor may throw. -

+ If an exception is thrown: + + * If type `T` has available `noexcept` move constructor: + * This function has no effects (strong exception guarantee). + * Else if type `T` has available copy constructor: + * This function has no effects (strong exception guarantee). + * Else if type `T` has available throwing move constructor: + * Container is changed but in valid state (basic exception guarantee). + +

### clear -``` -void clear() noexcept; -``` +1. ``` + void clear() noexcept; + ``` -**Effects:** -Erases all elements from the container. -After this call, `size()` returns zero and `capacity()` remains unchanged. + **Effects:** + Erases all elements from the container. + After this call, `size()` returns zero and `capacity()` remains unchanged. -**Complexity:** -Linear in `size()`. + **Complexity:** + Linear in `size()`. -

+

### emplace -``` -template -iterator emplace(Args&&... args); -``` +1. ``` + template + iterator emplace(Args&&... args); + ``` -**Effects:** -Inserts a new element into the container. + **Effects:** + Inserts a new element into the container. -New element is constructed as `value_type(std::forward(args)...)`. + New element is constructed as `value_type(std::forward(args)...)`. -**Returns:** -Iterator to the inserted element. + **Returns:** + Iterator to the inserted element. -

+

### emplace_hint -``` -template -iterator emplace_hint(const_iterator hint, Args&&... args); -``` +1. ``` + template + iterator emplace_hint(const_iterator hint, Args&&... args); + ``` -**Preconditions:** -`cbegin() <= hint && hint <= cend()` + **Preconditions:** + `cbegin() <= hint && hint <= cend()` -**Effects:** -Inserts a new element into the container. + **Effects:** + Inserts a new element into the container. -New element is constructed as `value_type(std::forward(args)...)`. + New element is constructed as `value_type(std::forward(args)...)`. -Iterator `hint` is used as a suggestion where to start to search insert position. + Iterator `hint` is used as a suggestion where to start to search insert position. -**Returns:** -Iterator to the inserted element. + **Returns:** + Iterator to the inserted element. -

+

### insert -``` -iterator insert(const value_type& value); -``` +1. ``` + iterator insert(const value_type& value); + ``` -**Effects:** -Inserts copy of `value`. + **Effects:** + Inserts copy of `value`. -**Returns:** -Iterator to the inserted element. + **Returns:** + Iterator to the inserted element. -

+

-``` -iterator insert(value_type&& value); -``` +2. ``` + iterator insert(value_type&& value); + ``` -**Effects:** -Inserts `value` using move semantics. + **Effects:** + Inserts `value` using move semantics. -**Returns:** -Iterator to the inserted element. + **Returns:** + Iterator to the inserted element. -

+

-``` -template -iterator insert(P&& value); -``` +3. ``` + template + iterator insert(P&& value); + ``` -**Effects:** -Inserts a new element into the container. + **Effects:** + Inserts a new element into the container. -New element is constructed as `value_type(std::forward

(value))`. + New element is constructed as `value_type(std::forward

(value))`. -**Note:** -This overload participates in overload resolution only if `std::is_constructible::value` is `true`. + **Note:** + This overload participates in overload resolution only if `std::is_constructible::value` is `true`. -**Returns:** -Iterator to the inserted element. + **Returns:** + Iterator to the inserted element. -

+

-``` -iterator insert(const_iterator hint, const value_type& value); -``` +4. ``` + iterator insert(const_iterator hint, const value_type& value); + ``` -**Preconditions:** -`cbegin() <= hint && hint <= cend()` + **Preconditions:** + `cbegin() <= hint && hint <= cend()` -**Effects:** -Inserts copy of `value`. + **Effects:** + Inserts copy of `value`. -Iterator `hint` is used as a suggestion where to start to search insert position. + Iterator `hint` is used as a suggestion where to start to search insert position. -**Returns:** -Iterator to the inserted element. + **Returns:** + Iterator to the inserted element. -

+

-``` -iterator insert(const_iterator hint, value_type&& value); -``` +5. ``` + iterator insert(const_iterator hint, value_type&& value); + ``` -**Preconditions:** -`cbegin() <= hint && hint <= cend()` + **Preconditions:** + `cbegin() <= hint && hint <= cend()` -**Effects:** -Inserts `value` using move semantics. + **Effects:** + Inserts `value` using move semantics. -Iterator `hint` is used as a suggestion where to start to search insert position. + Iterator `hint` is used as a suggestion where to start to search insert position. -**Returns:** -Iterator to the inserted element. + **Returns:** + Iterator to the inserted element. -

+

-``` -template -iterator insert(const_iterator hint, P&& value); -``` +6. ``` + template + iterator insert(const_iterator hint, P&& value); + ``` -**Preconditions:** -`cbegin() <= hint && hint <= cend()` + **Preconditions:** + `cbegin() <= hint && hint <= cend()` -**Effects:** -Inserts a new element into the container. + **Effects:** + Inserts a new element into the container. -New element is constructed as `value_type(std::forward

(value))`. + New element is constructed as `value_type(std::forward

(value))`. -Iterator `hint` is used as a suggestion where to start to search insert position. + Iterator `hint` is used as a suggestion where to start to search insert position. -**Note:** -This overload participates in overload resolution only if `std::is_constructible::value` is `true`. + **Note:** + This overload participates in overload resolution only if `std::is_constructible::value` is `true`. -**Returns:** -Iterator to the inserted element. + **Returns:** + Iterator to the inserted element. -

+

-``` -template -void insert(InputIt first, InputIt last); -``` +7. ``` + template + void insert(InputIt first, InputIt last); + ``` -**Effects:** -Inserts elements from range `[first, last)`. + **Effects:** + Inserts elements from range `[first, last)`. -The call to this function is equivalent to: -``` -while (first != last) -{ - insert(*first); - ++first; -} -``` + The call to this function is equivalent to: + ``` + while (first != last) + { + insert(*first); + ++first; + } + ``` -**Note:** -This overload participates in overload resolution only if `InputIt` satisfies requirements of [*LegacyInputIterator*](https://en.cppreference.com/w/cpp/named_req/InputIterator). + **Note:** + This overload participates in overload resolution only if `InputIt` satisfies requirements of [*LegacyInputIterator*](https://en.cppreference.com/w/cpp/named_req/InputIterator). -

+

-``` -void insert(std::initializer_list ilist); -``` +8. ``` + void insert(std::initializer_list ilist); + ``` -**Effects:** -Inserts elements from initializer list `ilist`. + **Effects:** + Inserts elements from initializer list `ilist`. -The call to this function is equivalent to: -``` -insert(ilist.begin(), ilist.end()); -``` + The call to this function is equivalent to `insert(ilist.begin(), ilist.end())`. -

+

### erase -``` -iterator erase(iterator pos); -``` -``` -iterator erase(const_iterator pos); -``` - -**Preconditions:** -`cbegin() <= pos && pos < cend()` - -**Effects:** -Removes the element at `pos`. - -**Returns:** -Iterator following the last removed element. - -

- - +1. ``` + iterator erase(iterator pos); + ``` +2. ``` + iterator erase(const_iterator pos); + ``` -``` -iterator erase(const_iterator first, const_iterator last); -``` + **Preconditions:** + `cbegin() <= pos && pos < cend()` -**Preconditions:** -`cbegin() <= first && first <= last && last <= cend()` + **Effects:** + Removes the element at `pos`. -**Effects:** -Removes the elements in the range `[first, last)`. + **Returns:** + Iterator following the last removed element. -**Returns:** -Iterator following the last removed element. +

-

+3. ``` + iterator erase(const_iterator first, const_iterator last); + ``` -``` -size_type erase(const Key& key); -``` + **Preconditions:** + `cbegin() <= first && first <= last && last <= cend()` -**Effects:** -Removes all elements with the key equivalent to `key`. + **Effects:** + Removes the elements in the range `[first, last)`. -**Returns:** -Number of elements removed. + **Returns:** + Iterator following the last removed element. -

+

-``` -template -size_type erase(K&& x); -``` +4. ``` + size_type erase(const Key& key); + ``` +5. ``` + template + size_type erase(K&& x); + ``` -**Effects:** -Removes all elements with key that compares equivalent to the value `x`. + **Effects:** + Removes all elements with the key equivalent to `key` or `x`. -**Note:** -This overload participates in overload resolution only if `Compare::is_transparent` exists and is a valid type. It allows calling this function without constructing an instance of `Key`. + **Note:** + Overload (5) participates in overload resolution only if `Compare::is_transparent` exists and is a valid type. It allows calling this function without constructing an instance of `Key`. -**Returns:** -Number of elements removed. + **Returns:** + Number of elements removed. -

+

### swap -``` -void swap(small_flat_multimap& other); -``` +1. ``` + void swap(small_flat_multimap& other); + ``` -**Preconditions:** -`allocator_traits::propagate_on_container_swap::value || get_allocator() == other.get_allocator()` + **Preconditions:** + `allocator_traits::propagate_on_container_swap::value || get_allocator() == other.get_allocator()` -**Effects:** -Exchanges the contents of the container with those of `other`. + **Effects:** + Exchanges the contents of the container with those of `other`. -**Complexity:** -Constant in the best case. Linear in `this->size()` plus linear in `other.size()` in the worst case. + **Complexity:** + Constant in the best case. Linear in `this->size()` plus linear in `other.size()` in the worst case. -

+

### lower_bound -``` -iterator lower_bound(const Key& key); -``` -``` -const_iterator lower_bound(const Key& key) const; -``` - -**Effects:** -Returns an iterator pointing to the first element with key that is not less than `key`, or `end()` if such an element is not found. - -**Complexity:** -Logarithmic in `size()`. - -

- - - -``` -template -iterator lower_bound(const K& x); -``` -``` -template -const_iterator lower_bound(const K& x) const; -``` +1. ``` + iterator lower_bound(const Key& key); + ``` +2. ``` + const_iterator lower_bound(const Key& key) const; + ``` +3. ``` + template + iterator lower_bound(const K& x); + ``` +4. ``` + template + const_iterator lower_bound(const K& x) const; + ``` -**Effects:** -Returns an iterator pointing to the first element with key that compares not less to the value `x`, or `end()` if such an element is not found. + **Effects:** + Returns an iterator pointing to the first element with key that compares **not less than** `key` or `x`. Returns `end()` if no such element is found. -**Note:** -This overload participates in overload resolution only if `Compare::is_transparent` exists and is a valid type. It allows calling this function without constructing an instance of `Key`. + **Note:** + Overloads (3) and (4) participate in overload resolution only if `Compare::is_transparent` exists and is a valid type. It allows calling these functions without constructing an instance of `Key`. -**Complexity:** -Logarithmic in `size()`. + **Complexity:** + Logarithmic in `size()`. -

+

### upper_bound -``` -iterator upper_bound(const Key& key); -``` -``` -const_iterator upper_bound(const Key& key) const; -``` - -**Effects:** -Returns an iterator pointing to the first element with key that is greater than `key`, or `end()` if such an element is not found. - -**Complexity:** -Logarithmic in `size()`. - -

- - - -``` -template -iterator upper_bound(const K& x); -``` -``` -template -const_iterator upper_bound(const K& x) const; -``` +1. ``` + iterator upper_bound(const Key& key); + ``` +2. ``` + const_iterator upper_bound(const Key& key) const; + ``` +3. ``` + template + iterator upper_bound(const K& x); + ``` +4. ``` + template + const_iterator upper_bound(const K& x) const; + ``` -**Effects:** -Returns an iterator pointing to the first element with key that compares greater to the value `x`, or `end()` if such an element is not found. + **Effects:** + Returns an iterator pointing to the first element with key that compares **greater than** `key` or `x`. Returns `end()` if no such element is found. -**Note:** -This overload participates in overload resolution only if `Compare::is_transparent` exists and is a valid type. It allows calling this function without constructing an instance of `Key`. + **Note:** + Overloads (3) and (4) participate in overload resolution only if `Compare::is_transparent` exists and is a valid type. It allows calling these functions without constructing an instance of `Key`. -**Complexity:** -Logarithmic in `size()`. + **Complexity:** + Logarithmic in `size()`. -

+

### equal_range -``` -std::pair equal_range(const Key& key); -``` -``` -std::pair equal_range(const Key& key) const; -``` - -**Effects:** -Returns a range containing all elements with the key that is equal to `key`: -* The first iterator in pair points to the first element that is not less than `key`, or `end()` if such an element does not exist. -* The second iterator in pair points to the first element that is greater that `key`, or `end()` is such an element does not exist. - -**Complexity:** -Logarithmic in `size()`. - -

- - - -``` -template -std::pair equal_range(const K& x); -``` -``` -template -std::pair equal_range(const K& x) const; -``` +1. ``` + std::pair equal_range(const Key& key); + ``` +2. ``` + std::pair equal_range(const Key& key) const; + ``` +3. ``` + template + std::pair equal_range(const K& x); + ``` +4. ``` + template + std::pair equal_range(const K& x) const; + ``` -**Effects:** -Returns a range containing all elements with the key that compares equal to the value `x`: -* The first iterator in pair points to the first element that compares not less to the value `x`, or `end()` if such an element does not exist. -* The second iterator in pair points to the first element that compares greater to the value `x`, or `end()` is such an element does not exist. + **Effects:** + Returns a range containing all elements with key that compares equivalent to `key` or `x`. + * The first iterator in pair points to the first element that compares **not less than** `key` or `x`. It is equal to `end()` if no such element is found. + * The second iterator in pair points to the first element that compares **greater than** `key` or `x`. It is equal to `end()` is no such element is found. -**Note:** -This overload participates in overload resolution only if `Compare::is_transparent` exists and is a valid type. It allows calling this function without constructing an instance of `Key`. + **Note:** + Overloads (3) and (4) participate in overload resolution only if `Compare::is_transparent` exists and is a valid type. It allows calling these functions without constructing an instance of `Key`. -**Complexity:** -Logarithmic in `size()`. + **Complexity:** + Logarithmic in `size()`. -

+

### find -``` -iterator find(const Key& key); -``` -``` -const_iterator find(const Key& key) const; -``` - -**Effects:** -Returns an iterator to an element with key equivalent to `key`, or `end()` if such an element is not found. If there are several elements with key in the container, any of them may be returned. - -**Complexity:** -Logarithmic in `size()`. - -

- - - -``` -template -iterator find(const K& x); -``` -``` -template -const_iterator find(const K& x) const; -``` +1. ``` + iterator find(const Key& key); + ``` +2. ``` + const_iterator find(const Key& key) const; + ``` +3. ``` + template + iterator find(const K& x); + ``` +4. ``` + template + const_iterator find(const K& x) const; + ``` -**Effects:** -Returns an iterator to an element with key that compares equivalent to `x`, or `end()` if such an element is not found. If there are several elements with key in the container, any of them may be returned. + **Effects:** + Returns an iterator pointing to the element with key equivalent to `key` or `x`. Returns `end()` if no such element is found. + If there are several elements with key in the container, any of them may be returned. -**Note:** -This overload participates in overload resolution only if `Compare::is_transparent` exists and is a valid type. It allows calling this function without constructing an instance of `Key`. + **Note:** + Overloads (3) and (4) participate in overload resolution only if `Compare::is_transparent` exists and is a valid type. It allows calling these functions without constructing an instance of `Key`. -**Complexity:** -Logarithmic in `size()`. + **Complexity:** + Logarithmic in `size()`. -

+

### count -``` -size_type count(const Key& key) const; -``` - -**Effects:** -Returns the number of elements with key equivalent to `key`. - -**Complexity:** -Logarithmic in `size()` plus linear in the number of the elements found. - -

- - - -``` -template -size_type count(const K& x) const; -``` +1. ``` + size_type count(const Key& key) const; + ``` +2. ``` + template + size_type count(const K& x) const; + ``` -**Effects:** -Returns the number of elements with key that compares equivalent to the value `x`. + **Effects:** + Returns the number of elements with key equivalent to `key` or `x`. -**Note:** -This overload participates in overload resolution only if `Compare::is_transparent` exists and is a valid type. It allows calling this function without constructing an instance of `Key`. + **Note:** + Overload (2) participates in overload resolution only if `Compare::is_transparent` exists and is a valid type. It allows calling this function without constructing an instance of `Key`. -**Complexity:** -Logarithmic in `size()` plus linear in the number of the elements found. + **Complexity:** + Logarithmic in `size()` plus linear in the number of the elements found. -

+

### contains -``` -bool contains(const Key& key) const; -``` - -**Effects:** -Returns `true` if the container contains an element with key equivalent to `key`, otherwise returns `false`. - -**Complexity:** -Logarithmic in `size()`. - -

- - - -``` -template -bool contains(const K& x) const; -``` +1. ``` + bool contains(const Key& key) const; + ``` +2. ``` + template + bool contains(const K& x) const; + ``` -**Effects:** -Returns `true` if the container contains an element with the key that compares equivalent to `x`, otherwise returns `false`. + **Effects:** + Returns `true` if the container contains an element with key equivalent to `key` or `x`, otherwise returns `false`. -**Note:** -This overload participates in overload resolution only if `Compare::is_transparent` exists and is a valid type. It allows calling this function without constructing an instance of `Key`. + **Note:** + Overload (2) participates in overload resolution only if `Compare::is_transparent` exists and is a valid type. It allows calling this function without constructing an instance of `Key`. -**Complexity:** -Logarithmic in `size()`. + **Complexity:** + Logarithmic in `size()`. -

+

### data -``` -value_type* data() noexcept; -``` -``` -const value_type* data() const noexcept; -``` +1. ``` + value_type* data() noexcept; + ``` +2. ``` + const value_type* data() const noexcept; + ``` -**Effects:** -Returns pointer to the underlying array serving as element storage. The pointer is such that range `[data(), data() + size())` is always a valid range, even if the container is empty. `data()` is not dereferenceable if the container is empty. + **Effects:** + Returns pointer to the underlying array serving as element storage. The pointer is such that range `[data(), data() + size())` is always a valid range, even if the container is empty. `data()` is not dereferenceable if the container is empty. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

@@ -1295,186 +1212,186 @@ Constant. ### operator== -``` -template -bool operator== -( - const small_flat_multimap& x, - const small_flat_multimap& y -); -``` +1. ``` + template + bool operator== + ( + const small_flat_multimap& x, + const small_flat_multimap& y + ); + ``` -**Effects:** -Checks if the contents of `x` and `y` are equal. + **Effects:** + Checks if the contents of `x` and `y` are equal. -The contents of `x` and `y` are equal if the following conditions hold: -* `x.size() == y.size()` -* Each element in `x` compares equal with the element in `y` at the same position. + The contents of `x` and `y` are equal if the following conditions hold: + * `x.size() == y.size()` + * Each element in `x` compares equal with the element in `y` at the same position. -The comparison is performed by `std::equal`. -This comparison ignores the container's ordering `Compare`. + The comparison is performed by `std::equal`. + This comparison ignores the container's ordering `Compare`. -**Returns:** -Returns `true` if the contents of the `x` and `y` are equal, `false` otherwise. + **Returns:** + Returns `true` if the contents of the `x` and `y` are equal, `false` otherwise. -

+

### operator!= -``` -template -bool operator!= -( - const small_flat_multimap& x, - const small_flat_multimap& y -); -``` +1. ``` + template + bool operator!= + ( + const small_flat_multimap& x, + const small_flat_multimap& y + ); + ``` -**Effects:** -Checks if the contents of `x` and `y` are equal. + **Effects:** + Checks if the contents of `x` and `y` are equal. -For details see `operator==`. + For details see `operator==`. -**Returns:** -Returns `true` if the contents of the `x` and `y` are not equal, `false` otherwise. + **Returns:** + Returns `true` if the contents of the `x` and `y` are not equal, `false` otherwise. -

+

### operator< -``` -template -bool operator< -( - const small_flat_multimap& x, - const small_flat_multimap& y -); -``` +1. ``` + template + bool operator< + ( + const small_flat_multimap& x, + const small_flat_multimap& y + ); + ``` -**Effects:** -Compares the contents of `x` and `y` lexicographically. -The comparison is performed by a function `std::lexicographical_compare`. -This comparison ignores the container's ordering `Compare`. + **Effects:** + Compares the contents of `x` and `y` lexicographically. + The comparison is performed by a function `std::lexicographical_compare`. + This comparison ignores the container's ordering `Compare`. -**Returns:** -`true` if the contents of the `x` are lexicographically less than the contents of `y`, `false` otherwise. + **Returns:** + `true` if the contents of the `x` are lexicographically less than the contents of `y`, `false` otherwise. -

+

### operator> -``` -template -bool operator> -( - const small_flat_multimap& x, - const small_flat_multimap& y -); -``` +1. ``` + template + bool operator> + ( + const small_flat_multimap& x, + const small_flat_multimap& y + ); + ``` -**Effects:** -Compares the contents of lhs and rhs lexicographically. + **Effects:** + Compares the contents of lhs and rhs lexicographically. -The comparison is performed by a function `std::lexicographical_compare`. -This comparison ignores the container's ordering `Compare`. + The comparison is performed by a function `std::lexicographical_compare`. + This comparison ignores the container's ordering `Compare`. -**Returns:** -`true` if the contents of the `x` are lexicographically greater than the contents of `y`, `false` otherwise. + **Returns:** + `true` if the contents of the `x` are lexicographically greater than the contents of `y`, `false` otherwise. -

+

### operator<= -``` -template -bool operator<= -( - const small_flat_multimap& x, - const small_flat_multimap& y -); -``` +1. ``` + template + bool operator<= + ( + const small_flat_multimap& x, + const small_flat_multimap& y + ); + ``` -**Effects:** -Compares the contents of `x` and `y` lexicographically. -The comparison is performed by a function `std::lexicographical_compare`. -This comparison ignores the container's ordering `Compare`. + **Effects:** + Compares the contents of `x` and `y` lexicographically. + The comparison is performed by a function `std::lexicographical_compare`. + This comparison ignores the container's ordering `Compare`. -**Returns:** -`true` if the contents of the `x` are lexicographically less than or equal to the contents of `y`, `false` otherwise. + **Returns:** + `true` if the contents of the `x` are lexicographically less than or equal to the contents of `y`, `false` otherwise. -

+

### operator>= -``` -template -bool operator>= -( - const small_flat_multimap& x, - const small_flat_multimap& y -); -``` +1. ``` + template + bool operator>= + ( + const small_flat_multimap& x, + const small_flat_multimap& y + ); + ``` -**Effects:** -Compares the contents of `x` and `y` lexicographically. -The comparison is performed by a function `std::lexicographical_compare`. -This comparison ignores the container's ordering `Compare`. + **Effects:** + Compares the contents of `x` and `y` lexicographically. + The comparison is performed by a function `std::lexicographical_compare`. + This comparison ignores the container's ordering `Compare`. -**Returns:** -`true` if the contents of the `x` are lexicographically greater than or equal to the contents of `y`, `false` otherwise. + **Returns:** + `true` if the contents of the `x` are lexicographically greater than or equal to the contents of `y`, `false` otherwise. -

+

### swap -``` -template -void swap -( - small_flat_multimap& x, - small_flat_multimap& y -); -``` +1. ``` + template + void swap + ( + small_flat_multimap& x, + small_flat_multimap& y + ); + ``` -**Effects:** -Swaps the contents of `x` and `y`. Calls `x.swap(y)`. + **Effects:** + Swaps the contents of `x` and `y`. Calls `x.swap(y)`. -

+

### erase_if -``` -template -typename small_flat_multimap::size_type - erase_if(small_flat_multimap& c, Predicate pred); -``` +1. ``` + template + typename small_flat_multimap::size_type + erase_if(small_flat_multimap& c, Predicate pred); + ``` -**Effects:** -Erases all elements that satisfy the predicate `pred` from the container. + **Effects:** + Erases all elements that satisfy the predicate `pred` from the container. -`pred` is unary predicate which returns `true` if the element should be removed. + `pred` is unary predicate which returns `true` if the element should be removed. -**Returns:** -The number of erased elements. + **Returns:** + The number of erased elements. -**Complexity:** -Linear. + **Complexity:** + Linear. -

+

diff --git a/doc/small_flat_multiset.md b/doc/small_flat_multiset.md index e8f2e3f..d8e98c8 100644 --- a/doc/small_flat_multiset.md +++ b/doc/small_flat_multiset.md @@ -98,7 +98,8 @@ Iterators to elements of `sfl::small_flat_multiset` are random access iterators std::size_t N ``` - Size of the internal statically allocated array. + Size of the internal statically allocated array, i.e. the maximal number of elements that can fit into this array. + This parameter can be zero. 3. ``` @@ -160,1066 +161,982 @@ static constexpr size_type static_capacity = N; ### (constructor) -``` -small_flat_multiset() - noexcept( +1. ``` + small_flat_multiset() noexcept( std::is_nothrow_default_constructible::value && std::is_nothrow_default_constructible::value ); -``` -``` -explicit small_flat_multiset(const Compare& comp) - noexcept( + ``` +2. ``` + explicit small_flat_multiset(const Compare& comp) noexcept( std::is_nothrow_default_constructible::value && std::is_nothrow_copy_constructible::value ); -``` -``` -explicit small_flat_multiset(const Allocator& alloc) - noexcept( + ``` +3. ``` + explicit small_flat_multiset(const Allocator& alloc) noexcept( std::is_nothrow_copy_constructible::value && std::is_nothrow_default_constructible::value ); -``` -``` -explicit small_flat_multiset(const Compare& comp, const Allocator& alloc) - noexcept( + ``` +4. ``` + explicit small_flat_multiset(const Compare& comp, const Allocator& alloc) noexcept( std::is_nothrow_copy_constructible::value && std::is_nothrow_copy_constructible::value ); -``` + ``` -**Effects:** -Constructs an empty container. + **Effects:** + Constructs an empty container. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

-``` -template -small_flat_multiset(InputIt first, InputIt last); -``` -``` -template -small_flat_multiset(InputIt first, InputIt last, const Compare& comp); -``` -``` -template -small_flat_multiset(InputIt first, InputIt last, const Allocator& alloc); -``` -``` -template -small_flat_multiset(InputIt first, InputIt last, const Compare& comp, const Allocator& alloc); -``` +5. ``` + template + small_flat_multiset(InputIt first, InputIt last); + ``` +6. ``` + template + small_flat_multiset(InputIt first, InputIt last, const Compare& comp); + ``` +7. ``` + template + small_flat_multiset(InputIt first, InputIt last, const Allocator& alloc); + ``` +8. ``` + template + small_flat_multiset(InputIt first, InputIt last, const Compare& comp, const Allocator& alloc); + ``` -**Effects:** -Constructs an empty container and inserts elements from the range `[first, last)`. + **Effects:** + Constructs an empty container and inserts elements from the range `[first, last)`. -**Note:** -This overload participates in overload resolution only if `InputIt` satisfies requirements of [*LegacyInputIterator*](https://en.cppreference.com/w/cpp/named_req/InputIterator). + **Note:** + These overloads participate in overload resolution only if `InputIt` satisfies requirements of [*LegacyInputIterator*](https://en.cppreference.com/w/cpp/named_req/InputIterator). -**Complexity:** -Linear in `std::distance(first, last)`. + **Complexity:** + Linear in `std::distance(first, last)`. -

+

-``` -small_flat_multiset(std::initializer_list ilist); -``` -``` -small_flat_multiset(std::initializer_list ilist, const Compare& comp); -``` -``` -small_flat_multiset(std::initializer_list ilist, const Allocator& alloc); -``` -``` -small_flat_multiset(std::initializer_list ilist, const Compare& comp, const Allocator& alloc); -``` +9. ``` + small_flat_multiset(std::initializer_list ilist); + ``` +10. ``` + small_flat_multiset(std::initializer_list ilist, const Compare& comp); + ``` +11. ``` + small_flat_multiset(std::initializer_list ilist, const Allocator& alloc); + ``` +12. ``` + small_flat_multiset(std::initializer_list ilist, const Compare& comp, const Allocator& alloc); + ``` -**Effects:** -Constructs an empty container and inserts elements from the initializer list `ilist`. + **Effects:** + Constructs an empty container and inserts elements from the initializer list `ilist`. -**Complexity:** -Linear in `ilist.size()`. + **Complexity:** + Linear in `ilist.size()`. -

+

-``` -small_flat_multiset(const small_flat_multiset& other); -``` -``` -small_flat_multiset(const small_flat_multiset& other, const Allocator& alloc); -``` +13. ``` + small_flat_multiset(const small_flat_multiset& other); + ``` +14. ``` + small_flat_multiset(const small_flat_multiset& other, const Allocator& alloc); + ``` -**Effects:** -Copy constructor. -Constructs the container with the copy of the contents of `other`. + **Effects:** + Copy constructor. + Constructs the container with the copy of the contents of `other`. -**Complexity:** -Linear in `other.size()`. + **Complexity:** + Linear in `other.size()`. -

+

-``` -small_flat_multiset(small_flat_multiset&& other); -``` -``` -small_flat_multiset(small_flat_multiset&& other, const Allocator& alloc); -``` +15. ``` + small_flat_multiset(small_flat_multiset&& other); + ``` +16. ``` + small_flat_multiset(small_flat_multiset&& other, const Allocator& alloc); + ``` -**Effects:** -Move constructor. -Constructs the container with the contents of `other` using move semantics. + **Effects:** + Move constructor. + Constructs the container with the contents of `other` using move semantics. -`other` is not guaranteed to be empty after the move. + `other` is not guaranteed to be empty after the move. -`other` is in a valid but unspecified state after the move. + `other` is in a valid but unspecified state after the move. -**Complexity:** -Constant in the best case. Linear in `N` in the worst case. + **Complexity:** + Constant in the best case. Linear in `N` in the worst case. -

+

### (destructor) -``` -~small_flat_multiset(); -``` +1. ``` + ~small_flat_multiset(); + ``` -**Effects:** -Destructs the container. The destructors of the elements are called and the used storage is deallocated. + **Effects:** + Destructs the container. The destructors of the elements are called and the used storage is deallocated. -**Complexity:** -Linear in `size()`. + **Complexity:** + Linear in `size()`. -

+

### operator= -``` -small_flat_multiset& operator=(const small_flat_multiset& other); -``` +1. ``` + small_flat_multiset& operator=(const small_flat_multiset& other); + ``` -**Effects:** -Copy assignment operator. -Replaces the contents with a copy of the contents of `other`. + **Effects:** + Copy assignment operator. + Replaces the contents with a copy of the contents of `other`. -**Returns:** -`*this()`. + **Returns:** + `*this()`. -**Complexity:** -Linear in `this->size()` plus linear in `other.size()`. + **Complexity:** + Linear in `this->size()` plus linear in `other.size()`. -

+

-``` -small_flat_multiset& operator=(small_flat_multiset&& other); -``` +2. ``` + small_flat_multiset& operator=(small_flat_multiset&& other); + ``` -**Effects:** -Move assignment operator. -Replaces the contents with those of `other` using move semantics. + **Effects:** + Move assignment operator. + Replaces the contents with those of `other` using move semantics. -`other` is not guaranteed to be empty after the move. + `other` is not guaranteed to be empty after the move. -`other` is in a valid but unspecified state after the move. + `other` is in a valid but unspecified state after the move. -**Returns:** -`*this()`. + **Returns:** + `*this()`. -**Complexity:** + **Complexity:** -* The best case: Linear in `this->size()` plus constant. -* The worst case: Linear in `this->size()` plus linear in `other.size()`. + * The best case: Linear in `this->size()` plus constant. + * The worst case: Linear in `this->size()` plus linear in `other.size()`. -

+

-``` -small_flat_multiset& operator=(std::initializer_list ilist); -``` +3. ``` + small_flat_multiset& operator=(std::initializer_list ilist); + ``` -**Effects:** -Replaces the contents with those identified by initializer list `ilist`. + **Effects:** + Replaces the contents with those identified by initializer list `ilist`. -**Returns:** -`*this()`. + **Returns:** + `*this()`. -**Complexity:** -Linear in `this->size()` plus linear in `ilist.size()`. + **Complexity:** + Linear in `this->size()` plus linear in `ilist.size()`. -

+

### get_allocator -``` -allocator_type get_allocator() const noexcept; -``` +1. ``` + allocator_type get_allocator() const noexcept; + ``` -**Effects:** -Returns the allocator associated with the container. + **Effects:** + Returns the allocator associated with the container. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

### key_comp -``` -key_compare key_comp() const; -``` +1. ``` + key_compare key_comp() const; + ``` -**Effects:** -Returns the function object that compares the keys, which is a copy of this container's constructor argument `comp`. + **Effects:** + Returns the function object that compares the keys, which is a copy of this container's constructor argument `comp`. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

### value_comp -``` -value_compare value_comp() const; -``` +1. ``` + value_compare value_comp() const; + ``` -**Effects:** -Returns a function object that compares objects of type `value_type`. + **Effects:** + Returns a function object that compares objects of type `value_type`. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

### begin, cbegin -``` -iterator begin() noexcept; -``` -``` -const_iterator begin() const noexcept; -``` -``` -const_iterator cbegin() const noexcept; -``` - -**Effects:** -Returns an iterator to the first element of the container. +1. ``` + iterator begin() noexcept; + ``` +2. ``` + const_iterator begin() const noexcept; + ``` +3. ``` + const_iterator cbegin() const noexcept; + ``` -If the container is empty, the returned iterator will be equal to `end()`. + **Effects:** + Returns an iterator to the first element of the container. + If the container is empty, the returned iterator will be equal to `end()`. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

### end, cend -``` -iterator end() noexcept; -``` -``` -const_iterator end() const noexcept; -``` -``` -const_iterator cend() const noexcept; -``` - -**Effects:** -Returns an iterator to the element following the last element of the container. +1. ``` + iterator end() noexcept; + ``` +2. ``` + const_iterator end() const noexcept; + ``` +3. ``` + const_iterator cend() const noexcept; + ``` -This element acts as a placeholder; attempting to access it results in undefined behavior. + **Effects:** + Returns an iterator to the element following the last element of the container. + This element acts as a placeholder; attempting to access it results in undefined behavior. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

### rbegin, crbegin -``` -reverse_iterator rbegin() noexcept; -``` -``` -const_reverse_iterator rbegin() const noexcept; -``` -``` -const_reverse_iterator crbegin() const noexcept; -``` +1. ``` + reverse_iterator rbegin() noexcept; + ``` +2. ``` + const_reverse_iterator rbegin() const noexcept; + ``` +3. ``` + const_reverse_iterator crbegin() const noexcept; + ``` -**Effects:** -Returns a reverse iterator to the first element of the reversed container. -It corresponds to the last element of the non-reversed container. -If the container is empty, the returned iterator is equal to `rend()`. + **Effects:** + Returns a reverse iterator to the first element of the reversed container. + It corresponds to the last element of the non-reversed container. + If the container is empty, the returned iterator is equal to `rend()`. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

### rend, crend -``` -reverse_iterator rend() noexcept; -``` -``` -const_reverse_iterator rend() const noexcept; -``` -``` -const_reverse_iterator crend() const noexcept; -``` +1. ``` + reverse_iterator rend() noexcept; + ``` +2. ``` + const_reverse_iterator rend() const noexcept; + ``` +3. ``` + const_reverse_iterator crend() const noexcept; + ``` -**Effects:** -Returns a reverse iterator to the element following the last element of the reversed container. -It corresponds to the element preceding the first element of the non-reversed container. -This element acts as a placeholder, attempting to access it results in undefined behavior. + **Effects:** + Returns a reverse iterator to the element following the last element of the reversed container. + It corresponds to the element preceding the first element of the non-reversed container. + This element acts as a placeholder, attempting to access it results in undefined behavior. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

### nth -``` -iterator nth(size_type pos) noexcept; -``` -``` -const_iterator nth(size_type pos) const noexcept; -``` +1. ``` + iterator nth(size_type pos) noexcept; + ``` +2. ``` + const_iterator nth(size_type pos) const noexcept; + ``` -**Preconditions:** -`pos <= size()` + **Preconditions:** + `pos <= size()` -**Effects:** -Returns an iterator to the element at position `pos`. -If `pos == size()`, the returned iterator is equal to `end()`. + **Effects:** + Returns an iterator to the element at position `pos`. -**Complexity:** -Constant. + If `pos == size()`, the returned iterator is equal to `end()`. -

+ **Complexity:** + Constant. + +

### index_of -``` -size_type index_of(const_iterator pos) const noexcept; -``` +1. ``` + size_type index_of(const_iterator pos) const noexcept; + ``` -**Preconditions:** -`cbegin() <= pos && pos <= cend()` + **Preconditions:** + `cbegin() <= pos && pos <= cend()` -**Effects:** -Returns position of the element pointed by iterator `pos`, i.e. `std::distance(begin(), pos)`. + **Effects:** + Returns position of the element pointed by iterator `pos`, i.e. `std::distance(begin(), pos)`. -If `pos == end()`, the returned value is equal to `size()`. + If `pos == end()`, the returned value is equal to `size()`. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

### empty -``` -bool empty() const noexcept; -``` +1. ``` + bool empty() const noexcept; + ``` -**Effects:** -Returns `true` if the container has no elements, i.e. whether `begin() == end()`. + **Effects:** + Returns `true` if the container has no elements, i.e. whether `begin() == end()`. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

### size -``` -size_type size() const noexcept; -``` +1. ``` + size_type size() const noexcept; + ``` -**Effects:** -Returns the number of elements in the container, i.e. `std::distance(begin(), end())`. + **Effects:** + Returns the number of elements in the container, i.e. `std::distance(begin(), end())`. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

### max_size -``` -size_type max_size() const noexcept; -``` +1. ``` + size_type max_size() const noexcept; + ``` -**Effects:** -Returns the maximum number of elements the container is able to hold, i.e. `std::distance(begin(), end())` for the largest container. + **Effects:** + Returns the maximum number of elements the container is able to hold, i.e. `std::distance(begin(), end())` for the largest container. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

### capacity -``` -size_type capacity() const noexcept; -``` +1. ``` + size_type capacity() const noexcept; + ``` -**Effects:** -Returns the number of elements that the container has currently allocated space for. + **Effects:** + Returns the number of elements that the container has currently allocated space for. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

### available -``` -size_type available() const noexcept; -``` +1. ``` + size_type available() const noexcept; + ``` -**Effects:** -Returns the number of elements that can be inserted into the container without requiring allocation of additional memory. + **Effects:** + Returns the number of elements that can be inserted into the container without requiring allocation of additional memory. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

### reserve -``` -void reserve(size_type new_cap); -``` +1. ``` + void reserve(size_type new_cap); + ``` -**Effects:** -Tries to increase capacity by allocating additional memory. + **Effects:** + Tries to increase capacity by allocating additional memory. -If `new_cap > capacity()`, the function allocates memory for new storage of capacity equal to the value of `new_cap`, moves elements from old storage to new storage, and deallocates memory used by old storage. Otherwise, the function does nothing. + If `new_cap > capacity()`, the function allocates memory for new storage of capacity equal to the value of `new_cap`, moves elements from old storage to new storage, and deallocates memory used by old storage. Otherwise, the function does nothing. -This function does not change size of the container. + This function does not change size of the container. -If the capacity is changed, all iterators and all references to the elements are invalidated. Otherwise, no iterators or references are invalidated. + If the capacity is changed, all iterators and all references to the elements are invalidated. Otherwise, no iterators or references are invalidated. -**Complexity:** -Linear. + **Complexity:** + Linear. -**Exceptions:** + **Exceptions:** -* `Allocator::allocate` may throw. -* `T`'s move or copy constructor may throw. + * `Allocator::allocate` may throw. + * `T`'s move or copy constructor may throw. -If an exception is thrown: + If an exception is thrown: -* If type `T` has available `noexcept` move constructor: - * This function has no effects (strong exception guarantee). -* Else if type `T` has available copy constructor: - * This function has no effects (strong exception guarantee). -* Else if type `T` has available throwing move constructor: - * Container is changed but in valid state (basic exception guarantee). + * If type `T` has available `noexcept` move constructor: + * This function has no effects (strong exception guarantee). + * Else if type `T` has available copy constructor: + * This function has no effects (strong exception guarantee). + * Else if type `T` has available throwing move constructor: + * Container is changed but in valid state (basic exception guarantee). -

+

### shrink_to_fit -``` -void shrink_to_fit(); -``` +1. ``` + void shrink_to_fit(); + ``` -**Effects:** -Tries to reduce memory usage by freeing unused memory. + **Effects:** + Tries to reduce memory usage by freeing unused memory. -1. If `size() > N && size() < capacity()`, the function allocates memory for new storage of capacity equal to the value of `size()`, moves elements from old storage to new storage, and deallocates memory used by old storage. -2. If `size() <= N && N < capacity()`, the function sets new storage to be internal statically allocated array of capacity `N`, moves elements from old storage to new storage, and deallocates memory used by old storage. -3. Otherwise the function does nothing. + 1. If `size() > N && size() < capacity()`, the function allocates memory for new storage of capacity equal to the value of `size()`, moves elements from old storage to new storage, and deallocates memory used by old storage. -This function does not change size of the container. + 2. If `size() <= N && N < capacity()`, the function sets new storage to be internal statically allocated array of capacity `N`, moves elements from old storage to new storage, and deallocates memory used by old storage. -If the capacity is changed, all iterators and all references to the elements are invalidated. Otherwise, no iterators or references are invalidated. + 3. Otherwise the function does nothing. -**Complexity:** -Linear. + This function does not change size of the container. -**Exceptions:** + If the capacity is changed, all iterators and all references to the elements are invalidated. Otherwise, no iterators or references are invalidated. -* `Allocator::allocate` may throw. -* `T`'s move or copy constructor may throw. + **Complexity:** + Linear. -If an exception is thrown: + **Exceptions:** -* If type `T` has available `noexcept` move constructor: - * This function has no effects (strong exception guarantee). -* Else if type `T` has available copy constructor: - * This function has no effects (strong exception guarantee). -* Else if type `T` has available throwing move constructor: - * Container is changed but in valid state (basic exception guarantee). + * `Allocator::allocate` may throw. + * `T`'s move or copy constructor may throw. -

+ If an exception is thrown: + + * If type `T` has available `noexcept` move constructor: + * This function has no effects (strong exception guarantee). + * Else if type `T` has available copy constructor: + * This function has no effects (strong exception guarantee). + * Else if type `T` has available throwing move constructor: + * Container is changed but in valid state (basic exception guarantee). + +

### clear -``` -void clear() noexcept; -``` +1. ``` + void clear() noexcept; + ``` -**Effects:** -Erases all elements from the container. -After this call, `size()` returns zero and `capacity()` remains unchanged. + **Effects:** + Erases all elements from the container. + After this call, `size()` returns zero and `capacity()` remains unchanged. -**Complexity:** -Linear in `size()`. + **Complexity:** + Linear in `size()`. -

+

### emplace -``` -template -iterator emplace(Args&&... args); -``` +1. ``` + template + iterator emplace(Args&&... args); + ``` -**Effects:** -Inserts a new element into the container. + **Effects:** + Inserts a new element into the container. -New element is constructed as `value_type(std::forward(args)...)`. + New element is constructed as `value_type(std::forward(args)...)`. -**Returns:** -Iterator to the inserted element. + **Returns:** + Iterator to the inserted element. -

+

### emplace_hint -``` -template -iterator emplace_hint(const_iterator hint, Args&&... args); -``` +1. ``` + template + iterator emplace_hint(const_iterator hint, Args&&... args); + ``` -**Preconditions:** -`cbegin() <= hint && hint <= cend()` + **Preconditions:** + `cbegin() <= hint && hint <= cend()` -**Effects:** -Inserts a new element into the container. + **Effects:** + Inserts a new element into the container. -New element is constructed as `value_type(std::forward(args)...)`. + New element is constructed as `value_type(std::forward(args)...)`. -Iterator `hint` is used as a suggestion where to start to search insert position. + Iterator `hint` is used as a suggestion where to start to search insert position. -**Returns:** -Iterator to the inserted element. + **Returns:** + Iterator to the inserted element. -

+

### insert -``` -iterator insert(const value_type& value); -``` +1. ``` + iterator insert(const value_type& value); + ``` -**Effects:** -Inserts copy of `value`. + **Effects:** + Inserts copy of `value`. -**Returns:** -Iterator to the inserted element. + **Returns:** + Iterator to the inserted element. -

+

-``` -iterator insert(value_type&& value); -``` +2. ``` + iterator insert(value_type&& value); + ``` -**Effects:** -Inserts `value` using move semantics. + **Effects:** + Inserts `value` using move semantics. -**Returns:** -Iterator to the inserted element. + **Returns:** + Iterator to the inserted element. -

+

-``` -iterator insert(const_iterator hint, const value_type& value); -``` +3. ``` + iterator insert(const_iterator hint, const value_type& value); + ``` -**Preconditions:** -`cbegin() <= hint && hint <= cend()` + **Preconditions:** + `cbegin() <= hint && hint <= cend()` -**Effects:** -Inserts copy of `value`. + **Effects:** + Inserts copy of `value`. -Iterator `hint` is used as a suggestion where to start to search insert position. + Iterator `hint` is used as a suggestion where to start to search insert position. -**Returns:** -Iterator to the inserted element. + **Returns:** + Iterator to the inserted element. -

+

-``` -iterator insert(const_iterator hint, value_type&& value); -``` +4. ``` + iterator insert(const_iterator hint, value_type&& value); + ``` -**Preconditions:** -`cbegin() <= hint && hint <= cend()` + **Preconditions:** + `cbegin() <= hint && hint <= cend()` -**Effects:** -Inserts `value` using move semantics. + **Effects:** + Inserts `value` using move semantics. -Iterator `hint` is used as a suggestion where to start to search insert position. + Iterator `hint` is used as a suggestion where to start to search insert position. -**Returns:** -Iterator to the inserted element. + **Returns:** + Iterator to the inserted element. -

+

-``` -template -void insert(InputIt first, InputIt last); -``` +5. ``` + template + void insert(InputIt first, InputIt last); + ``` -**Effects:** -Inserts elements from range `[first, last)`. + **Effects:** + Inserts elements from range `[first, last)`. -The call to this function is equivalent to: -``` -while (first != last) -{ - insert(*first); - ++first; -} -``` + The call to this function is equivalent to: + ``` + while (first != last) + { + insert(*first); + ++first; + } + ``` -**Note:** -This overload participates in overload resolution only if `InputIt` satisfies requirements of [*LegacyInputIterator*](https://en.cppreference.com/w/cpp/named_req/InputIterator). + **Note:** + This overload participates in overload resolution only if `InputIt` satisfies requirements of [*LegacyInputIterator*](https://en.cppreference.com/w/cpp/named_req/InputIterator). -

+

-``` -void insert(std::initializer_list ilist); -``` +6. ``` + void insert(std::initializer_list ilist); + ``` -**Effects:** -Inserts elements from initializer list `ilist`. + **Effects:** + Inserts elements from initializer list `ilist`. -The call to this function is equivalent to: -``` -insert(ilist.begin(), ilist.end()); -``` + The call to this function is equivalent to `insert(ilist.begin(), ilist.end())`. -

+

### erase -``` -iterator erase(iterator pos); -``` -``` -iterator erase(const_iterator pos); -``` - -**Preconditions:** -`cbegin() <= pos && pos < cend()` - -**Effects:** -Removes the element at `pos`. - -**Returns:** -Iterator following the last removed element. - -

- - +1. ``` + iterator erase(iterator pos); + ``` +2. ``` + iterator erase(const_iterator pos); + ``` -``` -iterator erase(const_iterator first, const_iterator last); -``` + **Preconditions:** + `cbegin() <= pos && pos < cend()` -**Preconditions:** -`cbegin() <= first && first <= last && last <= cend()` + **Effects:** + Removes the element at `pos`. -**Effects:** -Removes the elements in the range `[first, last)`. + **Returns:** + Iterator following the last removed element. -**Returns:** -Iterator following the last removed element. +

-

+3. ``` + iterator erase(const_iterator first, const_iterator last); + ``` -``` -size_type erase(const Key& key); -``` + **Preconditions:** + `cbegin() <= first && first <= last && last <= cend()` -**Effects:** -Removes all elements with the key equivalent to `key`. + **Effects:** + Removes the elements in the range `[first, last)`. -**Returns:** -Number of elements removed. + **Returns:** + Iterator following the last removed element. -

+

-``` -template -size_type erase(K&& x); -``` +4. ``` + size_type erase(const Key& key); + ``` +5. ``` + template + size_type erase(K&& x); + ``` -**Effects:** -Removes all elements with key that compares equivalent to the value `x`. + **Effects:** + Removes all elements with the key equivalent to `key` or `x`. -**Note:** -This overload participates in overload resolution only if `Compare::is_transparent` exists and is a valid type. It allows calling this function without constructing an instance of `Key`. + **Note:** + Overload (5) participates in overload resolution only if `Compare::is_transparent` exists and is a valid type. It allows calling this function without constructing an instance of `Key`. -**Returns:** -Number of elements removed. + **Returns:** + Number of elements removed. -

+

### swap -``` -void swap(small_flat_multiset& other); -``` +1. ``` + void swap(small_flat_multiset& other); + ``` -**Preconditions:** -`allocator_traits::propagate_on_container_swap::value || get_allocator() == other.get_allocator()` + **Preconditions:** + `allocator_traits::propagate_on_container_swap::value || get_allocator() == other.get_allocator()` -**Effects:** -Exchanges the contents of the container with those of `other`. + **Effects:** + Exchanges the contents of the container with those of `other`. -**Complexity:** -Constant in the best case. Linear in `this->size()` plus linear in `other.size()` in the worst case. + **Complexity:** + Constant in the best case. Linear in `this->size()` plus linear in `other.size()` in the worst case. -

+

### lower_bound -``` -iterator lower_bound(const Key& key); -``` -``` -const_iterator lower_bound(const Key& key) const; -``` - -**Effects:** -Returns an iterator pointing to the first element with key that is not less than `key`, or `end()` if such an element is not found. - -**Complexity:** -Logarithmic in `size()`. - -

- - - -``` -template -iterator lower_bound(const K& x); -``` -``` -template -const_iterator lower_bound(const K& x) const; -``` +1. ``` + iterator lower_bound(const Key& key); + ``` +2. ``` + const_iterator lower_bound(const Key& key) const; + ``` +3. ``` + template + iterator lower_bound(const K& x); + ``` +4. ``` + template + const_iterator lower_bound(const K& x) const; + ``` -**Effects:** -Returns an iterator pointing to the first element with key that compares not less to the value `x`, or `end()` if such an element is not found. + **Effects:** + Returns an iterator pointing to the first element with key that compares **not less than** `key` or `x`. Returns `end()` if no such element is found. -**Note:** -This overload participates in overload resolution only if `Compare::is_transparent` exists and is a valid type. It allows calling this function without constructing an instance of `Key`. + **Note:** + Overloads (3) and (4) participate in overload resolution only if `Compare::is_transparent` exists and is a valid type. It allows calling these functions without constructing an instance of `Key`. -**Complexity:** -Logarithmic in `size()`. + **Complexity:** + Logarithmic in `size()`. -

+

### upper_bound -``` -iterator upper_bound(const Key& key); -``` -``` -const_iterator upper_bound(const Key& key) const; -``` - -**Effects:** -Returns an iterator pointing to the first element with key that is greater than `key`, or `end()` if such an element is not found. - -**Complexity:** -Logarithmic in `size()`. - -

- - - -``` -template -iterator upper_bound(const K& x); -``` -``` -template -const_iterator upper_bound(const K& x) const; -``` +1. ``` + iterator upper_bound(const Key& key); + ``` +2. ``` + const_iterator upper_bound(const Key& key) const; + ``` +3. ``` + template + iterator upper_bound(const K& x); + ``` +4. ``` + template + const_iterator upper_bound(const K& x) const; + ``` -**Effects:** -Returns an iterator pointing to the first element with key that compares greater to the value `x`, or `end()` if such an element is not found. + **Effects:** + Returns an iterator pointing to the first element with key that compares **greater than** `key` or `x`. Returns `end()` if no such element is found. -**Note:** -This overload participates in overload resolution only if `Compare::is_transparent` exists and is a valid type. It allows calling this function without constructing an instance of `Key`. + **Note:** + Overloads (3) and (4) participate in overload resolution only if `Compare::is_transparent` exists and is a valid type. It allows calling these functions without constructing an instance of `Key`. -**Complexity:** -Logarithmic in `size()`. + **Complexity:** + Logarithmic in `size()`. -

+

### equal_range -``` -std::pair equal_range(const Key& key); -``` -``` -std::pair equal_range(const Key& key) const; -``` - -**Effects:** -Returns a range containing all elements with the key that is equal to `key`: -* The first iterator in pair points to the first element that is not less than `key`, or `end()` if such an element does not exist. -* The second iterator in pair points to the first element that is greater that `key`, or `end()` is such an element does not exist. - -**Complexity:** -Logarithmic in `size()`. - -

- - - -``` -template -std::pair equal_range(const K& x); -``` -``` -template -std::pair equal_range(const K& x) const; -``` +1. ``` + std::pair equal_range(const Key& key); + ``` +2. ``` + std::pair equal_range(const Key& key) const; + ``` +3. ``` + template + std::pair equal_range(const K& x); + ``` +4. ``` + template + std::pair equal_range(const K& x) const; + ``` -**Effects:** -Returns a range containing all elements with the key that compares equal to the value `x`: -* The first iterator in pair points to the first element that compares not less to the value `x`, or `end()` if such an element does not exist. -* The second iterator in pair points to the first element that compares greater to the value `x`, or `end()` is such an element does not exist. + **Effects:** + Returns a range containing all elements with key that compares equivalent to `key` or `x`. + * The first iterator in pair points to the first element that compares **not less than** `key` or `x`. It is equal to `end()` if no such element is found. + * The second iterator in pair points to the first element that compares **greater than** `key` or `x`. It is equal to `end()` is no such element is found. -**Note:** -This overload participates in overload resolution only if `Compare::is_transparent` exists and is a valid type. It allows calling this function without constructing an instance of `Key`. + **Note:** + Overloads (3) and (4) participate in overload resolution only if `Compare::is_transparent` exists and is a valid type. It allows calling these functions without constructing an instance of `Key`. -**Complexity:** -Logarithmic in `size()`. + **Complexity:** + Logarithmic in `size()`. -

+

### find -``` -iterator find(const Key& key); -``` -``` -const_iterator find(const Key& key) const; -``` - -**Effects:** -Returns an iterator to an element with key equivalent to `key`, or `end()` if such an element is not found. If there are several elements with key in the container, any of them may be returned. - -**Complexity:** -Logarithmic in `size()`. - -

- - - -``` -template -iterator find(const K& x); -``` -``` -template -const_iterator find(const K& x) const; -``` +1. ``` + iterator find(const Key& key); + ``` +2. ``` + const_iterator find(const Key& key) const; + ``` +3. ``` + template + iterator find(const K& x); + ``` +4. ``` + template + const_iterator find(const K& x) const; + ``` -**Effects:** -Returns an iterator to an element with key that compares equivalent to `x`, or `end()` if such an element is not found. If there are several elements with key in the container, any of them may be returned. + **Effects:** + Returns an iterator pointing to the element with key equivalent to `key` or `x`. Returns `end()` if no such element is found. + If there are several elements with key in the container, any of them may be returned. -**Note:** -This overload participates in overload resolution only if `Compare::is_transparent` exists and is a valid type. It allows calling this function without constructing an instance of `Key`. + **Note:** + Overloads (3) and (4) participate in overload resolution only if `Compare::is_transparent` exists and is a valid type. It allows calling these functions without constructing an instance of `Key`. -**Complexity:** -Logarithmic in `size()`. + **Complexity:** + Logarithmic in `size()`. -

+

### count -``` -size_type count(const Key& key) const; -``` - -**Effects:** -Returns the number of elements with key equivalent to `key`. - -**Complexity:** -Logarithmic in `size()` plus linear in the number of the elements found. - -

- - - -``` -template -size_type count(const K& x) const; -``` +1. ``` + size_type count(const Key& key) const; + ``` +2. ``` + template + size_type count(const K& x) const; + ``` -**Effects:** -Returns the number of elements with key that compares equivalent to the value `x`. + **Effects:** + Returns the number of elements with key equivalent to `key` or `x`. -**Note:** -This overload participates in overload resolution only if `Compare::is_transparent` exists and is a valid type. It allows calling this function without constructing an instance of `Key`. + **Note:** + Overload (2) participates in overload resolution only if `Compare::is_transparent` exists and is a valid type. It allows calling this function without constructing an instance of `Key`. -**Complexity:** -Logarithmic in `size()` plus linear in the number of the elements found. + **Complexity:** + Logarithmic in `size()` plus linear in the number of the elements found. -

+

### contains -``` -bool contains(const Key& key) const; -``` - -**Effects:** -Returns `true` if the container contains an element with key equivalent to `key`, otherwise returns `false`. - -**Complexity:** -Logarithmic in `size()`. - -

- - - -``` -template -bool contains(const K& x) const; -``` +1. ``` + bool contains(const Key& key) const; + ``` +2. ``` + template + bool contains(const K& x) const; + ``` -**Effects:** -Returns `true` if the container contains an element with the key that compares equivalent to `x`, otherwise returns `false`. + **Effects:** + Returns `true` if the container contains an element with key equivalent to `key` or `x`, otherwise returns `false`. -**Note:** -This overload participates in overload resolution only if `Compare::is_transparent` exists and is a valid type. It allows calling this function without constructing an instance of `Key`. + **Note:** + Overload (2) participates in overload resolution only if `Compare::is_transparent` exists and is a valid type. It allows calling this function without constructing an instance of `Key`. -**Complexity:** -Logarithmic in `size()`. + **Complexity:** + Logarithmic in `size()`. -

+

### data -``` -value_type* data() noexcept; -``` -``` -const value_type* data() const noexcept; -``` +1. ``` + value_type* data() noexcept; + ``` +2. ``` + const value_type* data() const noexcept; + ``` -**Effects:** -Returns pointer to the underlying array serving as element storage. The pointer is such that range `[data(), data() + size())` is always a valid range, even if the container is empty. `data()` is not dereferenceable if the container is empty. + **Effects:** + Returns pointer to the underlying array serving as element storage. The pointer is such that range `[data(), data() + size())` is always a valid range, even if the container is empty. `data()` is not dereferenceable if the container is empty. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

@@ -1227,186 +1144,186 @@ Constant. ### operator== -``` -template -bool operator== -( - const small_flat_multiset& x, - const small_flat_multiset& y -); -``` +1. ``` + template + bool operator== + ( + const small_flat_multiset& x, + const small_flat_multiset& y + ); + ``` -**Effects:** -Checks if the contents of `x` and `y` are equal. + **Effects:** + Checks if the contents of `x` and `y` are equal. -The contents of `x` and `y` are equal if the following conditions hold: -* `x.size() == y.size()` -* Each element in `x` compares equal with the element in `y` at the same position. + The contents of `x` and `y` are equal if the following conditions hold: + * `x.size() == y.size()` + * Each element in `x` compares equal with the element in `y` at the same position. -The comparison is performed by `std::equal`. -This comparison ignores the container's ordering `Compare`. + The comparison is performed by `std::equal`. + This comparison ignores the container's ordering `Compare`. -**Returns:** -Returns `true` if the contents of the `x` and `y` are equal, `false` otherwise. + **Returns:** + Returns `true` if the contents of the `x` and `y` are equal, `false` otherwise. -

+

### operator!= -``` -template -bool operator!= -( - const small_flat_multiset& x, - const small_flat_multiset& y -); -``` +1. ``` + template + bool operator!= + ( + const small_flat_multiset& x, + const small_flat_multiset& y + ); + ``` -**Effects:** -Checks if the contents of `x` and `y` are equal. + **Effects:** + Checks if the contents of `x` and `y` are equal. -For details see `operator==`. + For details see `operator==`. -**Returns:** -Returns `true` if the contents of the `x` and `y` are not equal, `false` otherwise. + **Returns:** + Returns `true` if the contents of the `x` and `y` are not equal, `false` otherwise. -

+

### operator< -``` -template -bool operator< -( - const small_flat_multiset& x, - const small_flat_multiset& y -); -``` +1. ``` + template + bool operator< + ( + const small_flat_multiset& x, + const small_flat_multiset& y + ); + ``` -**Effects:** -Compares the contents of `x` and `y` lexicographically. -The comparison is performed by a function `std::lexicographical_compare`. -This comparison ignores the container's ordering `Compare`. + **Effects:** + Compares the contents of `x` and `y` lexicographically. + The comparison is performed by a function `std::lexicographical_compare`. + This comparison ignores the container's ordering `Compare`. -**Returns:** -`true` if the contents of the `x` are lexicographically less than the contents of `y`, `false` otherwise. + **Returns:** + `true` if the contents of the `x` are lexicographically less than the contents of `y`, `false` otherwise. -

+

### operator> -``` -template -bool operator> -( - const small_flat_multiset& x, - const small_flat_multiset& y -); -``` +1. ``` + template + bool operator> + ( + const small_flat_multiset& x, + const small_flat_multiset& y + ); + ``` -**Effects:** -Compares the contents of lhs and rhs lexicographically. + **Effects:** + Compares the contents of lhs and rhs lexicographically. -The comparison is performed by a function `std::lexicographical_compare`. -This comparison ignores the container's ordering `Compare`. + The comparison is performed by a function `std::lexicographical_compare`. + This comparison ignores the container's ordering `Compare`. -**Returns:** -`true` if the contents of the `x` are lexicographically greater than the contents of `y`, `false` otherwise. + **Returns:** + `true` if the contents of the `x` are lexicographically greater than the contents of `y`, `false` otherwise. -

+

### operator<= -``` -template -bool operator<= -( - const small_flat_multiset& x, - const small_flat_multiset& y -); -``` +1. ``` + template + bool operator<= + ( + const small_flat_multiset& x, + const small_flat_multiset& y + ); + ``` -**Effects:** -Compares the contents of `x` and `y` lexicographically. -The comparison is performed by a function `std::lexicographical_compare`. -This comparison ignores the container's ordering `Compare`. + **Effects:** + Compares the contents of `x` and `y` lexicographically. + The comparison is performed by a function `std::lexicographical_compare`. + This comparison ignores the container's ordering `Compare`. -**Returns:** -`true` if the contents of the `x` are lexicographically less than or equal to the contents of `y`, `false` otherwise. + **Returns:** + `true` if the contents of the `x` are lexicographically less than or equal to the contents of `y`, `false` otherwise. -

+

### operator>= -``` -template -bool operator>= -( - const small_flat_multiset& x, - const small_flat_multiset& y -); -``` +1. ``` + template + bool operator>= + ( + const small_flat_multiset& x, + const small_flat_multiset& y + ); + ``` -**Effects:** -Compares the contents of `x` and `y` lexicographically. -The comparison is performed by a function `std::lexicographical_compare`. -This comparison ignores the container's ordering `Compare`. + **Effects:** + Compares the contents of `x` and `y` lexicographically. + The comparison is performed by a function `std::lexicographical_compare`. + This comparison ignores the container's ordering `Compare`. -**Returns:** -`true` if the contents of the `x` are lexicographically greater than or equal to the contents of `y`, `false` otherwise. + **Returns:** + `true` if the contents of the `x` are lexicographically greater than or equal to the contents of `y`, `false` otherwise. -

+

### swap -``` -template -void swap -( - small_flat_multiset& x, - small_flat_multiset& y -); -``` +1. ``` + template + void swap + ( + small_flat_multiset& x, + small_flat_multiset& y + ); + ``` -**Effects:** -Swaps the contents of `x` and `y`. Calls `x.swap(y)`. + **Effects:** + Swaps the contents of `x` and `y`. Calls `x.swap(y)`. -

+

### erase_if -``` -template -typename small_flat_multiset::size_type - erase_if(small_flat_multiset& c, Predicate pred); -``` +1. ``` + template + typename small_flat_multiset::size_type + erase_if(small_flat_multiset& c, Predicate pred); + ``` -**Effects:** -Erases all elements that satisfy the predicate `pred` from the container. + **Effects:** + Erases all elements that satisfy the predicate `pred` from the container. -`pred` is unary predicate which returns `true` if the element should be removed. + `pred` is unary predicate which returns `true` if the element should be removed. -**Returns:** -The number of erased elements. + **Returns:** + The number of erased elements. -**Complexity:** -Linear. + **Complexity:** + Linear. -

+

diff --git a/doc/small_flat_set.md b/doc/small_flat_set.md index 2f75d87..ebdbe14 100644 --- a/doc/small_flat_set.md +++ b/doc/small_flat_set.md @@ -98,7 +98,8 @@ Iterators to elements of `sfl::small_flat_set` are random access iterators and t std::size_t N ``` - Size of the internal statically allocated array. + Size of the internal statically allocated array, i.e. the maximal number of elements that can fit into this array. + This parameter can be zero. 3. ``` @@ -160,1071 +161,1032 @@ static constexpr size_type static_capacity = N; ### (constructor) -``` -small_flat_set() - noexcept( +1. ``` + small_flat_set() noexcept( std::is_nothrow_default_constructible::value && std::is_nothrow_default_constructible::value ); -``` -``` -explicit small_flat_set(const Compare& comp) - noexcept( + ``` +2. ``` + explicit small_flat_set(const Compare& comp) noexcept( std::is_nothrow_default_constructible::value && std::is_nothrow_copy_constructible::value ); -``` -``` -explicit small_flat_set(const Allocator& alloc) - noexcept( + ``` +3. ``` + explicit small_flat_set(const Allocator& alloc) noexcept( std::is_nothrow_copy_constructible::value && std::is_nothrow_default_constructible::value ); -``` -``` -explicit small_flat_set(const Compare& comp, const Allocator& alloc) - noexcept( + ``` +4. ``` + explicit small_flat_set(const Compare& comp, const Allocator& alloc) noexcept( std::is_nothrow_copy_constructible::value && std::is_nothrow_copy_constructible::value ); -``` + ``` -**Effects:** -Constructs an empty container. + **Effects:** + Constructs an empty container. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

-``` -template -small_flat_set(InputIt first, InputIt last); -``` -``` -template -small_flat_set(InputIt first, InputIt last, const Compare& comp); -``` -``` -template -small_flat_set(InputIt first, InputIt last, const Allocator& alloc); -``` -``` -template -small_flat_set(InputIt first, InputIt last, const Compare& comp, const Allocator& alloc); -``` +5. ``` + template + small_flat_set(InputIt first, InputIt last); + ``` +6. ``` + template + small_flat_set(InputIt first, InputIt last, const Compare& comp); + ``` +7. ``` + template + small_flat_set(InputIt first, InputIt last, const Allocator& alloc); + ``` +8. ``` + template + small_flat_set(InputIt first, InputIt last, const Compare& comp, const Allocator& alloc); + ``` -**Effects:** -Constructs an empty container and inserts elements from the range `[first, last)`. + **Effects:** + Constructs an empty container and inserts elements from the range `[first, last)`. -**Note:** -This overload participates in overload resolution only if `InputIt` satisfies requirements of [*LegacyInputIterator*](https://en.cppreference.com/w/cpp/named_req/InputIterator). + **Note:** + These overloads participate in overload resolution only if `InputIt` satisfies requirements of [*LegacyInputIterator*](https://en.cppreference.com/w/cpp/named_req/InputIterator). -**Complexity:** -Linear in `std::distance(first, last)`. + **Complexity:** + Linear in `std::distance(first, last)`. -

+

-``` -small_flat_set(std::initializer_list ilist); -``` -``` -small_flat_set(std::initializer_list ilist, const Compare& comp); -``` -``` -small_flat_set(std::initializer_list ilist, const Allocator& alloc); -``` -``` -small_flat_set(std::initializer_list ilist, const Compare& comp, const Allocator& alloc); -``` +9. ``` + small_flat_set(std::initializer_list ilist); + ``` +10. ``` + small_flat_set(std::initializer_list ilist, const Compare& comp); + ``` +11. ``` + small_flat_set(std::initializer_list ilist, const Allocator& alloc); + ``` +12. ``` + small_flat_set(std::initializer_list ilist, const Compare& comp, const Allocator& alloc); + ``` -**Effects:** -Constructs an empty container and inserts elements from the initializer list `ilist`. + **Effects:** + Constructs an empty container and inserts elements from the initializer list `ilist`. -**Complexity:** -Linear in `ilist.size()`. + **Complexity:** + Linear in `ilist.size()`. -

+

-``` -small_flat_set(const small_flat_set& other); -``` -``` -small_flat_set(const small_flat_set& other, const Allocator& alloc); -``` +13. ``` + small_flat_set(const small_flat_set& other); + ``` +14. ``` + small_flat_set(const small_flat_set& other, const Allocator& alloc); + ``` -**Effects:** -Copy constructor. -Constructs the container with the copy of the contents of `other`. + **Effects:** + Copy constructor. + Constructs the container with the copy of the contents of `other`. -**Complexity:** -Linear in `other.size()`. + **Complexity:** + Linear in `other.size()`. -

+

-``` -small_flat_set(small_flat_set&& other); -``` -``` -small_flat_set(small_flat_set&& other, const Allocator& alloc); -``` +15. ``` + small_flat_set(small_flat_set&& other); + ``` +16. ``` + small_flat_set(small_flat_set&& other, const Allocator& alloc); + ``` -**Effects:** -Move constructor. -Constructs the container with the contents of `other` using move semantics. + **Effects:** + Move constructor. + Constructs the container with the contents of `other` using move semantics. -`other` is not guaranteed to be empty after the move. + `other` is not guaranteed to be empty after the move. -`other` is in a valid but unspecified state after the move. + `other` is in a valid but unspecified state after the move. -**Complexity:** -Constant in the best case. Linear in `N` in the worst case. + **Complexity:** + Constant in the best case. Linear in `N` in the worst case. -

+

### (destructor) -``` -~small_flat_set(); -``` +1. ``` + ~small_flat_set(); + ``` -**Effects:** -Destructs the container. The destructors of the elements are called and the used storage is deallocated. + **Effects:** + Destructs the container. The destructors of the elements are called and the used storage is deallocated. -**Complexity:** -Linear in `size()`. + **Complexity:** + Linear in `size()`. -

+

### operator= -``` -small_flat_set& operator=(const small_flat_set& other); -``` +1. ``` + small_flat_set& operator=(const small_flat_set& other); + ``` -**Effects:** -Copy assignment operator. -Replaces the contents with a copy of the contents of `other`. + **Effects:** + Copy assignment operator. + Replaces the contents with a copy of the contents of `other`. -**Returns:** -`*this()`. + **Returns:** + `*this()`. -**Complexity:** -Linear in `this->size()` plus linear in `other.size()`. + **Complexity:** + Linear in `this->size()` plus linear in `other.size()`. -

+

-``` -small_flat_set& operator=(small_flat_set&& other); -``` +2. ``` + small_flat_set& operator=(small_flat_set&& other); + ``` -**Effects:** -Move assignment operator. -Replaces the contents with those of `other` using move semantics. + **Effects:** + Move assignment operator. + Replaces the contents with those of `other` using move semantics. -`other` is not guaranteed to be empty after the move. + `other` is not guaranteed to be empty after the move. -`other` is in a valid but unspecified state after the move. + `other` is in a valid but unspecified state after the move. -**Returns:** -`*this()`. + **Returns:** + `*this()`. -**Complexity:** + **Complexity:** -* The best case: Linear in `this->size()` plus constant. -* The worst case: Linear in `this->size()` plus linear in `other.size()`. + * The best case: Linear in `this->size()` plus constant. + * The worst case: Linear in `this->size()` plus linear in `other.size()`. -

+

-``` -small_flat_set& operator=(std::initializer_list ilist); -``` +3. ``` + small_flat_set& operator=(std::initializer_list ilist); + ``` -**Effects:** -Replaces the contents with those identified by initializer list `ilist`. + **Effects:** + Replaces the contents with those identified by initializer list `ilist`. -**Returns:** -`*this()`. + **Returns:** + `*this()`. -**Complexity:** -Linear in `this->size()` plus linear in `ilist.size()`. + **Complexity:** + Linear in `this->size()` plus linear in `ilist.size()`. -

+

### get_allocator -``` -allocator_type get_allocator() const noexcept; -``` +1. ``` + allocator_type get_allocator() const noexcept; + ``` -**Effects:** -Returns the allocator associated with the container. + **Effects:** + Returns the allocator associated with the container. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

### key_comp -``` -key_compare key_comp() const; -``` +1. ``` + key_compare key_comp() const; + ``` -**Effects:** -Returns the function object that compares the keys, which is a copy of this container's constructor argument `comp`. + **Effects:** + Returns the function object that compares the keys, which is a copy of this container's constructor argument `comp`. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

### value_comp -``` -value_compare value_comp() const; -``` +1. ``` + value_compare value_comp() const; + ``` -**Effects:** -Returns a function object that compares objects of type `value_type`. + **Effects:** + Returns a function object that compares objects of type `value_type`. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

### begin, cbegin -``` -iterator begin() noexcept; -``` -``` -const_iterator begin() const noexcept; -``` -``` -const_iterator cbegin() const noexcept; -``` - -**Effects:** -Returns an iterator to the first element of the container. +1. ``` + iterator begin() noexcept; + ``` +2. ``` + const_iterator begin() const noexcept; + ``` +3. ``` + const_iterator cbegin() const noexcept; + ``` -If the container is empty, the returned iterator will be equal to `end()`. + **Effects:** + Returns an iterator to the first element of the container. + If the container is empty, the returned iterator will be equal to `end()`. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

### end, cend -``` -iterator end() noexcept; -``` -``` -const_iterator end() const noexcept; -``` -``` -const_iterator cend() const noexcept; -``` - -**Effects:** -Returns an iterator to the element following the last element of the container. +1. ``` + iterator end() noexcept; + ``` +2. ``` + const_iterator end() const noexcept; + ``` +3. ``` + const_iterator cend() const noexcept; + ``` -This element acts as a placeholder; attempting to access it results in undefined behavior. + **Effects:** + Returns an iterator to the element following the last element of the container. + This element acts as a placeholder; attempting to access it results in undefined behavior. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

### rbegin, crbegin -``` -reverse_iterator rbegin() noexcept; -``` -``` -const_reverse_iterator rbegin() const noexcept; -``` -``` -const_reverse_iterator crbegin() const noexcept; -``` +1. ``` + reverse_iterator rbegin() noexcept; + ``` +2. ``` + const_reverse_iterator rbegin() const noexcept; + ``` +3. ``` + const_reverse_iterator crbegin() const noexcept; + ``` -**Effects:** -Returns a reverse iterator to the first element of the reversed container. -It corresponds to the last element of the non-reversed container. -If the container is empty, the returned iterator is equal to `rend()`. + **Effects:** + Returns a reverse iterator to the first element of the reversed container. + It corresponds to the last element of the non-reversed container. + If the container is empty, the returned iterator is equal to `rend()`. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

### rend, crend -``` -reverse_iterator rend() noexcept; -``` -``` -const_reverse_iterator rend() const noexcept; -``` -``` -const_reverse_iterator crend() const noexcept; -``` +1. ``` + reverse_iterator rend() noexcept; + ``` +2. ``` + const_reverse_iterator rend() const noexcept; + ``` +3. ``` + const_reverse_iterator crend() const noexcept; + ``` -**Effects:** -Returns a reverse iterator to the element following the last element of the reversed container. -It corresponds to the element preceding the first element of the non-reversed container. -This element acts as a placeholder, attempting to access it results in undefined behavior. + **Effects:** + Returns a reverse iterator to the element following the last element of the reversed container. + It corresponds to the element preceding the first element of the non-reversed container. + This element acts as a placeholder, attempting to access it results in undefined behavior. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

### nth -``` -iterator nth(size_type pos) noexcept; -``` -``` -const_iterator nth(size_type pos) const noexcept; -``` +1. ``` + iterator nth(size_type pos) noexcept; + ``` +2. ``` + const_iterator nth(size_type pos) const noexcept; + ``` -**Preconditions:** -`pos <= size()` + **Preconditions:** + `pos <= size()` -**Effects:** -Returns an iterator to the element at position `pos`. -If `pos == size()`, the returned iterator is equal to `end()`. + **Effects:** + Returns an iterator to the element at position `pos`. -**Complexity:** -Constant. + If `pos == size()`, the returned iterator is equal to `end()`. -

+ **Complexity:** + Constant. + +

### index_of -``` -size_type index_of(const_iterator pos) const noexcept; -``` +1. ``` + size_type index_of(const_iterator pos) const noexcept; + ``` -**Preconditions:** -`cbegin() <= pos && pos <= cend()` + **Preconditions:** + `cbegin() <= pos && pos <= cend()` -**Effects:** -Returns position of the element pointed by iterator `pos`, i.e. `std::distance(begin(), pos)`. + **Effects:** + Returns position of the element pointed by iterator `pos`, i.e. `std::distance(begin(), pos)`. -If `pos == end()`, the returned value is equal to `size()`. + If `pos == end()`, the returned value is equal to `size()`. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

### empty -``` -bool empty() const noexcept; -``` +1. ``` + bool empty() const noexcept; + ``` -**Effects:** -Returns `true` if the container has no elements, i.e. whether `begin() == end()`. + **Effects:** + Returns `true` if the container has no elements, i.e. whether `begin() == end()`. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

### size -``` -size_type size() const noexcept; -``` +1. ``` + size_type size() const noexcept; + ``` -**Effects:** -Returns the number of elements in the container, i.e. `std::distance(begin(), end())`. + **Effects:** + Returns the number of elements in the container, i.e. `std::distance(begin(), end())`. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

### max_size -``` -size_type max_size() const noexcept; -``` +1. ``` + size_type max_size() const noexcept; + ``` -**Effects:** -Returns the maximum number of elements the container is able to hold, i.e. `std::distance(begin(), end())` for the largest container. + **Effects:** + Returns the maximum number of elements the container is able to hold, i.e. `std::distance(begin(), end())` for the largest container. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

### capacity -``` -size_type capacity() const noexcept; -``` +1. ``` + size_type capacity() const noexcept; + ``` -**Effects:** -Returns the number of elements that the container has currently allocated space for. + **Effects:** + Returns the number of elements that the container has currently allocated space for. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

### available -``` -size_type available() const noexcept; -``` +1. ``` + size_type available() const noexcept; + ``` -**Effects:** -Returns the number of elements that can be inserted into the container without requiring allocation of additional memory. + **Effects:** + Returns the number of elements that can be inserted into the container without requiring allocation of additional memory. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

### reserve -``` -void reserve(size_type new_cap); -``` +1. ``` + void reserve(size_type new_cap); + ``` -**Effects:** -Tries to increase capacity by allocating additional memory. + **Effects:** + Tries to increase capacity by allocating additional memory. -If `new_cap > capacity()`, the function allocates memory for new storage of capacity equal to the value of `new_cap`, moves elements from old storage to new storage, and deallocates memory used by old storage. Otherwise, the function does nothing. + If `new_cap > capacity()`, the function allocates memory for new storage of capacity equal to the value of `new_cap`, moves elements from old storage to new storage, and deallocates memory used by old storage. Otherwise, the function does nothing. -This function does not change size of the container. + This function does not change size of the container. -If the capacity is changed, all iterators and all references to the elements are invalidated. Otherwise, no iterators or references are invalidated. + If the capacity is changed, all iterators and all references to the elements are invalidated. Otherwise, no iterators or references are invalidated. -**Complexity:** -Linear. + **Complexity:** + Linear. -**Exceptions:** + **Exceptions:** -* `Allocator::allocate` may throw. -* `T`'s move or copy constructor may throw. + * `Allocator::allocate` may throw. + * `T`'s move or copy constructor may throw. -If an exception is thrown: + If an exception is thrown: -* If type `T` has available `noexcept` move constructor: - * This function has no effects (strong exception guarantee). -* Else if type `T` has available copy constructor: - * This function has no effects (strong exception guarantee). -* Else if type `T` has available throwing move constructor: - * Container is changed but in valid state (basic exception guarantee). + * If type `T` has available `noexcept` move constructor: + * This function has no effects (strong exception guarantee). + * Else if type `T` has available copy constructor: + * This function has no effects (strong exception guarantee). + * Else if type `T` has available throwing move constructor: + * Container is changed but in valid state (basic exception guarantee). -

+

### shrink_to_fit -``` -void shrink_to_fit(); -``` +1. ``` + void shrink_to_fit(); + ``` -**Effects:** -Tries to reduce memory usage by freeing unused memory. + **Effects:** + Tries to reduce memory usage by freeing unused memory. -1. If `size() > N && size() < capacity()`, the function allocates memory for new storage of capacity equal to the value of `size()`, moves elements from old storage to new storage, and deallocates memory used by old storage. -2. If `size() <= N && N < capacity()`, the function sets new storage to be internal statically allocated array of capacity `N`, moves elements from old storage to new storage, and deallocates memory used by old storage. -3. Otherwise the function does nothing. + 1. If `size() > N && size() < capacity()`, the function allocates memory for new storage of capacity equal to the value of `size()`, moves elements from old storage to new storage, and deallocates memory used by old storage. -This function does not change size of the container. + 2. If `size() <= N && N < capacity()`, the function sets new storage to be internal statically allocated array of capacity `N`, moves elements from old storage to new storage, and deallocates memory used by old storage. -If the capacity is changed, all iterators and all references to the elements are invalidated. Otherwise, no iterators or references are invalidated. + 3. Otherwise the function does nothing. -**Complexity:** -Linear. + This function does not change size of the container. -**Exceptions:** + If the capacity is changed, all iterators and all references to the elements are invalidated. Otherwise, no iterators or references are invalidated. -* `Allocator::allocate` may throw. -* `T`'s move or copy constructor may throw. + **Complexity:** + Linear. -If an exception is thrown: + **Exceptions:** -* If type `T` has available `noexcept` move constructor: - * This function has no effects (strong exception guarantee). -* Else if type `T` has available copy constructor: - * This function has no effects (strong exception guarantee). -* Else if type `T` has available throwing move constructor: - * Container is changed but in valid state (basic exception guarantee). + * `Allocator::allocate` may throw. + * `T`'s move or copy constructor may throw. -

+ If an exception is thrown: + + * If type `T` has available `noexcept` move constructor: + * This function has no effects (strong exception guarantee). + * Else if type `T` has available copy constructor: + * This function has no effects (strong exception guarantee). + * Else if type `T` has available throwing move constructor: + * Container is changed but in valid state (basic exception guarantee). + +

### clear -``` -void clear() noexcept; -``` +1. ``` + void clear() noexcept; + ``` -**Effects:** -Erases all elements from the container. -After this call, `size()` returns zero and `capacity()` remains unchanged. + **Effects:** + Erases all elements from the container. + After this call, `size()` returns zero and `capacity()` remains unchanged. -**Complexity:** -Linear in `size()`. + **Complexity:** + Linear in `size()`. -

+

### emplace -``` -template -std::pair emplace(Args&&... args); -``` +1. ``` + template + std::pair emplace(Args&&... args); + ``` -**Effects:** -Inserts a new element into the container only if the container does not already contain an element with an equivalent key. + **Effects:** + Inserts new element into the container if the container doesn't already contain an element with an equivalent key. -New element is constructed as `value_type(std::forward(args)...)`. + New element is constructed as `value_type(std::forward(args)...)`. -The element may be constructed even if there already is an element with the key in the container, in which case the newly constructed element will be destroyed immediately. + The element may be constructed even if there already is an element with the key in the container, in which case the newly constructed element will be destroyed immediately. -**Returns:** -Pair consisting of an iterator to the inserted element, or the already-existing element if no insertion happened, and a `bool` denoting whether the insertion took place (`true` if insertion happened, `false` if it did not). + **Returns:** + The iterator component points to the inserted element or to the already existing element. The `bool` component is `true` if insertion happened and `false` if it did not. -

+

### emplace_hint -``` -template -iterator emplace_hint(const_iterator hint, Args&&... args); -``` +1. ``` + template + iterator emplace_hint(const_iterator hint, Args&&... args); + ``` -**Preconditions:** -`cbegin() <= hint && hint <= cend()` + **Preconditions:** + `cbegin() <= hint && hint <= cend()` -**Effects:** -Inserts a new element into the container only if the container does not already contain an element with an equivalent key. + **Effects:** + Inserts new element into the container if the container doesn't already contain an element with an equivalent key. -New element is constructed as `value_type(std::forward(args)...)`. + New element is constructed as `value_type(std::forward(args)...)`. -The element may be constructed even if there already is an element with the key in the container, in which case the newly constructed element will be destroyed immediately. + The element may be constructed even if there already is an element with the key in the container, in which case the newly constructed element will be destroyed immediately. -Iterator `hint` is used as a suggestion where to start to search insert position. + Iterator `hint` is used as a suggestion where to start to search insert position. -**Returns:** -Iterator to the inserted element or to the already existing element. + **Returns:** + Iterator to the inserted element or to the already existing element. -

+

### insert -``` -std::pair insert(const value_type& value); -``` +1. ``` + std::pair insert(const value_type& value); + ``` -**Effects:** -Inserts copy of `value` only if the container does not already contain an element with an key equivalent to the key of `value`. + **Effects:** + Inserts copy of `value` if the container doesn't already contain an element with an equivalent key. -**Returns:** -Pair consisting of an iterator to the inserted element, or the already-existing element if no insertion happened, and a `bool` denoting whether the insertion took place (`true` if insertion happened, `false` if it did not). + **Returns:** + The iterator component points to the inserted element or to the already existing element. The `bool` component is `true` if insertion happened and `false` if it did not. -

+

-``` -std::pair insert(value_type&& value); -``` +2. ``` + std::pair insert(value_type&& value); + ``` -**Effects:** -Inserts `value` using move semantics only if the container does not already contain an element with an key equivalent to the key of `value`. + **Effects:** + Inserts `value` using move semantics if the container doesn't already contain an element with an equivalent key. -**Returns:** -Pair consisting of an iterator to the inserted element, or the already-existing element if no insertion happened, and a `bool` denoting whether the insertion took place (`true` if insertion happened, `false` if it did not). + **Returns:** + The iterator component points to the inserted element or to the already existing element. The `bool` component is `true` if insertion happened and `false` if it did not. -

+

-``` -iterator insert(const_iterator hint, const value_type& value); -``` +3. ``` + template + std::pair insert(K&& x); + ``` -**Preconditions:** -`cbegin() <= hint && hint <= cend()` + **Effects:** + Inserts new element if the container doesn't already contain an element with a key equivalent to `x`. -**Effects:** -Inserts copy of `value` only if the container does not already contain an element with an key equivalent to the key of `value`. + New element is constructed as `value_type(std::forward(x))`. -Iterator `hint` is used as a suggestion where to start to search insert position. + **Note:** This overload participates in overload resolution only if `Compare::is_transparent` exists and is a valid type. It allows calling this function without constructing an instance of `Key`. -**Returns:** -Iterator to the inserted element or to the already existing element. + **Returns:** + The iterator component points to the inserted element or to the already existing element. The `bool` component is `true` if insertion happened and `false` if it did not. -

+

-``` -iterator insert(const_iterator hint, value_type&& value); -``` +4. ``` + iterator insert(const_iterator hint, const value_type& value); + ``` -**Preconditions:** -`cbegin() <= hint && hint <= cend()` + **Preconditions:** + `cbegin() <= hint && hint <= cend()` -**Effects:** -Inserts `value` using move semantics only if the container does not already contain an element with an key equivalent to the key of `value`. + **Effects:** + Inserts copy of `value` if the container doesn't already contain an element with an equivalent key. -Iterator `hint` is used as a suggestion where to start to search insert position. + Iterator `hint` is used as a suggestion where to start to search insert position. -**Returns:** -Iterator to the inserted element or to the already existing element. + **Returns:** + Iterator to the inserted element or to the already existing element. -

+

-``` -template -void insert(InputIt first, InputIt last); -``` +5. ``` + iterator insert(const_iterator hint, value_type&& value); + ``` -**Effects:** -Inserts elements from range `[first, last)`. + **Preconditions:** + `cbegin() <= hint && hint <= cend()` -The call to this function is equivalent to: -``` -while (first != last) -{ - insert(*first); - ++first; -} -``` + **Effects:** + Inserts `value` using move semantics if the container doesn't already contain an element with an equivalent key. -**Note:** -This overload participates in overload resolution only if `InputIt` satisfies requirements of [*LegacyInputIterator*](https://en.cppreference.com/w/cpp/named_req/InputIterator). + Iterator `hint` is used as a suggestion where to start to search insert position. -

+ **Returns:** + Iterator to the inserted element or to the already existing element. +

-``` -void insert(std::initializer_list ilist); -``` -**Effects:** -Inserts elements from initializer list `ilist`. +6. ``` + template + iterator insert(const_iterator hint, K&& x); + ``` -The call to this function is equivalent to: -``` -insert(ilist.begin(), ilist.end()); -``` + **Preconditions:** + `cbegin() <= hint && hint <= cend()` -

+ **Effects:** + Inserts new element if the container doesn't already contain an element with a key equivalent to `x`. + New element is constructed as `value_type(std::forward(x))`. + Iterator `hint` is used as a suggestion where to start to search insert position. -### erase + **Note:** This overload participates in overload resolution only if all following conditions are satisfied: + 1. `Compare::is_transparent` exists and is a valid type. It allows calling this function without constructing an instance of `Key`. + 2. `std::is_convertible_v` is `false`. + 3. `std::is_convertible_v` is `false`. -``` -iterator erase(iterator pos); -``` -``` -iterator erase(const_iterator pos); -``` + **Returns:** + Iterator to the inserted element or to the already existing element. -**Preconditions:** -`cbegin() <= pos && pos < cend()` +

-**Effects:** -Removes the element at `pos`. -**Returns:** -Iterator following the last removed element. -

+7. ``` + template + void insert(InputIt first, InputIt last); + ``` + **Effects:** + Inserts elements from range `[first, last)`. + The call to this function is equivalent to: + ``` + while (first != last) + { + insert(*first); + ++first; + } + ``` -``` -iterator erase(const_iterator first, const_iterator last); -``` + **Note:** + This overload participates in overload resolution only if `InputIt` satisfies requirements of [*LegacyInputIterator*](https://en.cppreference.com/w/cpp/named_req/InputIterator). -**Preconditions:** -`cbegin() <= first && first <= last && last <= cend()` +

-**Effects:** -Removes the elements in the range `[first, last)`. -**Returns:** -Iterator following the last removed element. -

+8. ``` + void insert(std::initializer_list ilist); + ``` + **Effects:** + Inserts elements from initializer list `ilist`. + The call to this function is equivalent to `insert(ilist.begin(), ilist.end())`. -``` -size_type erase(const Key& key); -``` +

-**Effects:** -Removes the element (if one exists) with the key equivalent to `key`. -**Returns:** -Number of elements removed (0 or 1). -

+### erase +1. ``` + iterator erase(iterator pos); + ``` +2. ``` + iterator erase(const_iterator pos); + ``` + **Preconditions:** + `cbegin() <= pos && pos < cend()` -``` -template -size_type erase(K&& x); -``` + **Effects:** + Removes the element at `pos`. -**Effects:** -Removes the element (if one exists) with key that compares equivalent to the value `x`. + **Returns:** + Iterator following the last removed element. -**Note:** -This overload participates in overload resolution only if `Compare::is_transparent` exists and is a valid type. It allows calling this function without constructing an instance of `Key`. +

-**Returns:** -Number of elements removed (0 or 1). -

+3. ``` + iterator erase(const_iterator first, const_iterator last); + ``` + **Preconditions:** + `cbegin() <= first && first <= last && last <= cend()` -### swap + **Effects:** + Removes the elements in the range `[first, last)`. -``` -void swap(small_flat_set& other); -``` + **Returns:** + Iterator following the last removed element. -**Preconditions:** -`allocator_traits::propagate_on_container_swap::value || get_allocator() == other.get_allocator()` +

-**Effects:** -Exchanges the contents of the container with those of `other`. -**Complexity:** -Constant in the best case. Linear in `this->size()` plus linear in `other.size()` in the worst case. -

+4. ``` + size_type erase(const Key& key); + ``` +5. ``` + template + size_type erase(K&& x); + ``` + **Effects:** + Removes the element (if one exists) with the key equivalent to `key` or `x`. + **Note:** + Overload (5) participates in overload resolution only if `Compare::is_transparent` exists and is a valid type. It allows calling this function without constructing an instance of `Key`. -### lower_bound + **Returns:** + Number of elements removed (0 or 1). -``` -iterator lower_bound(const Key& key); -``` -``` -const_iterator lower_bound(const Key& key) const; -``` +

-**Effects:** -Returns an iterator pointing to the first element with key that is not less than `key`, or `end()` if such an element is not found. -**Complexity:** -Logarithmic in `size()`. -

+### swap +1. ``` + void swap(small_flat_set& other); + ``` + **Preconditions:** + `allocator_traits::propagate_on_container_swap::value || get_allocator() == other.get_allocator()` -``` -template -iterator lower_bound(const K& x); -``` -``` -template -const_iterator lower_bound(const K& x) const; -``` + **Effects:** + Exchanges the contents of the container with those of `other`. -**Effects:** -Returns an iterator pointing to the first element with key that compares not less to the value `x`, or `end()` if such an element is not found. + **Complexity:** + Constant in the best case. Linear in `this->size()` plus linear in `other.size()` in the worst case. -**Note:** -This overload participates in overload resolution only if `Compare::is_transparent` exists and is a valid type. It allows calling this function without constructing an instance of `Key`. +

-**Complexity:** -Logarithmic in `size()`. -

+### lower_bound +1. ``` + iterator lower_bound(const Key& key); + ``` +2. ``` + const_iterator lower_bound(const Key& key) const; + ``` +3. ``` + template + iterator lower_bound(const K& x); + ``` +4. ``` + template + const_iterator lower_bound(const K& x) const; + ``` -### upper_bound + **Effects:** + Returns an iterator pointing to the first element with key that compares **not less than** `key` or `x`. Returns `end()` if no such element is found. -``` -iterator upper_bound(const Key& key); -``` -``` -const_iterator upper_bound(const Key& key) const; -``` + **Note:** + Overloads (3) and (4) participate in overload resolution only if `Compare::is_transparent` exists and is a valid type. It allows calling these functions without constructing an instance of `Key`. -**Effects:** -Returns an iterator pointing to the first element with key that is greater than `key`, or `end()` if such an element is not found. + **Complexity:** + Logarithmic in `size()`. -**Complexity:** -Logarithmic in `size()`. +

-

+### upper_bound -``` -template -iterator upper_bound(const K& x); -``` -``` -template -const_iterator upper_bound(const K& x) const; -``` +1. ``` + iterator upper_bound(const Key& key); + ``` +2. ``` + const_iterator upper_bound(const Key& key) const; + ``` +3. ``` + template + iterator upper_bound(const K& x); + ``` +4. ``` + template + const_iterator upper_bound(const K& x) const; + ``` -**Effects:** -Returns an iterator pointing to the first element with key that compares greater to the value `x`, or `end()` if such an element is not found. + **Effects:** + Returns an iterator pointing to the first element with key that compares **greater than** `key` or `x`. Returns `end()` if no such element is found. -**Note:** -This overload participates in overload resolution only if `Compare::is_transparent` exists and is a valid type. It allows calling this function without constructing an instance of `Key`. + **Note:** + Overloads (3) and (4) participate in overload resolution only if `Compare::is_transparent` exists and is a valid type. It allows calling these functions without constructing an instance of `Key`. -**Complexity:** -Logarithmic in `size()`. + **Complexity:** + Logarithmic in `size()`. -

+

### equal_range -``` -std::pair equal_range(const Key& key); -``` -``` -std::pair equal_range(const Key& key) const; -``` - -**Effects:** -Returns a range containing all elements with the key that is equal to `key`: -* The first iterator in pair points to the first element that is not less than `key`, or `end()` if such an element does not exist. -* The second iterator in pair points to the first element that is greater that `key`, or `end()` is such an element does not exist. - -**Complexity:** -Logarithmic in `size()`. - -

- - - -``` -template -std::pair equal_range(const K& x); -``` -``` -template -std::pair equal_range(const K& x) const; -``` +1. ``` + std::pair equal_range(const Key& key); + ``` +2. ``` + std::pair equal_range(const Key& key) const; + ``` +3. ``` + template + std::pair equal_range(const K& x); + ``` +4. ``` + template + std::pair equal_range(const K& x) const; + ``` -**Effects:** -Returns a range containing all elements with the key that compares equal to the value `x`: -* The first iterator in pair points to the first element that compares not less to the value `x`, or `end()` if such an element does not exist. -* The second iterator in pair points to the first element that compares greater to the value `x`, or `end()` is such an element does not exist. + **Effects:** + Returns a range containing all elements with key that compares equivalent to `key` or `x`. + * The first iterator in pair points to the first element that compares **not less than** `key` or `x`. It is equal to `end()` if no such element is found. + * The second iterator in pair points to the first element that compares **greater than** `key` or `x`. It is equal to `end()` is no such element is found. -**Note:** -This overload participates in overload resolution only if `Compare::is_transparent` exists and is a valid type. It allows calling this function without constructing an instance of `Key`. + **Note:** + Overloads (3) and (4) participate in overload resolution only if `Compare::is_transparent` exists and is a valid type. It allows calling these functions without constructing an instance of `Key`. -**Complexity:** -Logarithmic in `size()`. + **Complexity:** + Logarithmic in `size()`. -

+

### find -``` -iterator find(const Key& key); -``` -``` -const_iterator find(const Key& key) const; -``` - -**Effects:** -Returns an iterator to an element with key equivalent to `key`, or `end()` if such an element is not found. - -**Complexity:** -Logarithmic in `size()`. - -

- - - -``` -template -iterator find(const K& x); -``` -``` -template -const_iterator find(const K& x) const; -``` +1. ``` + iterator find(const Key& key); + ``` +2. ``` + const_iterator find(const Key& key) const; + ``` +3. ``` + template + iterator find(const K& x); + ``` +4. ``` + template + const_iterator find(const K& x) const; + ``` -**Effects:** -Returns an iterator to an element with key that compares equivalent to `x`, or `end()` if such an element is not found. + **Effects:** + Returns an iterator pointing to the element with key equivalent to `key` or `x`. Returns `end()` if no such element is found. -**Note:** -This overload participates in overload resolution only if `Compare::is_transparent` exists and is a valid type. It allows calling this function without constructing an instance of `Key`. + **Note:** + Overloads (3) and (4) participate in overload resolution only if `Compare::is_transparent` exists and is a valid type. It allows calling these functions without constructing an instance of `Key`. -**Complexity:** -Logarithmic in `size()`. + **Complexity:** + Logarithmic in `size()`. -

+

### count -``` -size_type count(const Key& key) const; -``` - -**Effects:** -Returns the number of elements with key equivalent to `key`, which is either 1 or 0 since this container does not allow duplicates. - -**Complexity:** -Logarithmic in `size()`. - -

- - - -``` -template -size_type count(const K& x) const; -``` +1. ``` + size_type count(const Key& key) const; + ``` +2. ``` + template + size_type count(const K& x) const; + ``` -**Effects:** -Returns the number of elements with key that compares equivalent to `x`, which is either 1 or 0 since this container does not allow duplicates. + **Effects:** + Returns the number of elements with key equivalent to `key` or `x`, which is either 1 or 0 since this container does not allow duplicates. -**Note:** -This overload participates in overload resolution only if `Compare::is_transparent` exists and is a valid type. It allows calling this function without constructing an instance of `Key`. + **Note:** + Overload (2) participates in overload resolution only if `Compare::is_transparent` exists and is a valid type. It allows calling this function without constructing an instance of `Key`. -**Complexity:** -Logarithmic in `size()`. + **Complexity:** + Logarithmic in `size()`. -

+

### contains -``` -bool contains(const Key& key) const; -``` - -**Effects:** -Returns `true` if the container contains an element with key equivalent to `key`, otherwise returns `false`. - -**Complexity:** -Logarithmic in `size()`. - -

- - +1. ``` + bool contains(const Key& key) const; + ``` +2. ``` + template + bool contains(const K& x) const; + ``` -``` -template -bool contains(const K& x) const; -``` + **Effects:** + Returns `true` if the container contains an element with key equivalent to `key` or `x`, otherwise returns `false`. -**Effects:** -Returns `true` if the container contains an element with the key that compares equivalent to `x`, otherwise returns `false`. + **Note:** + Overload (2) participates in overload resolution only if `Compare::is_transparent` exists and is a valid type. It allows calling this function without constructing an instance of `Key`. -**Note:** -This overload participates in overload resolution only if `Compare::is_transparent` exists and is a valid type. It allows calling this function without constructing an instance of `Key`. + **Complexity:** + Logarithmic in `size()`. -**Complexity:** -Logarithmic in `size()`. - -

+

### data -``` -value_type* data() noexcept; -``` -``` -const value_type* data() const noexcept; -``` +1. ``` + value_type* data() noexcept; + ``` +2. ``` + const value_type* data() const noexcept; + ``` -**Effects:** -Returns pointer to the underlying array serving as element storage. The pointer is such that range `[data(), data() + size())` is always a valid range, even if the container is empty. `data()` is not dereferenceable if the container is empty. + **Effects:** + Returns pointer to the underlying array serving as element storage. The pointer is such that range `[data(), data() + size())` is always a valid range, even if the container is empty. `data()` is not dereferenceable if the container is empty. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

@@ -1232,186 +1194,186 @@ Constant. ### operator== -``` -template -bool operator== -( - const small_flat_set& x, - const small_flat_set& y -); -``` +1. ``` + template + bool operator== + ( + const small_flat_set& x, + const small_flat_set& y + ); + ``` -**Effects:** -Checks if the contents of `x` and `y` are equal. + **Effects:** + Checks if the contents of `x` and `y` are equal. -The contents of `x` and `y` are equal if the following conditions hold: -* `x.size() == y.size()` -* Each element in `x` compares equal with the element in `y` at the same position. + The contents of `x` and `y` are equal if the following conditions hold: + * `x.size() == y.size()` + * Each element in `x` compares equal with the element in `y` at the same position. -The comparison is performed by `std::equal`. -This comparison ignores the container's ordering `Compare`. + The comparison is performed by `std::equal`. + This comparison ignores the container's ordering `Compare`. -**Returns:** -Returns `true` if the contents of the `x` and `y` are equal, `false` otherwise. + **Returns:** + Returns `true` if the contents of the `x` and `y` are equal, `false` otherwise. -

+

### operator!= -``` -template -bool operator!= -( - const small_flat_set& x, - const small_flat_set& y -); -``` +1. ``` + template + bool operator!= + ( + const small_flat_set& x, + const small_flat_set& y + ); + ``` -**Effects:** -Checks if the contents of `x` and `y` are equal. + **Effects:** + Checks if the contents of `x` and `y` are equal. -For details see `operator==`. + For details see `operator==`. -**Returns:** -Returns `true` if the contents of the `x` and `y` are not equal, `false` otherwise. + **Returns:** + Returns `true` if the contents of the `x` and `y` are not equal, `false` otherwise. -

+

### operator< -``` -template -bool operator< -( - const small_flat_set& x, - const small_flat_set& y -); -``` +1. ``` + template + bool operator< + ( + const small_flat_set& x, + const small_flat_set& y + ); + ``` -**Effects:** -Compares the contents of `x` and `y` lexicographically. -The comparison is performed by a function `std::lexicographical_compare`. -This comparison ignores the container's ordering `Compare`. + **Effects:** + Compares the contents of `x` and `y` lexicographically. + The comparison is performed by a function `std::lexicographical_compare`. + This comparison ignores the container's ordering `Compare`. -**Returns:** -`true` if the contents of the `x` are lexicographically less than the contents of `y`, `false` otherwise. + **Returns:** + `true` if the contents of the `x` are lexicographically less than the contents of `y`, `false` otherwise. -

+

### operator> -``` -template -bool operator> -( - const small_flat_set& x, - const small_flat_set& y -); -``` +1. ``` + template + bool operator> + ( + const small_flat_set& x, + const small_flat_set& y + ); + ``` -**Effects:** -Compares the contents of lhs and rhs lexicographically. + **Effects:** + Compares the contents of lhs and rhs lexicographically. -The comparison is performed by a function `std::lexicographical_compare`. -This comparison ignores the container's ordering `Compare`. + The comparison is performed by a function `std::lexicographical_compare`. + This comparison ignores the container's ordering `Compare`. -**Returns:** -`true` if the contents of the `x` are lexicographically greater than the contents of `y`, `false` otherwise. + **Returns:** + `true` if the contents of the `x` are lexicographically greater than the contents of `y`, `false` otherwise. -

+

### operator<= -``` -template -bool operator<= -( - const small_flat_set& x, - const small_flat_set& y -); -``` +1. ``` + template + bool operator<= + ( + const small_flat_set& x, + const small_flat_set& y + ); + ``` -**Effects:** -Compares the contents of `x` and `y` lexicographically. -The comparison is performed by a function `std::lexicographical_compare`. -This comparison ignores the container's ordering `Compare`. + **Effects:** + Compares the contents of `x` and `y` lexicographically. + The comparison is performed by a function `std::lexicographical_compare`. + This comparison ignores the container's ordering `Compare`. -**Returns:** -`true` if the contents of the `x` are lexicographically less than or equal to the contents of `y`, `false` otherwise. + **Returns:** + `true` if the contents of the `x` are lexicographically less than or equal to the contents of `y`, `false` otherwise. -

+

### operator>= -``` -template -bool operator>= -( - const small_flat_set& x, - const small_flat_set& y -); -``` +1. ``` + template + bool operator>= + ( + const small_flat_set& x, + const small_flat_set& y + ); + ``` -**Effects:** -Compares the contents of `x` and `y` lexicographically. -The comparison is performed by a function `std::lexicographical_compare`. -This comparison ignores the container's ordering `Compare`. + **Effects:** + Compares the contents of `x` and `y` lexicographically. + The comparison is performed by a function `std::lexicographical_compare`. + This comparison ignores the container's ordering `Compare`. -**Returns:** -`true` if the contents of the `x` are lexicographically greater than or equal to the contents of `y`, `false` otherwise. + **Returns:** + `true` if the contents of the `x` are lexicographically greater than or equal to the contents of `y`, `false` otherwise. -

+

### swap -``` -template -void swap -( - small_flat_set& x, - small_flat_set& y -); -``` +1. ``` + template + void swap + ( + small_flat_set& x, + small_flat_set& y + ); + ``` -**Effects:** -Swaps the contents of `x` and `y`. Calls `x.swap(y)`. + **Effects:** + Swaps the contents of `x` and `y`. Calls `x.swap(y)`. -

+

### erase_if -``` -template -typename small_flat_set::size_type - erase_if(small_flat_set& c, Predicate pred); -``` +1. ``` + template + typename small_flat_set::size_type + erase_if(small_flat_set& c, Predicate pred); + ``` -**Effects:** -Erases all elements that satisfy the predicate `pred` from the container. + **Effects:** + Erases all elements that satisfy the predicate `pred` from the container. -`pred` is unary predicate which returns `true` if the element should be removed. + `pred` is unary predicate which returns `true` if the element should be removed. -**Returns:** -The number of erased elements. + **Returns:** + The number of erased elements. -**Complexity:** -Linear. + **Complexity:** + Linear. -

+

diff --git a/doc/small_unordered_flat_map.md b/doc/small_unordered_flat_map.md index 2f02726..ffc3785 100644 --- a/doc/small_unordered_flat_map.md +++ b/doc/small_unordered_flat_map.md @@ -101,7 +101,8 @@ Iterators to elements of `sfl::small_unordered_flat_map` are random access itera std::size_t N ``` - Size of the internal statically allocated array. + Size of the internal statically allocated array, i.e. the maximal number of elements that can fit into this array. + This parameter can be zero. 4. ``` @@ -175,1108 +176,1192 @@ static constexpr size_type static_capacity = N; ### (constructor) -``` -small_unordered_flat_map() - noexcept( +1. ``` + small_unordered_flat_map() noexcept( std::is_nothrow_default_constructible::value && std::is_nothrow_default_constructible::value ); -``` -``` -explicit small_unordered_flat_map(const KeyEqual& equal) - noexcept( + ``` +2. ``` + explicit small_unordered_flat_map(const KeyEqual& equal) noexcept( std::is_nothrow_default_constructible::value && std::is_nothrow_copy_constructible::value ); -``` -``` -explicit small_unordered_flat_map(const Allocator& alloc) - noexcept( + ``` +3. ``` + explicit small_unordered_flat_map(const Allocator& alloc) noexcept( std::is_nothrow_copy_constructible::value && std::is_nothrow_default_constructible::value ); -``` -``` -explicit small_unordered_flat_map(const KeyEqual& equal, const Allocator& alloc) - noexcept( + ``` +4. ``` + explicit small_unordered_flat_map(const KeyEqual& equal, const Allocator& alloc) noexcept( std::is_nothrow_copy_constructible::value && std::is_nothrow_copy_constructible::value ); -``` + ``` -**Effects:** -Constructs an empty container. + **Effects:** + Constructs an empty container. -

+

-``` -template -small_unordered_flat_map(InputIt first, InputIt last); -``` -``` -template -small_unordered_flat_map(InputIt first, InputIt last, const KeyEqual& equal); -``` -``` -template -small_unordered_flat_map(InputIt first, InputIt last, const Allocator& alloc); -``` -``` -template -small_unordered_flat_map(InputIt first, InputIt last, const KeyEqual& equal, const Allocator& alloc); -``` +5. ``` + template + small_unordered_flat_map(InputIt first, InputIt last); + ``` +6. ``` + template + small_unordered_flat_map(InputIt first, InputIt last, const KeyEqual& equal); + ``` +7. ``` + template + small_unordered_flat_map(InputIt first, InputIt last, const Allocator& alloc); + ``` +8. ``` + template + small_unordered_flat_map(InputIt first, InputIt last, const KeyEqual& equal, const Allocator& alloc); + ``` -**Effects:** -Constructs an empty container and inserts elements from the range `[first, last)`. + **Effects:** + Constructs an empty container and inserts elements from the range `[first, last)`. -**Note:** -This overload participates in overload resolution only if `InputIt` satisfies requirements of [*LegacyInputIterator*](https://en.cppreference.com/w/cpp/named_req/InputIterator). + **Note:** + This overload participates in overload resolution only if `InputIt` satisfies requirements of [*LegacyInputIterator*](https://en.cppreference.com/w/cpp/named_req/InputIterator). -

+

-``` -small_unordered_flat_map(std::initializer_list ilist); -``` -``` -small_unordered_flat_map(std::initializer_list ilist, const KeyEqual& equal); -``` -``` -small_unordered_flat_map(std::initializer_list ilist, const Allocator& alloc); -``` -``` -small_unordered_flat_map(std::initializer_list ilist, const KeyEqual& equal, const Allocator& alloc); -``` +9. ``` + small_unordered_flat_map(std::initializer_list ilist); + ``` +10. ``` + small_unordered_flat_map(std::initializer_list ilist, const KeyEqual& equal); + ``` +11. ``` + small_unordered_flat_map(std::initializer_list ilist, const Allocator& alloc); + ``` +12. ``` + small_unordered_flat_map(std::initializer_list ilist, const KeyEqual& equal, const Allocator& alloc); + ``` -**Effects:** -Constructs an empty container and inserts elements from the initializer list `ilist`. + **Effects:** + Constructs an empty container and inserts elements from the initializer list `ilist`. -

+

-``` -small_unordered_flat_map(const small_unordered_flat_map& other); -``` -``` -small_unordered_flat_map(const small_unordered_flat_map& other, const Allocator& alloc); -``` +13. ``` + small_unordered_flat_map(const small_unordered_flat_map& other); + ``` +14. ``` + small_unordered_flat_map(const small_unordered_flat_map& other, const Allocator& alloc); + ``` -**Effects:** -Copy constructor. -Constructs the container with the copy of the contents of `other`. + **Effects:** + Copy constructor. + Constructs the container with the copy of the contents of `other`. -**Complexity:** -Linear in `other.size()`. + **Complexity:** + Linear in `other.size()`. -

+

-``` -small_unordered_flat_map(small_unordered_flat_map&& other); -``` -``` -small_unordered_flat_map(small_unordered_flat_map&& other, const Allocator& alloc); -``` +15. ``` + small_unordered_flat_map(small_unordered_flat_map&& other); + ``` +16. ``` + small_unordered_flat_map(small_unordered_flat_map&& other, const Allocator& alloc); + ``` -**Effects:** -Move constructor. -Constructs the container with the contents of `other` using move semantics. + **Effects:** + Move constructor. + Constructs the container with the contents of `other` using move semantics. -`other` is not guaranteed to be empty after the move. + `other` is not guaranteed to be empty after the move. -`other` is in a valid but unspecified state after the move. + `other` is in a valid but unspecified state after the move. -**Complexity:** -Constant in the best case. Linear in `N` in the worst case. + **Complexity:** + Constant in the best case. Linear in `N` in the worst case. -

+

### (destructor) -``` -~small_unordered_flat_map(); -``` +1. ``` + ~small_unordered_flat_map(); + ``` -**Effects:** -Destructs the container. The destructors of the elements are called and the used storage is deallocated. + **Effects:** + Destructs the container. The destructors of the elements are called and the used storage is deallocated. -**Complexity:** -Linear in `size()`. + **Complexity:** + Linear in `size()`. -

+

### operator= -``` -small_unordered_flat_map& operator=(const small_unordered_flat_map& other); -``` +1. ``` + small_unordered_flat_map& operator=(const small_unordered_flat_map& other); + ``` -**Effects:** -Copy assignment operator. -Replaces the contents with a copy of the contents of `other`. + **Effects:** + Copy assignment operator. + Replaces the contents with a copy of the contents of `other`. -**Returns:** -`*this()`. + **Returns:** + `*this()`. -**Complexity:** -Linear in `this->size()` plus linear in `other.size()`. + **Complexity:** + Linear in `this->size()` plus linear in `other.size()`. -

+

-``` -small_unordered_flat_map& operator=(small_unordered_flat_map&& other); -``` +2. ``` + small_unordered_flat_map& operator=(small_unordered_flat_map&& other); + ``` -**Effects:** -Move assignment operator. -Replaces the contents with those of `other` using move semantics. + **Effects:** + Move assignment operator. + Replaces the contents with those of `other` using move semantics. -`other` is not guaranteed to be empty after the move. + `other` is not guaranteed to be empty after the move. -`other` is in a valid but unspecified state after the move. + `other` is in a valid but unspecified state after the move. -**Returns:** -`*this()`. + **Returns:** + `*this()`. -**Complexity:** + **Complexity:** -* The best case: Linear in `this->size()` plus constant. -* The worst case: Linear in `this->size()` plus linear in `other.size()`. + * The best case: Linear in `this->size()` plus constant. + * The worst case: Linear in `this->size()` plus linear in `other.size()`. -

+

-``` -small_unordered_flat_map& operator=(std::initializer_list ilist); -``` +3. ``` + small_unordered_flat_map& operator=(std::initializer_list ilist); + ``` -**Effects:** -Replaces the contents with those identified by initializer list `ilist`. + **Effects:** + Replaces the contents with those identified by initializer list `ilist`. -**Returns:** -`*this()`. + **Returns:** + `*this()`. -**Complexity:** -Linear in `this->size()` plus linear in `ilist.size()`. + **Complexity:** + Linear in `this->size()` plus linear in `ilist.size()`. -

+

### get_allocator -``` -allocator_type get_allocator() const noexcept; -``` +1. ``` + allocator_type get_allocator() const noexcept; + ``` -**Effects:** -Returns the allocator associated with the container. + **Effects:** + Returns the allocator associated with the container. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

### key_eq -``` -key_equal key_eq() const; -``` +1. ``` + key_equal key_eq() const; + ``` -**Effects:** -Returns the function object that compares keys for equality, which is a copy of this container's constructor argument `equal`. + **Effects:** + Returns the function object that compares keys for equality, which is a copy of this container's constructor argument `equal`. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

### value_eq -``` -value_equal value_eq() const; -``` +1. ``` + value_equal value_eq() const; + ``` -**Effects:** -Returns a function object that compares objects of type `value_type`. + **Effects:** + Returns a function object that compares objects of type `value_type`. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

### begin, cbegin -``` -iterator begin() noexcept; -``` -``` -const_iterator begin() const noexcept; -``` -``` -const_iterator cbegin() const noexcept; -``` - -**Effects:** -Returns an iterator to the first element of the container. +1. ``` + iterator begin() noexcept; + ``` +2. ``` + const_iterator begin() const noexcept; + ``` +3. ``` + const_iterator cbegin() const noexcept; + ``` -If the container is empty, the returned iterator will be equal to `end()`. + **Effects:** + Returns an iterator to the first element of the container. + If the container is empty, the returned iterator will be equal to `end()`. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

### end, cend -``` -iterator end() noexcept; -``` -``` -const_iterator end() const noexcept; -``` -``` -const_iterator cend() const noexcept; -``` - -**Effects:** -Returns an iterator to the element following the last element of the container. +1. ``` + iterator end() noexcept; + ``` +2. ``` + const_iterator end() const noexcept; + ``` +3. ``` + const_iterator cend() const noexcept; + ``` -This element acts as a placeholder; attempting to access it results in undefined behavior. + **Effects:** + Returns an iterator to the element following the last element of the container. + This element acts as a placeholder; attempting to access it results in undefined behavior. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

### nth -``` -iterator nth(size_type pos) noexcept; -``` -``` -const_iterator nth(size_type pos) const noexcept; -``` +1. ``` + iterator nth(size_type pos) noexcept; + ``` +2. ``` + const_iterator nth(size_type pos) const noexcept; + ``` -**Preconditions:** -`pos <= size()` + **Preconditions:** + `pos <= size()` -**Effects:** -Returns an iterator to the element at position `pos`. -If `pos == size()`, the returned iterator is equal to `end()`. + **Effects:** + Returns an iterator to the element at position `pos`. -**Complexity:** -Constant. + If `pos == size()`, the returned iterator is equal to `end()`. -

+ **Complexity:** + Constant. + +

### index_of -``` -size_type index_of(const_iterator pos) const noexcept; -``` +1. ``` + size_type index_of(const_iterator pos) const noexcept; + ``` -**Preconditions:** -`cbegin() <= pos && pos <= cend()` + **Preconditions:** + `cbegin() <= pos && pos <= cend()` -**Effects:** -Returns position of the element pointed by iterator `pos`, i.e. `std::distance(begin(), pos)`. + **Effects:** + Returns position of the element pointed by iterator `pos`, i.e. `std::distance(begin(), pos)`. -If `pos == end()`, the returned value is equal to `size()`. + If `pos == end()`, the returned value is equal to `size()`. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

### empty -``` -bool empty() const noexcept; -``` +1. ``` + bool empty() const noexcept; + ``` -**Effects:** -Returns `true` if the container has no elements, i.e. whether `begin() == end()`. + **Effects:** + Returns `true` if the container has no elements, i.e. whether `begin() == end()`. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

### size -``` -size_type size() const noexcept; -``` +1. ``` + size_type size() const noexcept; + ``` -**Effects:** -Returns the number of elements in the container, i.e. `std::distance(begin(), end())`. + **Effects:** + Returns the number of elements in the container, i.e. `std::distance(begin(), end())`. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

### max_size -``` -size_type max_size() const noexcept; -``` +1. ``` + size_type max_size() const noexcept; + ``` -**Effects:** -Returns the maximum number of elements the container is able to hold, i.e. `std::distance(begin(), end())` for the largest container. + **Effects:** + Returns the maximum number of elements the container is able to hold, i.e. `std::distance(begin(), end())` for the largest container. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

### capacity -``` -size_type capacity() const noexcept; -``` +1. ``` + size_type capacity() const noexcept; + ``` -**Effects:** -Returns the number of elements that the container has currently allocated space for. + **Effects:** + Returns the number of elements that the container has currently allocated space for. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

### available -``` -size_type available() const noexcept; -``` +1. ``` + size_type available() const noexcept; + ``` -**Effects:** -Returns the number of elements that can be inserted into the container without requiring allocation of additional memory. + **Effects:** + Returns the number of elements that can be inserted into the container without requiring allocation of additional memory. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

### reserve -``` -void reserve(size_type new_cap); -``` +1. ``` + void reserve(size_type new_cap); + ``` -**Effects:** -Tries to increase capacity by allocating additional memory. + **Effects:** + Tries to increase capacity by allocating additional memory. -If `new_cap > capacity()`, the function allocates memory for new storage of capacity equal to the value of `new_cap`, moves elements from old storage to new storage, and deallocates memory used by old storage. Otherwise, the function does nothing. + If `new_cap > capacity()`, the function allocates memory for new storage of capacity equal to the value of `new_cap`, moves elements from old storage to new storage, and deallocates memory used by old storage. Otherwise, the function does nothing. -This function does not change size of the container. + This function does not change size of the container. -If the capacity is changed, all iterators and all references to the elements are invalidated. Otherwise, no iterators or references are invalidated. + If the capacity is changed, all iterators and all references to the elements are invalidated. Otherwise, no iterators or references are invalidated. -**Complexity:** -Linear. + **Complexity:** + Linear. -**Exceptions:** + **Exceptions:** -* `Allocator::allocate` may throw. -* `T`'s move or copy constructor may throw. + * `Allocator::allocate` may throw. + * `T`'s move or copy constructor may throw. -If an exception is thrown: + If an exception is thrown: -* If type `T` has available `noexcept` move constructor: - * This function has no effects (strong exception guarantee). -* Else if type `T` has available copy constructor: - * This function has no effects (strong exception guarantee). -* Else if type `T` has available throwing move constructor: - * Container is changed but in valid state (basic exception guarantee). + * If type `T` has available `noexcept` move constructor: + * This function has no effects (strong exception guarantee). + * Else if type `T` has available copy constructor: + * This function has no effects (strong exception guarantee). + * Else if type `T` has available throwing move constructor: + * Container is changed but in valid state (basic exception guarantee). -

+

### shrink_to_fit -``` -void shrink_to_fit(); -``` +1. ``` + void shrink_to_fit(); + ``` -**Effects:** -Tries to reduce memory usage by freeing unused memory. + **Effects:** + Tries to reduce memory usage by freeing unused memory. -1. If `size() > N && size() < capacity()`, the function allocates memory for new storage of capacity equal to the value of `size()`, moves elements from old storage to new storage, and deallocates memory used by old storage. -2. If `size() <= N && N < capacity()`, the function sets new storage to be internal statically allocated array of capacity `N`, moves elements from old storage to new storage, and deallocates memory used by old storage. -3. Otherwise the function does nothing. + 1. If `size() > N && size() < capacity()`, the function allocates memory for new storage of capacity equal to the value of `size()`, moves elements from old storage to new storage, and deallocates memory used by old storage. -This function does not change size of the container. + 2. If `size() <= N && N < capacity()`, the function sets new storage to be internal statically allocated array of capacity `N`, moves elements from old storage to new storage, and deallocates memory used by old storage. -If the capacity is changed, all iterators and all references to the elements are invalidated. Otherwise, no iterators or references are invalidated. + 3. Otherwise the function does nothing. -**Complexity:** -Linear. + This function does not change size of the container. -**Exceptions:** + If the capacity is changed, all iterators and all references to the elements are invalidated. Otherwise, no iterators or references are invalidated. -* `Allocator::allocate` may throw. -* `T`'s move or copy constructor may throw. + **Complexity:** + Linear. -If an exception is thrown: + **Exceptions:** -* If type `T` has available `noexcept` move constructor: - * This function has no effects (strong exception guarantee). -* Else if type `T` has available copy constructor: - * This function has no effects (strong exception guarantee). -* Else if type `T` has available throwing move constructor: - * Container is changed but in valid state (basic exception guarantee). + * `Allocator::allocate` may throw. + * `T`'s move or copy constructor may throw. -

+ If an exception is thrown: + + * If type `T` has available `noexcept` move constructor: + * This function has no effects (strong exception guarantee). + * Else if type `T` has available copy constructor: + * This function has no effects (strong exception guarantee). + * Else if type `T` has available throwing move constructor: + * Container is changed but in valid state (basic exception guarantee). + +

### clear -``` -void clear() noexcept; -``` +1. ``` + void clear() noexcept; + ``` -**Effects:** -Erases all elements from the container. -After this call, `size()` returns zero and `capacity()` remains unchanged. + **Effects:** + Erases all elements from the container. + After this call, `size()` returns zero and `capacity()` remains unchanged. -**Complexity:** -Linear in `size()`. + **Complexity:** + Linear in `size()`. -

+

### emplace -``` -template -std::pair emplace(Args&&... args); -``` +1. ``` + template + std::pair emplace(Args&&... args); + ``` -**Effects:** -Inserts a new element into the container only if the container does not already contain an element with an equivalent key. + **Effects:** + Inserts new element into the container if the container doesn't already contain an element with an equivalent key. -New element is constructed as `value_type(std::forward(args)...)`. + New element is constructed as `value_type(std::forward(args)...)`. -The element may be constructed even if there already is an element with the key in the container, in which case the newly constructed element will be destroyed immediately. + The element may be constructed even if there already is an element with the key in the container, in which case the newly constructed element will be destroyed immediately. -**Returns:** -Pair consisting of an iterator to the inserted element, or the already-existing element if no insertion happened, and a `bool` denoting whether the insertion took place (`true` if insertion happened, `false` if it did not). + **Returns:** + The iterator component points to the inserted element or to the already existing element. The `bool` component is `true` if insertion happened and `false` if it did not. -

+

### emplace_hint -``` -template -iterator emplace_hint(const_iterator hint, Args&&... args); -``` +1. ``` + template + iterator emplace_hint(const_iterator hint, Args&&... args); + ``` -**Preconditions:** -`cbegin() <= hint && hint <= cend()` + **Preconditions:** + `cbegin() <= hint && hint <= cend()` -**Effects:** -Inserts a new element into the container only if the container does not already contain an element with an equivalent key. + **Effects:** + Inserts new element into the container if the container doesn't already contain an element with an equivalent key. -New element is constructed as `value_type(std::forward(args)...)`. + New element is constructed as `value_type(std::forward(args)...)`. -The element may be constructed even if there already is an element with the key in the container, in which case the newly constructed element will be destroyed immediately. + The element may be constructed even if there already is an element with the key in the container, in which case the newly constructed element will be destroyed immediately. -Iterator `hint` is used as a suggestion where to start to search insert position. + Iterator `hint` is used as a suggestion where to start to search insert position. -**Returns:** -Iterator to the inserted element or to the already existing element. + Iterator `hint` is ignored due to container's underlying storage implementation. This overload exists just to have this container compatible with standard C++ containers as much as possible. -

+ **Returns:** + Iterator to the inserted element or to the already existing element. + +

### insert -``` -std::pair insert(const value_type& value); -``` +1. ``` + std::pair insert(const value_type& value); + ``` -**Effects:** -Inserts copy of `value` only if the container does not already contain an element with an key equivalent to the key of `value`. + **Effects:** + Inserts copy of `value` if the container doesn't already contain an element with an equivalent key. -**Returns:** -Pair consisting of an iterator to the inserted element, or the already-existing element if no insertion happened, and a `bool` denoting whether the insertion took place (`true` if insertion happened, `false` if it did not). + **Returns:** + The iterator component points to the inserted element or to the already existing element. The `bool` component is `true` if insertion happened and `false` if it did not. -

+

-``` -std::pair insert(value_type&& value); -``` +2. ``` + std::pair insert(value_type&& value); + ``` -**Effects:** -Inserts `value` using move semantics only if the container does not already contain an element with an key equivalent to the key of `value`. + **Effects:** + Inserts `value` using move semantics if the container doesn't already contain an element with an equivalent key. -**Returns:** -Pair consisting of an iterator to the inserted element, or the already-existing element if no insertion happened, and a `bool` denoting whether the insertion took place (`true` if insertion happened, `false` if it did not). + **Returns:** + The iterator component points to the inserted element or to the already existing element. The `bool` component is `true` if insertion happened and `false` if it did not. -

+

-``` -template -std::pair insert(P&& value); -``` +3. ``` + template + std::pair insert(P&& value); + ``` -**Effects:** -Inserts a new element into the container only if the container does not already contain an element with an equivalent key. + **Effects:** + Inserts new element into the container if the container doesn't already contain an element with an equivalent key. -New element is constructed as `value_type(std::forward

(value))`. + New element is constructed as `value_type(std::forward

(value))`. -**Note:** -This overload participates in overload resolution only if `std::is_constructible::value` is `true`. + **Note:** + This overload participates in overload resolution only if `std::is_constructible::value` is `true`. -**Returns:** -Pair consisting of an iterator to the inserted element, or the already-existing element if no insertion happened, and a `bool` denoting whether the insertion took place (`true` if insertion happened, `false` if it did not). + **Returns:** + The iterator component points to the inserted element or to the already existing element. The `bool` component is `true` if insertion happened and `false` if it did not. -

+

-``` -iterator insert(const_iterator hint, const value_type& value); -``` +4. ``` + iterator insert(const_iterator hint, const value_type& value); + ``` -**Preconditions:** -`cbegin() <= hint && hint <= cend()` + **Preconditions:** + `cbegin() <= hint && hint <= cend()` -**Effects:** -Inserts copy of `value` only if the container does not already contain an element with an key equivalent to the key of `value`. + **Effects:** + Inserts copy of `value` if the container doesn't already contain an element with an equivalent key. -Iterator `hint` is used as a suggestion where to start to search insert position. + Iterator `hint` is used as a suggestion where to start to search insert position. -**Returns:** -Iterator to the inserted element or to the already existing element. + Iterator `hint` is ignored due to container's underlying storage implementation. This overload exists just to have this container compatible with standard C++ containers as much as possible. -

+ **Returns:** + Iterator to the inserted element or to the already existing element. +

-``` -iterator insert(const_iterator hint, value_type&& value); -``` -**Preconditions:** -`cbegin() <= hint && hint <= cend()` +5. ``` + iterator insert(const_iterator hint, value_type&& value); + ``` -**Effects:** -Inserts `value` using move semantics only if the container does not already contain an element with an key equivalent to the key of `value`. + **Preconditions:** + `cbegin() <= hint && hint <= cend()` -Iterator `hint` is used as a suggestion where to start to search insert position. + **Effects:** + Inserts `value` using move semantics if the container doesn't already contain an element with an equivalent key. -**Returns:** -Iterator to the inserted element or to the already existing element. + Iterator `hint` is used as a suggestion where to start to search insert position. -

+ Iterator `hint` is ignored due to container's underlying storage implementation. This overload exists just to have this container compatible with standard C++ containers as much as possible. + **Returns:** + Iterator to the inserted element or to the already existing element. +

-``` -template -iterator insert(const_iterator hint, P&& value); -``` -**Preconditions:** -`cbegin() <= hint && hint <= cend()` -**Effects:** -Inserts a new element into the container only if the container does not already contain an element with an equivalent key. +6. ``` + template + iterator insert(const_iterator hint, P&& value); + ``` -New element is constructed as `value_type(std::forward

(value))`. + **Preconditions:** + `cbegin() <= hint && hint <= cend()` -Iterator `hint` is used as a suggestion where to start to search insert position. + **Effects:** + Inserts new element into the container if the container doesn't already contain an element with an equivalent key. -**Note:** -This overload participates in overload resolution only if `std::is_constructible::value` is `true`. + New element is constructed as `value_type(std::forward

(value))`. -**Returns:** -Iterator to the inserted element or to the already existing element. + Iterator `hint` is used as a suggestion where to start to search insert position. -

+ Iterator `hint` is ignored due to container's underlying storage implementation. This overload exists just to have this container compatible with standard C++ containers as much as possible. + **Note:** + This overload participates in overload resolution only if `std::is_constructible::value` is `true`. + **Returns:** + Iterator to the inserted element or to the already existing element. -``` -template -void insert(InputIt first, InputIt last); -``` +

-**Effects:** -Inserts elements from range `[first, last)`. -The call to this function is equivalent to: -``` -while (first != last) -{ - insert(*first); - ++first; -} -``` -**Note:** -This overload participates in overload resolution only if `InputIt` satisfies requirements of [*LegacyInputIterator*](https://en.cppreference.com/w/cpp/named_req/InputIterator). +7. ``` + template + void insert(InputIt first, InputIt last); + ``` -

+ **Effects:** + Inserts elements from range `[first, last)`. + The call to this function is equivalent to: + ``` + while (first != last) + { + insert(*first); + ++first; + } + ``` + **Note:** + This overload participates in overload resolution only if `InputIt` satisfies requirements of [*LegacyInputIterator*](https://en.cppreference.com/w/cpp/named_req/InputIterator). -``` -void insert(std::initializer_list ilist); -``` +

-**Effects:** -Inserts elements from initializer list `ilist`. -The call to this function is equivalent to: -``` -insert(ilist.begin(), ilist.end()); -``` -

+8. ``` + void insert(std::initializer_list ilist); + ``` + + **Effects:** + Inserts elements from initializer list `ilist`. + + The call to this function is equivalent to `insert(ilist.begin(), ilist.end())`. + +

### insert_or_assign -``` -template -std::pair insert_or_assign(const Key& key, M&& obj); -``` -``` -template -std::pair insert_or_assign(Key&& key, M&& obj); -``` +1. ``` + template + std::pair insert_or_assign(const Key& key, M&& obj); + ``` +2. ``` + template + std::pair insert_or_assign(Key&& key, M&& obj); + ``` +3. ``` + template + std::pair insert_or_assign(K&& key, M&& obj); + ``` -**Effects:** -If a key equivalent to `key` already exists in the container, assigns `std::forward(obj)` to the mapped type corresponding to the key `key`. If the key does not exist, inserts the new element. - -* If the first overload is used, the new element is constructed as - ``` - value_type( std::piecewise_construct, - std::forward_as_tuple(key), - std::forward_as_tuple(std::forward(obj)) ) - ``` -* If the second overload is used, the new element is constructed as - ``` - value_type( std::piecewise_construct, - std::forward_as_tuple(std::move(key)), - std::forward_as_tuple(std::forward(obj)) ) - ``` - -**Note:** -This overload participates in overload resolution only if `std::is_assignable_v` is `true`. - -**Returns:** -A pair of iterator and `bool`: -* The iterator component points at the element that was inserted or updated. -* The `bool` component is `true` if the insertion took place and `false` if the assignment took place. + **Effects:** + If a key equivalent to `key` already exists in the container, assigns `std::forward(obj)` to the mapped type corresponding to the key `key`. If the key does not exist, inserts the new element. -

+ * **Overload (1):** New element is constructed as + ``` + value_type( std::piecewise_construct, + std::forward_as_tuple(key), + std::forward_as_tuple(std::forward(obj)) ) + ``` + **Note:** This overload participates in overload resolution only if `std::is_assignable_v` is `true`. -``` -template -iterator insert_or_assign(const_iterator hint, const Key& key, M&& obj); -``` -``` -template -iterator insert_or_assign(const_iterator hint, Key&& key, M&& obj); -``` + * **Overload (2):** New element is constructed as -**Preconditions:** -`cbegin() <= hint && hint <= cend()` + ``` + value_type( std::piecewise_construct, + std::forward_as_tuple(std::move(key)), + std::forward_as_tuple(std::forward(obj)) ) + ``` -**Effects:** -Same as `insert_or_assign` overloads that do not take `hint`. + **Note:** This overload participates in overload resolution only if `std::is_assignable_v` is `true`. -Iterator `hint` is used as a suggestion where to start to search insert position. + * **Overload (3):** New element is constructed as -**Note:** -This overload participates in overload resolution only if `std::is_assignable_v` is `true`. + ``` + value_type( std::piecewise_construct, + std::forward_as_tuple(std::forward(key)), + std::forward_as_tuple(std::forward(obj)) ) + ``` -**Returns:** -Iterator to the element that was inserted or updated. + **Note:** This overload participates in overload resolution only if all following conditions are satisfied: + 1. `KeyEqual::is_transparent` exists and is a valid type. It allows calling this function without constructing an instance of `Key`. + 2. `std::is_assignable_v` is `true`. -

+ **Returns:** + The iterator component points to the inserted element or to the updated element. The `bool` component is `true` if insertion took place and `false` if assignment took place. +

-### try_emplace -``` -template -std::pair try_emplace(const Key& key, Args&&... args); -``` -``` -template -std::pair try_emplace(Key&& key, Args&&... args); -``` +4. ``` + template + iterator insert_or_assign(const_iterator hint, const Key& key, M&& obj); + ``` +5. ``` + template + iterator insert_or_assign(const_iterator hint, Key&& key, M&& obj); + ``` +6. ``` + template + iterator insert_or_assign(const_iterator hint, K&& key, M&& obj); + ``` -**Effects:** -If a key equivalent to `key` already exists in the container, does nothing. Otherwise, behaves like `emplace`. - -* If the first overload is used, the new element is constructed as - ``` - value_type( std::piecewise_construct, - std::forward_as_tuple(key), - std::forward_as_tuple(std::forward(args)...) ) - ``` -* If the second overload is used, the new element is constructed as - ``` - value_type( std::piecewise_construct, - std::forward_as_tuple(std::move(key)), - std::forward_as_tuple(std::forward(args)...) ) - ``` - -**Returns:** -A pair of iterator and `bool`: -* The iterator component points at the inserted element or to the already existing element. -* The `bool` component is `true` if insertion happened and `false` if it did not. + **Preconditions:** + `cbegin() <= hint && hint <= cend()` -

+ **Effects:** + If a key equivalent to `key` already exists in the container, assigns `std::forward(obj)` to the mapped type corresponding to the key `key`. If the key does not exist, inserts the new element. + Iterator `hint` is used as a suggestion where to start to search insert position. + Iterator `hint` is ignored due to container's underlying storage implementation. These overloads exist just to have this container compatible with standard C++ containers as much as possible. -``` -template -iterator try_emplace(const_iterator hint, const Key& key, Args&&... args); -``` -``` -template -iterator try_emplace(const_iterator hint, Key&& key, Args&&... args); -``` + * **Overload (4):** New element is constructed as -**Preconditions:** -`cbegin() <= hint && hint <= cend()` + ``` + value_type( std::piecewise_construct, + std::forward_as_tuple(key), + std::forward_as_tuple(std::forward(obj)) ) + ``` -**Effects:** -Same as `try_emplace` overloads that do not take `hint`. + **Note:** This overload participates in overload resolution only if `std::is_assignable_v` is `true`. -Iterator `hint` is used as a suggestion where to start to search insert position. + * **Overload (5):** New element is constructed as -**Returns:** -Iterator to the inserted element or to the already existing element. + ``` + value_type( std::piecewise_construct, + std::forward_as_tuple(std::move(key)), + std::forward_as_tuple(std::forward(obj)) ) + ``` -

+ **Note:** This overload participates in overload resolution only if `std::is_assignable_v` is `true`. + * **Overload (6):** New element is constructed as + ``` + value_type( std::piecewise_construct, + std::forward_as_tuple(std::forward(key)), + std::forward_as_tuple(std::forward(obj)) ) + ``` -### erase + **Note:** This overload participates in overload resolution only if all following conditions are satisfied: + 1. `KeyEqual::is_transparent` exists and is a valid type. It allows calling this function without constructing an instance of `Key`. + 2. `std::is_assignable_v` is `true`. -``` -iterator erase(iterator pos); -``` -``` -iterator erase(const_iterator pos); -``` + **Returns:** + Iterator to the element that was inserted or updated. -**Preconditions:** -`cbegin() <= pos && pos < cend()` +

-**Effects:** -Removes the element at `pos`. -**Returns:** -Iterator following the last removed element. -

+### try_emplace +1. ``` + template + std::pair try_emplace(const Key& key, Args&&... args); + ``` +2. ``` + template + std::pair try_emplace(Key&& key, Args&&... args); + ``` +3. ``` + template + std::pair try_emplace(K&& key, Args&&... args); + ``` + **Effects:** + If a key equivalent to `key` already exists in the container, does nothing. + Otherwise, inserts a new element into the container. -``` -iterator erase(const_iterator first, const_iterator last); -``` + * **Overload (1):** Behaves like `emplace` except that the element is constructed as -**Preconditions:** -`cbegin() <= first && first <= last && last <= cend()` + ``` + value_type( std::piecewise_construct, + std::forward_as_tuple(key), + std::forward_as_tuple(std::forward(args)...) ) + ``` -**Effects:** -Removes the elements in the range `[first, last)`. + * **Overload (2):** Behaves like `emplace` except that the element is constructed as -**Returns:** -Iterator following the last removed element. + ``` + value_type( std::piecewise_construct, + std::forward_as_tuple(std::move(key)), + std::forward_as_tuple(std::forward(args)...) ) + ``` -

+ * **Overload (3):** Behaves like `emplace` except that the element is constructed as + ``` + value_type( std::piecewise_construct, + std::forward_as_tuple(std::forward(key)), + std::forward_as_tuple(std::forward(args)...) ) + ``` + **Note:** This overload participates in overload resolution only if all following conditions are satisfied: + 1. `KeyEqual::is_transparent` exists and is a valid type. It allows calling this function without constructing an instance of `Key`. + 2. `std::is_convertible_v` is `false`. + 3. `std::is_convertible_v` is `false`. -``` -size_type erase(const Key& key); -``` + **Returns:** + The iterator component points to the inserted element or to the already existing element. The `bool` component is `true` if insertion happened and `false` if it did not. -**Effects:** -Removes the element (if one exists) with the key equivalent to `key`. +

-**Returns:** -Number of elements removed (0 or 1). -

+4. ``` + template + iterator try_emplace(const_iterator hint, const Key& key, Args&&... args); + ``` +5. ``` + template + iterator try_emplace(const_iterator hint, Key&& key, Args&&... args); + ``` +6. ``` + template + iterator try_emplace(const_iterator hint, K&& key, Args&&... args); + ``` + **Preconditions:** + `cbegin() <= hint && hint <= cend()` -``` -template -size_type erase(K&& x); -``` + **Effects:** + If a key equivalent to `key` already exists in the container, does nothing. + Otherwise, inserts a new element into the container. -**Effects:** -Removes the element (if one exists) with key that compares equivalent to the value `x`. + Iterator `hint` is used as a suggestion where to start to search insert position. -**Note:** -This overload participates in overload resolution only if `KeyEqual::is_transparent` exists and is a valid type. It allows calling this function without constructing an instance of `Key`. + Iterator `hint` is ignored due to container's underlying storage implementation. These overloads exist just to have this container compatible with standard C++ containers as much as possible. -**Returns:** -Number of elements removed (0 or 1). + * **Overload (4):** Behaves like `emplace_hint` except that the element is constructed as -

+ ``` + value_type( std::piecewise_construct, + std::forward_as_tuple(key), + std::forward_as_tuple(std::forward(args)...) ) + ``` + * **Overload (5):** Behaves like `emplace_hint` except that the element is constructed as + ``` + value_type( std::piecewise_construct, + std::forward_as_tuple(std::move(key)), + std::forward_as_tuple(std::forward(args)...) ) + ``` -### swap + * **Overload (6):** Behaves like `emplace_hint` except that the element is constructed as -``` -void swap(small_flat_map& other); -``` + ``` + value_type( std::piecewise_construct, + std::forward_as_tuple(std::forward(key)), + std::forward_as_tuple(std::forward(args)...) ) + ``` -**Preconditions:** -`allocator_traits::propagate_on_container_swap::value || get_allocator() == other.get_allocator()` + **Note:** This overload participates in overload resolution only if `KeyEqual::is_transparent` exists and is a valid type. It allows calling this function without constructing an instance of `Key`. -**Effects:** -Exchanges the contents of the container with those of `other`. + **Returns:** + Iterator to the inserted element or to the already existing element. -**Complexity:** -Constant in the best case. Linear in `this->size()` plus linear in `other.size()` in the worst case. +

-

+### erase -### find +1. ``` + iterator erase(iterator pos); + ``` +2. ``` + iterator erase(const_iterator pos); + ``` -``` -iterator find(const Key& key); -``` -``` -const_iterator find(const Key& key) const; -``` + **Preconditions:** + `cbegin() <= pos && pos < cend()` -**Effects:** -Returns an iterator to an element with key equivalent to `key`, or `end()` if such an element is not found. + **Effects:** + Removes the element at `pos`. -**Complexity:** -Constant in the best case. Linear in `size()` in the worst case. + **Returns:** + Iterator following the last removed element. -

+

-``` -template -iterator find(const K& x); -``` -``` -template -const_iterator find(const K& x) const; -``` +3. ``` + iterator erase(const_iterator first, const_iterator last); + ``` -**Effects:** -Returns an iterator to an element with key that compares equivalent to `x`, or `end()` if such an element is not found. + **Preconditions:** + `cbegin() <= first && first <= last && last <= cend()` -**Note:** -This overload participates in overload resolution only if `KeyEqual::is_transparent` exists and is a valid type. It allows calling this function without constructing an instance of `Key`. + **Effects:** + Removes the elements in the range `[first, last)`. -**Complexity:** -Constant in the best case. Linear in `size()` in the worst case. + **Returns:** + Iterator following the last removed element. -

+

-### count +4. ``` + size_type erase(const Key& key); + ``` +5. ``` + template + size_type erase(K&& x); + ``` -``` -size_type count(const Key& key) const; -``` + **Effects:** + Removes the element (if one exists) with the key equivalent to `key` or `x`. -**Effects:** -Returns the number of elements with key equivalent to `key`, which is either 1 or 0 since this container does not allow duplicates. + **Note:** + Overload (5) participates in overload resolution only if `KeyEqual::is_transparent` exists and is a valid type. It allows calling this function without constructing an instance of `Key`. -**Complexity:** -Constant in the best case. Linear in `size()` in the worst case. + **Returns:** + Number of elements removed (0 or 1). -

+

-``` -template -size_type count(const K& x) const; -``` +### swap -**Effects:** -Returns the number of elements with key that compares equivalent to `x`, which is either 1 or 0 since this container does not allow duplicates. +1. ``` + void swap(small_flat_map& other); + ``` -**Note:** -This overload participates in overload resolution only if `KeyEqual::is_transparent` exists and is a valid type. It allows calling this function without constructing an instance of `Key`. + **Preconditions:** + `allocator_traits::propagate_on_container_swap::value || get_allocator() == other.get_allocator()` -**Complexity:** -Constant in the best case. Linear in `size()` in the worst case. + **Effects:** + Exchanges the contents of the container with those of `other`. -

+ **Complexity:** + Constant in the best case. Linear in `this->size()` plus linear in `other.size()` in the worst case. +

-### contains -``` -bool contains(const Key& key) const; -``` +### find -**Effects:** -Returns `true` if the container contains an element with key equivalent to `key`, otherwise returns `false`. +1. ``` + iterator find(const Key& key); + ``` +2. ``` + const_iterator find(const Key& key) const; + ``` +3. ``` + template + iterator find(const K& x); + ``` +4. ``` + template + const_iterator find(const K& x) const; + ``` -**Complexity:** -Constant in the best case. Linear in `size()` in the worst case. + **Effects:** + Returns an iterator pointing to the element with key equivalent to `key` or `x`. Returns `end()` if no such element is found. -

+ **Note:** + Overloads (3) and (4) participate in overload resolution only if `KeyEqual::is_transparent` exists and is a valid type. It allows calling these functions without constructing an instance of `Key`. + **Complexity:** + Constant in the best case. Linear in `size()` in the worst case. +

-``` -template -bool contains(const K& x) const; -``` -**Effects:** -Returns `true` if the container contains an element with the key that compares equivalent to `x`, otherwise returns `false`. -**Note:** -This overload participates in overload resolution only if `KeyEqual::is_transparent` exists and is a valid type. It allows calling this function without constructing an instance of `Key`. +### count + +1. ``` + size_type count(const Key& key) const; + ``` +2. ``` + template + size_type count(const K& x) const; + ``` + + **Effects:** + Returns the number of elements with key equivalent to `key` or `x`, which is either 1 or 0 since this container does not allow duplicates. -**Complexity:** -Constant in the best case. Linear in `size()` in the worst case. + **Note:** + Overload (2) participates in overload resolution only if `KeyEqual::is_transparent` exists and is a valid type. It allows calling this function without constructing an instance of `Key`. + + **Complexity:** + Constant in the best case. Linear in `size()` in the worst case. + +

-

+ + +### contains + +1. ``` + bool contains(const Key& key) const; + ``` +2. ``` + template + bool contains(const K& x) const; + ``` + + **Effects:** + Returns `true` if the container contains an element with key equivalent to `key` or `x`, otherwise returns `false`. + + **Note:** + Overload (2) participates in overload resolution only if `KeyEqual::is_transparent` exists and is a valid type. It allows calling this function without constructing an instance of `Key`. + + **Complexity:** + Constant in the best case. Linear in `size()` in the worst case. + +

### at -``` -T& at(const Key& key); -``` -``` -const T& at(const Key& key) const; -``` +1. ``` + T& at(const Key& key); + ``` +2. ``` + const T& at(const Key& key) const; + ``` +3. ``` + template + const T& at(const K& x) const; + ``` -**Effects:** -Returns a reference to the mapped value of the element with key equivalent to `key`. If no such element exists, an exception of type `std::out_of_range` is thrown. + **Effects:** + Returns a reference to the mapped value of the element with key equivalent to `key` or `x`. If no such element exists, an exception of type `std::out_of_range` is thrown. -**Complexity:** -Linear in `size()`. + **Note:** + Overload (3) participates in overload resolution only if `KeyEqual::is_transparent` exists and is a valid type. It allows calling this function without constructing an instance of `Key`. -**Exceptions:** -`std::out_of_range` if the container does not have an element with the specified key. + **Complexity:** + Linear in `size()`. -

+ **Exceptions:** + `std::out_of_range` if the container does not have an element with the specified key. + +

### operator[] -``` -T& operator[](const Key& key); -``` -``` -T& operator[](Key&& key); -``` +1. ``` + T& operator[](const Key& key); + ``` +2. ``` + T& operator[](Key&& key); + ``` +3. ``` + template + T& operator[](const K& x); + ``` +4. ``` + template + T& operator[](K&& x); + ``` -**Effects:** -Returns a reference to the value that is mapped to a key equivalent to `key`, performing an insertion if such key does not already exist. + **Effects:** + Returns a reference to the value that is mapped to a key equivalent to `key` or `x`, performing an insertion if such key does not already exist. -* The first overload is equivalent to: - ``` - return try_emplace(key).first->second; - ``` -* The second overload is equivalent to: - ``` - return try_emplace(std::move(key)).first->second; - ``` + * Overload (1) is equivalent to + `return try_emplace(key).first->second;` -**Complexity:** -Linear in `size()`. + * Overload (2) is equivalent to + `return try_emplace(std::move(key)).first->second;` -

+ * Overload (3) is equivalent to + `return try_emplace(x).first->second;` + + * Overload (4) is equivalent to + `return try_emplace(std::forward(x)).first->second;` + + **Note:** + Overloads (3) and (4) participate in overload resolution only if `KeyEqual::is_transparent` exists and is a valid type. It allows calling these functions without constructing an instance of `Key`. + + **Complexity:** + Linear in `size()`. + +

### data -``` -value_type* data() noexcept; -``` -``` -const value_type* data() const noexcept; -``` +1. ``` + value_type* data() noexcept; + ``` +2. ``` + const value_type* data() const noexcept; + ``` -**Effects:** -Returns pointer to the underlying array serving as element storage. The pointer is such that range `[data(), data() + size())` is always a valid range, even if the container is empty. `data()` is not dereferenceable if the container is empty. + **Effects:** + Returns pointer to the underlying array serving as element storage. The pointer is such that range `[data(), data() + size())` is always a valid range, even if the container is empty. `data()` is not dereferenceable if the container is empty. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

@@ -1284,93 +1369,93 @@ Constant. ### operator== -``` -template -bool operator== -( - const small_unordered_flat_map& x, - const small_unordered_flat_map& y -); -``` +1. ``` + template + bool operator== + ( + const small_unordered_flat_map& x, + const small_unordered_flat_map& y + ); + ``` -**Effects:** -Checks if the contents of `x` and `y` are equal. + **Effects:** + Checks if the contents of `x` and `y` are equal. -The contents of `x` and `y` are equal if the following conditions hold: -* `x.size() == y.size()` -* For each element in `x` there is equal element in `y`. + The contents of `x` and `y` are equal if the following conditions hold: + * `x.size() == y.size()` + * For each element in `x` there is equal element in `y`. -The comparison is performed by `std::is_permutation`. -This comparison ignores the container's `KeyEqual` function. + The comparison is performed by `std::is_permutation`. + This comparison ignores the container's `KeyEqual` function. -**Returns:** -`true` if the contents of the `x` and `y` are equal, `false` otherwise. + **Returns:** + `true` if the contents of the `x` and `y` are equal, `false` otherwise. -

+

### operator!= -``` -template -bool operator!= -( - const small_unordered_flat_map& x, - const small_unordered_flat_map& y -); -``` +1. ``` + template + bool operator!= + ( + const small_unordered_flat_map& x, + const small_unordered_flat_map& y + ); + ``` -**Effects:** -Checks if the contents of `x` and `y` are equal. + **Effects:** + Checks if the contents of `x` and `y` are equal. -For details see `operator==`. + For details see `operator==`. -**Returns:** -`true` if the contents of the `x` and `y` are not equal, `false` otherwise. + **Returns:** + `true` if the contents of the `x` and `y` are not equal, `false` otherwise. -

+

### swap -``` -template -void swap -( - small_unordered_flat_map& x, - small_unordered_flat_map& y -); -``` +1. ``` + template + void swap + ( + small_unordered_flat_map& x, + small_unordered_flat_map& y + ); + ``` -**Effects:** -Swaps the contents of `x` and `y`. Calls `x.swap(y)`. + **Effects:** + Swaps the contents of `x` and `y`. Calls `x.swap(y)`. -

+

### erase_if -``` -template -typename small_unordered_flat_map::size_type - erase_if(small_unordered_flat_map& c, Predicate pred); -``` +1. ``` + template + typename small_unordered_flat_map::size_type + erase_if(small_unordered_flat_map& c, Predicate pred); + ``` -**Effects:** -Erases all elements that satisfy the predicate `pred` from the container. + **Effects:** + Erases all elements that satisfy the predicate `pred` from the container. -`pred` is unary predicate which returns `true` if the element should be removed. + `pred` is unary predicate which returns `true` if the element should be removed. -**Returns:** -The number of erased elements. + **Returns:** + The number of erased elements. -**Complexity:** -Linear. + **Complexity:** + Linear. -

+

diff --git a/doc/small_unordered_flat_multimap.md b/doc/small_unordered_flat_multimap.md index 56a6589..a487df6 100644 --- a/doc/small_unordered_flat_multimap.md +++ b/doc/small_unordered_flat_multimap.md @@ -97,7 +97,8 @@ Iterators to elements of `sfl::small_unordered_flat_multimap` are random access std::size_t N ``` - Size of the internal statically allocated array. + Size of the internal statically allocated array, i.e. the maximal number of elements that can fit into this array. + This parameter can be zero. 4. ``` @@ -171,928 +172,887 @@ static constexpr size_type static_capacity = N; ### (constructor) -``` -small_unordered_flat_multimap() - noexcept( +1. ``` + small_unordered_flat_multimap() noexcept( std::is_nothrow_default_constructible::value && std::is_nothrow_default_constructible::value ); -``` -``` -explicit small_unordered_flat_multimap(const KeyEqual& equal) - noexcept( + ``` +2. ``` + explicit small_unordered_flat_multimap(const KeyEqual& equal) noexcept( std::is_nothrow_default_constructible::value && std::is_nothrow_copy_constructible::value ); -``` -``` -explicit small_unordered_flat_multimap(const Allocator& alloc) - noexcept( + ``` +3. ``` + explicit small_unordered_flat_multimap(const Allocator& alloc) noexcept( std::is_nothrow_copy_constructible::value && std::is_nothrow_default_constructible::value ); -``` -``` -explicit small_unordered_flat_multimap(const KeyEqual& equal, const Allocator& alloc) - noexcept( + ``` +4. ``` + explicit small_unordered_flat_multimap(const KeyEqual& equal, const Allocator& alloc) noexcept( std::is_nothrow_copy_constructible::value && std::is_nothrow_copy_constructible::value ); -``` + ``` -**Effects:** -Constructs an empty container. + **Effects:** + Constructs an empty container. -

+

-``` -template -small_unordered_flat_multimap(InputIt first, InputIt last); -``` -``` -template -small_unordered_flat_multimap(InputIt first, InputIt last, const KeyEqual& equal); -``` -``` -template -small_unordered_flat_multimap(InputIt first, InputIt last, const Allocator& alloc); -``` -``` -template -small_unordered_flat_multimap(InputIt first, InputIt last, const KeyEqual& equal, const Allocator& alloc); -``` +5. ``` + template + small_unordered_flat_multimap(InputIt first, InputIt last); + ``` +6. ``` + template + small_unordered_flat_multimap(InputIt first, InputIt last, const KeyEqual& equal); + ``` +7. ``` + template + small_unordered_flat_multimap(InputIt first, InputIt last, const Allocator& alloc); + ``` +8. ``` + template + small_unordered_flat_multimap(InputIt first, InputIt last, const KeyEqual& equal, const Allocator& alloc); + ``` -**Effects:** -Constructs an empty container and inserts elements from the range `[first, last)`. + **Effects:** + Constructs an empty container and inserts elements from the range `[first, last)`. -**Note:** -This overload participates in overload resolution only if `InputIt` satisfies requirements of [*LegacyInputIterator*](https://en.cppreference.com/w/cpp/named_req/InputIterator). + **Note:** + This overload participates in overload resolution only if `InputIt` satisfies requirements of [*LegacyInputIterator*](https://en.cppreference.com/w/cpp/named_req/InputIterator). -

+

-``` -small_unordered_flat_multimap(std::initializer_list ilist); -``` -``` -small_unordered_flat_multimap(std::initializer_list ilist, const KeyEqual& equal); -``` -``` -small_unordered_flat_multimap(std::initializer_list ilist, const Allocator& alloc); -``` -``` -small_unordered_flat_multimap(std::initializer_list ilist, const KeyEqual& equal, const Allocator& alloc); -``` +9. ``` + small_unordered_flat_multimap(std::initializer_list ilist); + ``` +10. ``` + small_unordered_flat_multimap(std::initializer_list ilist, const KeyEqual& equal); + ``` +11. ``` + small_unordered_flat_multimap(std::initializer_list ilist, const Allocator& alloc); + ``` +12. ``` + small_unordered_flat_multimap(std::initializer_list ilist, const KeyEqual& equal, const Allocator& alloc); + ``` -**Effects:** -Constructs an empty container and inserts elements from the initializer list `ilist`. + **Effects:** + Constructs an empty container and inserts elements from the initializer list `ilist`. -

+

-``` -small_unordered_flat_multimap(const small_unordered_flat_multimap& other); -``` -``` -small_unordered_flat_multimap(const small_unordered_flat_multimap& other, const Allocator& alloc); -``` +13. ``` + small_unordered_flat_multimap(const small_unordered_flat_multimap& other); + ``` +14. ``` + small_unordered_flat_multimap(const small_unordered_flat_multimap& other, const Allocator& alloc); + ``` -**Effects:** -Copy constructor. -Constructs the container with the copy of the contents of `other`. + **Effects:** + Copy constructor. + Constructs the container with the copy of the contents of `other`. -**Complexity:** -Linear in `other.size()`. + **Complexity:** + Linear in `other.size()`. -

+

-``` -small_unordered_flat_multimap(small_unordered_flat_multimap&& other); -``` -``` -small_unordered_flat_multimap(small_unordered_flat_multimap&& other, const Allocator& alloc); -``` +15. ``` + small_unordered_flat_multimap(small_unordered_flat_multimap&& other); + ``` +16. ``` + small_unordered_flat_multimap(small_unordered_flat_multimap&& other, const Allocator& alloc); + ``` -**Effects:** -Move constructor. -Constructs the container with the contents of `other` using move semantics. + **Effects:** + Move constructor. + Constructs the container with the contents of `other` using move semantics. -`other` is not guaranteed to be empty after the move. + `other` is not guaranteed to be empty after the move. -`other` is in a valid but unspecified state after the move. + `other` is in a valid but unspecified state after the move. -**Complexity:** -Constant in the best case. Linear in `N` in the worst case. + **Complexity:** + Constant in the best case. Linear in `N` in the worst case. -

+

### (destructor) -``` -~small_unordered_flat_multimap(); -``` +1. ``` + ~small_unordered_flat_multimap(); + ``` -**Effects:** -Destructs the container. The destructors of the elements are called and the used storage is deallocated. + **Effects:** + Destructs the container. The destructors of the elements are called and the used storage is deallocated. -**Complexity:** -Linear in `size()`. + **Complexity:** + Linear in `size()`. -

+

### operator= -``` -small_unordered_flat_multimap& operator=(const small_unordered_flat_multimap& other); -``` +1. ``` + small_unordered_flat_multimap& operator=(const small_unordered_flat_multimap& other); + ``` -**Effects:** -Copy assignment operator. -Replaces the contents with a copy of the contents of `other`. + **Effects:** + Copy assignment operator. + Replaces the contents with a copy of the contents of `other`. -**Returns:** -`*this()`. + **Returns:** + `*this()`. -**Complexity:** -Linear in `this->size()` plus linear in `other.size()`. + **Complexity:** + Linear in `this->size()` plus linear in `other.size()`. -

+

-``` -small_unordered_flat_multimap& operator=(small_unordered_flat_multimap&& other); -``` +2. ``` + small_unordered_flat_multimap& operator=(small_unordered_flat_multimap&& other); + ``` -**Effects:** -Move assignment operator. -Replaces the contents with those of `other` using move semantics. + **Effects:** + Move assignment operator. + Replaces the contents with those of `other` using move semantics. -`other` is not guaranteed to be empty after the move. + `other` is not guaranteed to be empty after the move. -`other` is in a valid but unspecified state after the move. + `other` is in a valid but unspecified state after the move. -**Returns:** -`*this()`. + **Returns:** + `*this()`. -**Complexity:** + **Complexity:** -* The best case: Linear in `this->size()` plus constant. -* The worst case: Linear in `this->size()` plus linear in `other.size()`. + * The best case: Linear in `this->size()` plus constant. + * The worst case: Linear in `this->size()` plus linear in `other.size()`. -

+

-``` -small_unordered_flat_multimap& operator=(std::initializer_list ilist); -``` +3. ``` + small_unordered_flat_multimap& operator=(std::initializer_list ilist); + ``` -**Effects:** -Replaces the contents with those identified by initializer list `ilist`. + **Effects:** + Replaces the contents with those identified by initializer list `ilist`. -**Returns:** -`*this()`. + **Returns:** + `*this()`. -**Complexity:** -Linear in `this->size()` plus linear in `ilist.size()`. + **Complexity:** + Linear in `this->size()` plus linear in `ilist.size()`. -

+

### get_allocator -``` -allocator_type get_allocator() const noexcept; -``` +1. ``` + allocator_type get_allocator() const noexcept; + ``` -**Effects:** -Returns the allocator associated with the container. + **Effects:** + Returns the allocator associated with the container. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

### key_eq -``` -key_equal key_eq() const; -``` +1. ``` + key_equal key_eq() const; + ``` -**Effects:** -Returns the function object that compares keys for equality, which is a copy of this container's constructor argument `equal`. + **Effects:** + Returns the function object that compares keys for equality, which is a copy of this container's constructor argument `equal`. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

### value_eq -``` -value_equal value_eq() const; -``` +1. ``` + value_equal value_eq() const; + ``` -**Effects:** -Returns a function object that compares objects of type `value_type`. + **Effects:** + Returns a function object that compares objects of type `value_type`. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

### begin, cbegin -``` -iterator begin() noexcept; -``` -``` -const_iterator begin() const noexcept; -``` -``` -const_iterator cbegin() const noexcept; -``` - -**Effects:** -Returns an iterator to the first element of the container. +1. ``` + iterator begin() noexcept; + ``` +2. ``` + const_iterator begin() const noexcept; + ``` +3. ``` + const_iterator cbegin() const noexcept; + ``` -If the container is empty, the returned iterator will be equal to `end()`. + **Effects:** + Returns an iterator to the first element of the container. + If the container is empty, the returned iterator will be equal to `end()`. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

### end, cend -``` -iterator end() noexcept; -``` -``` -const_iterator end() const noexcept; -``` -``` -const_iterator cend() const noexcept; -``` - -**Effects:** -Returns an iterator to the element following the last element of the container. +1. ``` + iterator end() noexcept; + ``` +2. ``` + const_iterator end() const noexcept; + ``` +3. ``` + const_iterator cend() const noexcept; + ``` -This element acts as a placeholder; attempting to access it results in undefined behavior. + **Effects:** + Returns an iterator to the element following the last element of the container. + This element acts as a placeholder; attempting to access it results in undefined behavior. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

### nth -``` -iterator nth(size_type pos) noexcept; -``` -``` -const_iterator nth(size_type pos) const noexcept; -``` +1. ``` + iterator nth(size_type pos) noexcept; + ``` +2. ``` + const_iterator nth(size_type pos) const noexcept; + ``` -**Preconditions:** -`pos <= size()` + **Preconditions:** + `pos <= size()` -**Effects:** -Returns an iterator to the element at position `pos`. -If `pos == size()`, the returned iterator is equal to `end()`. + **Effects:** + Returns an iterator to the element at position `pos`. -**Complexity:** -Constant. + If `pos == size()`, the returned iterator is equal to `end()`. -

+ **Complexity:** + Constant. + +

### index_of -``` -size_type index_of(const_iterator pos) const noexcept; -``` +1. ``` + size_type index_of(const_iterator pos) const noexcept; + ``` -**Preconditions:** -`cbegin() <= pos && pos <= cend()` + **Preconditions:** + `cbegin() <= pos && pos <= cend()` -**Effects:** -Returns position of the element pointed by iterator `pos`, i.e. `std::distance(begin(), pos)`. + **Effects:** + Returns position of the element pointed by iterator `pos`, i.e. `std::distance(begin(), pos)`. -If `pos == end()`, the returned value is equal to `size()`. + If `pos == end()`, the returned value is equal to `size()`. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

### empty -``` -bool empty() const noexcept; -``` +1. ``` + bool empty() const noexcept; + ``` -**Effects:** -Returns `true` if the container has no elements, i.e. whether `begin() == end()`. + **Effects:** + Returns `true` if the container has no elements, i.e. whether `begin() == end()`. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

### size -``` -size_type size() const noexcept; -``` +1. ``` + size_type size() const noexcept; + ``` -**Effects:** -Returns the number of elements in the container, i.e. `std::distance(begin(), end())`. + **Effects:** + Returns the number of elements in the container, i.e. `std::distance(begin(), end())`. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

### max_size -``` -size_type max_size() const noexcept; -``` +1. ``` + size_type max_size() const noexcept; + ``` -**Effects:** -Returns the maximum number of elements the container is able to hold, i.e. `std::distance(begin(), end())` for the largest container. + **Effects:** + Returns the maximum number of elements the container is able to hold, i.e. `std::distance(begin(), end())` for the largest container. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

### capacity -``` -size_type capacity() const noexcept; -``` +1. ``` + size_type capacity() const noexcept; + ``` -**Effects:** -Returns the number of elements that the container has currently allocated space for. + **Effects:** + Returns the number of elements that the container has currently allocated space for. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

### available -``` -size_type available() const noexcept; -``` +1. ``` + size_type available() const noexcept; + ``` -**Effects:** -Returns the number of elements that can be inserted into the container without requiring allocation of additional memory. + **Effects:** + Returns the number of elements that can be inserted into the container without requiring allocation of additional memory. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

### reserve -``` -void reserve(size_type new_cap); -``` +1. ``` + void reserve(size_type new_cap); + ``` -**Effects:** -Tries to increase capacity by allocating additional memory. + **Effects:** + Tries to increase capacity by allocating additional memory. -If `new_cap > capacity()`, the function allocates memory for new storage of capacity equal to the value of `new_cap`, moves elements from old storage to new storage, and deallocates memory used by old storage. Otherwise, the function does nothing. + If `new_cap > capacity()`, the function allocates memory for new storage of capacity equal to the value of `new_cap`, moves elements from old storage to new storage, and deallocates memory used by old storage. Otherwise, the function does nothing. -This function does not change size of the container. + This function does not change size of the container. -If the capacity is changed, all iterators and all references to the elements are invalidated. Otherwise, no iterators or references are invalidated. + If the capacity is changed, all iterators and all references to the elements are invalidated. Otherwise, no iterators or references are invalidated. -**Complexity:** -Linear. + **Complexity:** + Linear. -**Exceptions:** + **Exceptions:** -* `Allocator::allocate` may throw. -* `T`'s move or copy constructor may throw. + * `Allocator::allocate` may throw. + * `T`'s move or copy constructor may throw. -If an exception is thrown: + If an exception is thrown: -* If type `T` has available `noexcept` move constructor: - * This function has no effects (strong exception guarantee). -* Else if type `T` has available copy constructor: - * This function has no effects (strong exception guarantee). -* Else if type `T` has available throwing move constructor: - * Container is changed but in valid state (basic exception guarantee). + * If type `T` has available `noexcept` move constructor: + * This function has no effects (strong exception guarantee). + * Else if type `T` has available copy constructor: + * This function has no effects (strong exception guarantee). + * Else if type `T` has available throwing move constructor: + * Container is changed but in valid state (basic exception guarantee). -

+

### shrink_to_fit -``` -void shrink_to_fit(); -``` +1. ``` + void shrink_to_fit(); + ``` -**Effects:** -Tries to reduce memory usage by freeing unused memory. + **Effects:** + Tries to reduce memory usage by freeing unused memory. -1. If `size() > N && size() < capacity()`, the function allocates memory for new storage of capacity equal to the value of `size()`, moves elements from old storage to new storage, and deallocates memory used by old storage. -2. If `size() <= N && N < capacity()`, the function sets new storage to be internal statically allocated array of capacity `N`, moves elements from old storage to new storage, and deallocates memory used by old storage. -3. Otherwise the function does nothing. + 1. If `size() > N && size() < capacity()`, the function allocates memory for new storage of capacity equal to the value of `size()`, moves elements from old storage to new storage, and deallocates memory used by old storage. -This function does not change size of the container. + 2. If `size() <= N && N < capacity()`, the function sets new storage to be internal statically allocated array of capacity `N`, moves elements from old storage to new storage, and deallocates memory used by old storage. -If the capacity is changed, all iterators and all references to the elements are invalidated. Otherwise, no iterators or references are invalidated. + 3. Otherwise the function does nothing. -**Complexity:** -Linear. + This function does not change size of the container. -**Exceptions:** + If the capacity is changed, all iterators and all references to the elements are invalidated. Otherwise, no iterators or references are invalidated. -* `Allocator::allocate` may throw. -* `T`'s move or copy constructor may throw. + **Complexity:** + Linear. -If an exception is thrown: + **Exceptions:** -* If type `T` has available `noexcept` move constructor: - * This function has no effects (strong exception guarantee). -* Else if type `T` has available copy constructor: - * This function has no effects (strong exception guarantee). -* Else if type `T` has available throwing move constructor: - * Container is changed but in valid state (basic exception guarantee). + * `Allocator::allocate` may throw. + * `T`'s move or copy constructor may throw. -

+ If an exception is thrown: + + * If type `T` has available `noexcept` move constructor: + * This function has no effects (strong exception guarantee). + * Else if type `T` has available copy constructor: + * This function has no effects (strong exception guarantee). + * Else if type `T` has available throwing move constructor: + * Container is changed but in valid state (basic exception guarantee). + +

### clear -``` -void clear() noexcept; -``` +1. ``` + void clear() noexcept; + ``` -**Effects:** -Erases all elements from the container. -After this call, `size()` returns zero and `capacity()` remains unchanged. + **Effects:** + Erases all elements from the container. + After this call, `size()` returns zero and `capacity()` remains unchanged. -**Complexity:** -Linear in `size()`. + **Complexity:** + Linear in `size()`. -

+

### emplace -``` -template -iterator emplace(Args&&... args); -``` +1. ``` + template + iterator emplace(Args&&... args); + ``` -**Effects:** -Inserts a new element into the container. + **Effects:** + Inserts a new element into the container. -New element is constructed as `value_type(std::forward(args)...)`. + New element is constructed as `value_type(std::forward(args)...)`. -**Returns:** -Iterator to the inserted element. + **Returns:** + Iterator to the inserted element. -

+

### emplace_hint -``` -template -iterator emplace_hint(const_iterator hint, Args&&... args); -``` +1. ``` + template + iterator emplace_hint(const_iterator hint, Args&&... args); + ``` -**Preconditions:** -`cbegin() <= hint && hint <= cend()` + **Preconditions:** + `cbegin() <= hint && hint <= cend()` -**Effects:** -Inserts a new element into the container. + **Effects:** + Inserts a new element into the container. -New element is constructed as `value_type(std::forward(args)...)`. + New element is constructed as `value_type(std::forward(args)...)`. -Iterator `hint` is used as a suggestion where to start to search insert position. + Iterator `hint` is used as a suggestion where to start to search insert position. -**Returns:** -Iterator to the inserted element. + Iterator `hint` is ignored due to container's underlying storage implementation. This overload exists just to have this container compatible with standard C++ containers as much as possible. -

+ **Returns:** + Iterator to the inserted element. + +

### insert -``` -iterator insert(const value_type& value); -``` +1. ``` + iterator insert(const value_type& value); + ``` -**Effects:** -Inserts copy of `value`. + **Effects:** + Inserts copy of `value`. -**Returns:** -Iterator to the inserted element. + **Returns:** + Iterator to the inserted element. -

+

-``` -iterator insert(value_type&& value); -``` +2. ``` + iterator insert(value_type&& value); + ``` -**Effects:** -Inserts `value` using move semantics. + **Effects:** + Inserts `value` using move semantics. -**Returns:** -Iterator to the inserted element. + **Returns:** + Iterator to the inserted element. -

+

-``` -template -iterator insert(P&& value); -``` +3. ``` + template + iterator insert(P&& value); + ``` -**Effects:** -Inserts a new element into the container. + **Effects:** + Inserts a new element into the container. -New element is constructed as `value_type(std::forward

(value))`. + New element is constructed as `value_type(std::forward

(value))`. -**Note:** -This overload participates in overload resolution only if `std::is_constructible::value` is `true`. + **Note:** + This overload participates in overload resolution only if `std::is_constructible::value` is `true`. -**Returns:** -Iterator to the inserted element. + **Returns:** + Iterator to the inserted element. -

+

-``` -iterator insert(const_iterator hint, const value_type& value); -``` +4. ``` + iterator insert(const_iterator hint, const value_type& value); + ``` -**Preconditions:** -`cbegin() <= hint && hint <= cend()` + **Preconditions:** + `cbegin() <= hint && hint <= cend()` -**Effects:** -Inserts copy of `value`. + **Effects:** + Inserts copy of `value`. -Iterator `hint` is used as a suggestion where to start to search insert position. + Iterator `hint` is used as a suggestion where to start to search insert position. -**Returns:** -Iterator to the inserted element. + Iterator `hint` is ignored due to container's underlying storage implementation. This overload exists just to have this container compatible with standard C++ containers as much as possible. -

+ **Returns:** + Iterator to the inserted element. +

-``` -iterator insert(const_iterator hint, value_type&& value); -``` -**Preconditions:** -`cbegin() <= hint && hint <= cend()` +5. ``` + iterator insert(const_iterator hint, value_type&& value); + ``` -**Effects:** -Inserts `value` using move semantics. + **Preconditions:** + `cbegin() <= hint && hint <= cend()` -Iterator `hint` is used as a suggestion where to start to search insert position. + **Effects:** + Inserts `value` using move semantics. -**Returns:** -Iterator to the inserted element. + Iterator `hint` is used as a suggestion where to start to search insert position. -

+ Iterator `hint` is ignored due to container's underlying storage implementation. This overload exists just to have this container compatible with standard C++ containers as much as possible. + **Returns:** + Iterator to the inserted element. +

-``` -template -iterator insert(const_iterator hint, P&& value); -``` -**Preconditions:** -`cbegin() <= hint && hint <= cend()` -**Effects:** -Inserts a new element into the container. +6. ``` + template + iterator insert(const_iterator hint, P&& value); + ``` -New element is constructed as `value_type(std::forward

(value))`. + **Preconditions:** + `cbegin() <= hint && hint <= cend()` -Iterator `hint` is used as a suggestion where to start to search insert position. + **Effects:** + Inserts a new element into the container. -**Note:** -This overload participates in overload resolution only if `std::is_constructible::value` is `true`. + New element is constructed as `value_type(std::forward

(value))`. -**Returns:** -Iterator to the inserted element. + Iterator `hint` is used as a suggestion where to start to search insert position. -

+ Iterator `hint` is ignored due to container's underlying storage implementation. This overload exists just to have this container compatible with standard C++ containers as much as possible. + **Note:** + This overload participates in overload resolution only if `std::is_constructible::value` is `true`. + **Returns:** + Iterator to the inserted element. -``` -template -void insert(InputIt first, InputIt last); -``` +

-**Effects:** -Inserts elements from range `[first, last)`. -The call to this function is equivalent to: -``` -while (first != last) -{ - insert(*first); - ++first; -} -``` - -**Note:** -This overload participates in overload resolution only if `InputIt` satisfies requirements of [*LegacyInputIterator*](https://en.cppreference.com/w/cpp/named_req/InputIterator). - -

+7. ``` + template + void insert(InputIt first, InputIt last); + ``` + **Effects:** + Inserts elements from range `[first, last)`. -``` -void insert(std::initializer_list ilist); -``` - -**Effects:** -Inserts elements from initializer list `ilist`. + The call to this function is equivalent to: + ``` + while (first != last) + { + insert(*first); + ++first; + } + ``` -The call to this function is equivalent to: -``` -insert(ilist.begin(), ilist.end()); -``` + **Note:** + This overload participates in overload resolution only if `InputIt` satisfies requirements of [*LegacyInputIterator*](https://en.cppreference.com/w/cpp/named_req/InputIterator). -

+

-### erase +8. ``` + void insert(std::initializer_list ilist); + ``` -``` -iterator erase(iterator pos); -``` -``` -iterator erase(const_iterator pos); -``` + **Effects:** + Inserts elements from initializer list `ilist`. -**Preconditions:** -`cbegin() <= pos && pos < cend()` + The call to this function is equivalent to `insert(ilist.begin(), ilist.end())`. -**Effects:** -Removes the element at `pos`. +

-**Returns:** -Iterator following the last removed element. -

+### erase +1. ``` + iterator erase(iterator pos); + ``` +2. ``` + iterator erase(const_iterator pos); + ``` -``` -iterator erase(const_iterator first, const_iterator last); -``` + **Preconditions:** + `cbegin() <= pos && pos < cend()` -**Preconditions:** -`cbegin() <= first && first <= last && last <= cend()` + **Effects:** + Removes the element at `pos`. -**Effects:** -Removes the elements in the range `[first, last)`. + **Returns:** + Iterator following the last removed element. -**Returns:** -Iterator following the last removed element. +

-

+3. ``` + iterator erase(const_iterator first, const_iterator last); + ``` -``` -size_type erase(const Key& key); -``` + **Preconditions:** + `cbegin() <= first && first <= last && last <= cend()` -**Effects:** -Removes all elements with the key equivalent to `key`. + **Effects:** + Removes the elements in the range `[first, last)`. -**Returns:** -Number of elements removed. + **Returns:** + Iterator following the last removed element. -

+

-``` -template -size_type erase(K&& x); -``` +4. ``` + size_type erase(const Key& key); + ``` +5. ``` + template + size_type erase(K&& x); + ``` -**Effects:** -Removes all elements with key that compares equivalent to the value `x`. + **Effects:** + Removes all elements with the key equivalent to `key` or `x`. -**Note:** -This overload participates in overload resolution only if `KeyEqual::is_transparent` exists and is a valid type. It allows calling this function without constructing an instance of `Key`. + **Note:** + Overload (5) participates in overload resolution only if `KeyEqual::is_transparent` exists and is a valid type. It allows calling this function without constructing an instance of `Key`. -**Returns:** -Number of elements removed. + **Returns:** + Number of elements removed. -

+

### swap -``` -void swap(small_unordered_flat_multimap& other); -``` +1. ``` + void swap(small_unordered_flat_multimap& other); + ``` -**Preconditions:** -`allocator_traits::propagate_on_container_swap::value || get_allocator() == other.get_allocator()` + **Preconditions:** + `allocator_traits::propagate_on_container_swap::value || get_allocator() == other.get_allocator()` -**Effects:** -Exchanges the contents of the container with those of `other`. + **Effects:** + Exchanges the contents of the container with those of `other`. -**Complexity:** -Constant in the best case. Linear in `this->size()` plus linear in `other.size()` in the worst case. + **Complexity:** + Constant in the best case. Linear in `this->size()` plus linear in `other.size()` in the worst case. -

+

### find -``` -iterator find(const Key& key); -``` -``` -const_iterator find(const Key& key) const; -``` - -**Effects:** -Returns an iterator to an element with key equivalent to `key`, or `end()` if such an element is not found. If there are several elements with key in the container, any of them may be returned. - -**Complexity:** -Constant in the best case. Linear in `size()` in the worst case. - -

- - - -``` -template -iterator find(const K& x); -``` -``` -template -const_iterator find(const K& x) const; -``` +1. ``` + iterator find(const Key& key); + ``` +2. ``` + const_iterator find(const Key& key) const; + ``` +3. ``` + template + iterator find(const K& x); + ``` +4. ``` + template + const_iterator find(const K& x) const; + ``` -**Effects:** -Returns an iterator to an element with key that compares equivalent to `x`, or `end()` if such an element is not found. If there are several elements with key in the container, any of them may be returned. + **Effects:** + Returns an iterator pointing to the element with key equivalent to `key` or `x`. Returns `end()` if no such element is found. + If there are several elements with key in the container, any of them may be returned. -**Note:** -This overload participates in overload resolution only if `KeyEqual::is_transparent` exists and is a valid type. It allows calling this function without constructing an instance of `Key`. + **Note:** + Overloads (3) and (4) participate in overload resolution only if `KeyEqual::is_transparent` exists and is a valid type. It allows calling these functions without constructing an instance of `Key`. -**Complexity:** -Constant in the best case. Linear in `size()` in the worst case. + **Complexity:** + Constant in the best case. Linear in `size()` in the worst case. -

+

### count -``` -size_type count(const Key& key) const; -``` - -**Effects:** -Returns the number of elements with key equivalent to `key`. - -**Complexity:** -Linear in `size()`. - -

- - - -``` -template -size_type count(const K& x) const; -``` +1. ``` + size_type count(const Key& key) const; + ``` +2. ``` + template + size_type count(const K& x) const; + ``` -**Effects:** -Returns the number of elements with key that compares equivalent to the value `x`. + **Effects:** + Returns the number of elements with key equivalent to `key` or `x`. -**Note:** -This overload participates in overload resolution only if `KeyEqual::is_transparent` exists and is a valid type. It allows calling this function without constructing an instance of `Key`. + **Note:** + Overload (2) participates in overload resolution only if `KeyEqual::is_transparent` exists and is a valid type. It allows calling this function without constructing an instance of `Key`. -**Complexity:** -Linear in `size()`. + **Complexity:** + Linear in `size()`. -

+

### contains -``` -bool contains(const Key& key) const; -``` - -**Effects:** -Returns `true` if the container contains an element with key equivalent to `key`, otherwise returns `false`. - -**Complexity:** -Constant in the best case. Linear in `size()` in the worst case. - -

- - - -``` -template -bool contains(const K& x) const; -``` +1. ``` + bool contains(const Key& key) const; + ``` +2. ``` + template + bool contains(const K& x) const; + ``` -**Effects:** -Returns `true` if the container contains an element with the key that compares equivalent to `x`, otherwise returns `false`. + **Effects:** + Returns `true` if the container contains an element with key equivalent to `key` or `x`, otherwise returns `false`. -**Note:** -This overload participates in overload resolution only if `KeyEqual::is_transparent` exists and is a valid type. It allows calling this function without constructing an instance of `Key`. + **Note:** + Overload (2) participates in overload resolution only if `KeyEqual::is_transparent` exists and is a valid type. It allows calling this function without constructing an instance of `Key`. -**Complexity:** -Constant in the best case. Linear in `size()` in the worst case. + **Complexity:** + Constant in the best case. Linear in `size()` in the worst case. -

+

### data -``` -value_type* data() noexcept; -``` -``` -const value_type* data() const noexcept; -``` +1. ``` + value_type* data() noexcept; + ``` +2. ``` + const value_type* data() const noexcept; + ``` -**Effects:** -Returns pointer to the underlying array serving as element storage. The pointer is such that range `[data(), data() + size())` is always a valid range, even if the container is empty. `data()` is not dereferenceable if the container is empty. + **Effects:** + Returns pointer to the underlying array serving as element storage. The pointer is such that range `[data(), data() + size())` is always a valid range, even if the container is empty. `data()` is not dereferenceable if the container is empty. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

@@ -1100,93 +1060,93 @@ Constant. ### operator== -``` -template -bool operator== -( - const small_unordered_flat_multimap& x, - const small_unordered_flat_multimap& y -); -``` +1. ``` + template + bool operator== + ( + const small_unordered_flat_multimap& x, + const small_unordered_flat_multimap& y + ); + ``` -**Effects:** -Checks if the contents of `x` and `y` are equal. + **Effects:** + Checks if the contents of `x` and `y` are equal. -The contents of `x` and `y` are equal if the following conditions hold: -* `x.size() == y.size()` -* For each element in `x` there is equal element in `y`. + The contents of `x` and `y` are equal if the following conditions hold: + * `x.size() == y.size()` + * For each element in `x` there is equal element in `y`. -The comparison is performed by `std::is_permutation`. -This comparison ignores the container's `KeyEqual` function. + The comparison is performed by `std::is_permutation`. + This comparison ignores the container's `KeyEqual` function. -**Returns:** -`true` if the contents of the `x` and `y` are equal, `false` otherwise. + **Returns:** + `true` if the contents of the `x` and `y` are equal, `false` otherwise. -

+

### operator!= -``` -template -bool operator!= -( - const small_unordered_flat_multimap& x, - const small_unordered_flat_multimap& y -); -``` +1. ``` + template + bool operator!= + ( + const small_unordered_flat_multimap& x, + const small_unordered_flat_multimap& y + ); + ``` -**Effects:** -Checks if the contents of `x` and `y` are equal. + **Effects:** + Checks if the contents of `x` and `y` are equal. -For details see `operator==`. + For details see `operator==`. -**Returns:** -`true` if the contents of the `x` and `y` are not equal, `false` otherwise. + **Returns:** + `true` if the contents of the `x` and `y` are not equal, `false` otherwise. -

+

### swap -``` -template -void swap -( - small_unordered_flat_multimap& x, - small_unordered_flat_multimap& y -); -``` +1. ``` + template + void swap + ( + small_unordered_flat_multimap& x, + small_unordered_flat_multimap& y + ); + ``` -**Effects:** -Swaps the contents of `x` and `y`. Calls `x.swap(y)`. + **Effects:** + Swaps the contents of `x` and `y`. Calls `x.swap(y)`. -

+

### erase_if -``` -template -typename small_unordered_flat_multimap::size_type - erase_if(small_unordered_flat_multimap& c, Predicate pred); -``` +1. ``` + template + typename small_unordered_flat_multimap::size_type + erase_if(small_unordered_flat_multimap& c, Predicate pred); + ``` -**Effects:** -Erases all elements that satisfy the predicate `pred` from the container. + **Effects:** + Erases all elements that satisfy the predicate `pred` from the container. -`pred` is unary predicate which returns `true` if the element should be removed. + `pred` is unary predicate which returns `true` if the element should be removed. -**Returns:** -The number of erased elements. + **Returns:** + The number of erased elements. -**Complexity:** -Linear. + **Complexity:** + Linear. -

+

diff --git a/doc/small_unordered_flat_multiset.md b/doc/small_unordered_flat_multiset.md index 47c9937..050dfe0 100644 --- a/doc/small_unordered_flat_multiset.md +++ b/doc/small_unordered_flat_multiset.md @@ -88,7 +88,8 @@ Iterators to elements of `sfl::small_unordered_flat_multiset` are random access std::size_t N ``` - Size of the internal statically allocated array. + Size of the internal statically allocated array, i.e. the maximal number of elements that can fit into this array. + This parameter can be zero. 3. ``` @@ -147,867 +148,822 @@ static constexpr size_type static_capacity = N; ### (constructor) -``` -small_unordered_flat_multiset() - noexcept( +1. ``` + small_unordered_flat_multiset() noexcept( std::is_nothrow_default_constructible::value && std::is_nothrow_default_constructible::value ); -``` -``` -explicit small_unordered_flat_multiset(const KeyEqual& equal) - noexcept( + ``` +2. ``` + explicit small_unordered_flat_multiset(const KeyEqual& equal) noexcept( std::is_nothrow_default_constructible::value && std::is_nothrow_copy_constructible::value ); -``` -``` -explicit small_unordered_flat_multiset(const Allocator& alloc) - noexcept( + ``` +3. ``` + explicit small_unordered_flat_multiset(const Allocator& alloc) noexcept( std::is_nothrow_copy_constructible::value && std::is_nothrow_default_constructible::value ); -``` -``` -explicit small_unordered_flat_multiset(const KeyEqual& equal, const Allocator& alloc) - noexcept( + ``` +4. ``` + explicit small_unordered_flat_multiset(const KeyEqual& equal, const Allocator& alloc) noexcept( std::is_nothrow_copy_constructible::value && std::is_nothrow_copy_constructible::value ); -``` + ``` -**Effects:** -Constructs an empty container. + **Effects:** + Constructs an empty container. -

+

-``` -template -small_unordered_flat_multiset(InputIt first, InputIt last); -``` -``` -template -small_unordered_flat_multiset(InputIt first, InputIt last, const KeyEqual& equal); -``` -``` -template -small_unordered_flat_multiset(InputIt first, InputIt last, const Allocator& alloc); -``` -``` -template -small_unordered_flat_multiset(InputIt first, InputIt last, const KeyEqual& equal, const Allocator& alloc); -``` +5. ``` + template + small_unordered_flat_multiset(InputIt first, InputIt last); + ``` +6. ``` + template + small_unordered_flat_multiset(InputIt first, InputIt last, const KeyEqual& equal); + ``` +7. ``` + template + small_unordered_flat_multiset(InputIt first, InputIt last, const Allocator& alloc); + ``` +8. ``` + template + small_unordered_flat_multiset(InputIt first, InputIt last, const KeyEqual& equal, const Allocator& alloc); + ``` -**Effects:** -Constructs an empty container and inserts elements from the range `[first, last)`. + **Effects:** + Constructs an empty container and inserts elements from the range `[first, last)`. -**Note:** -This overload participates in overload resolution only if `InputIt` satisfies requirements of [*LegacyInputIterator*](https://en.cppreference.com/w/cpp/named_req/InputIterator). + **Note:** + This overload participates in overload resolution only if `InputIt` satisfies requirements of [*LegacyInputIterator*](https://en.cppreference.com/w/cpp/named_req/InputIterator). -

+

-``` -small_unordered_flat_multiset(std::initializer_list ilist); -``` -``` -small_unordered_flat_multiset(std::initializer_list ilist, const KeyEqual& equal); -``` -``` -small_unordered_flat_multiset(std::initializer_list ilist, const Allocator& alloc); -``` -``` -small_unordered_flat_multiset(std::initializer_list ilist, const KeyEqual& equal, const Allocator& alloc); -``` +9. ``` + small_unordered_flat_multiset(std::initializer_list ilist); + ``` +10. ``` + small_unordered_flat_multiset(std::initializer_list ilist, const KeyEqual& equal); + ``` +11. ``` + small_unordered_flat_multiset(std::initializer_list ilist, const Allocator& alloc); + ``` +12. ``` + small_unordered_flat_multiset(std::initializer_list ilist, const KeyEqual& equal, const Allocator& alloc); + ``` -**Effects:** -Constructs an empty container and inserts elements from the initializer list `ilist`. + **Effects:** + Constructs an empty container and inserts elements from the initializer list `ilist`. -

+

-``` -small_unordered_flat_multiset(const small_unordered_flat_multiset& other); -``` -``` -small_unordered_flat_multiset(const small_unordered_flat_multiset& other, const Allocator& alloc); -``` +13. ``` + small_unordered_flat_multiset(const small_unordered_flat_multiset& other); + ``` +14. ``` + small_unordered_flat_multiset(const small_unordered_flat_multiset& other, const Allocator& alloc); + ``` -**Effects:** -Copy constructor. -Constructs the container with the copy of the contents of `other`. + **Effects:** + Copy constructor. + Constructs the container with the copy of the contents of `other`. -**Complexity:** -Linear in `other.size()`. + **Complexity:** + Linear in `other.size()`. -

+

-``` -small_unordered_flat_multiset(small_unordered_flat_multiset&& other); -``` -``` -small_unordered_flat_multiset(small_unordered_flat_multiset&& other, const Allocator& alloc); -``` +15. ``` + small_unordered_flat_multiset(small_unordered_flat_multiset&& other); + ``` +16. ``` + small_unordered_flat_multiset(small_unordered_flat_multiset&& other, const Allocator& alloc); + ``` -**Effects:** -Move constructor. -Constructs the container with the contents of `other` using move semantics. + **Effects:** + Move constructor. + Constructs the container with the contents of `other` using move semantics. -`other` is not guaranteed to be empty after the move. + `other` is not guaranteed to be empty after the move. -`other` is in a valid but unspecified state after the move. + `other` is in a valid but unspecified state after the move. -**Complexity:** -Constant in the best case. Linear in `N` in the worst case. + **Complexity:** + Constant in the best case. Linear in `N` in the worst case. -

+

### (destructor) -``` -~small_unordered_flat_multiset(); -``` +1. ``` + ~small_unordered_flat_multiset(); + ``` -**Effects:** -Destructs the container. The destructors of the elements are called and the used storage is deallocated. + **Effects:** + Destructs the container. The destructors of the elements are called and the used storage is deallocated. -**Complexity:** -Linear in `size()`. + **Complexity:** + Linear in `size()`. -

+

### operator= -``` -small_unordered_flat_multiset& operator=(const small_unordered_flat_multiset& other); -``` +1. ``` + small_unordered_flat_multiset& operator=(const small_unordered_flat_multiset& other); + ``` -**Effects:** -Copy assignment operator. -Replaces the contents with a copy of the contents of `other`. + **Effects:** + Copy assignment operator. + Replaces the contents with a copy of the contents of `other`. -**Returns:** -`*this()`. + **Returns:** + `*this()`. -**Complexity:** -Linear in `this->size()` plus linear in `other.size()`. + **Complexity:** + Linear in `this->size()` plus linear in `other.size()`. -

+

-``` -small_unordered_flat_multiset& operator=(small_unordered_flat_multiset&& other); -``` +2. ``` + small_unordered_flat_multiset& operator=(small_unordered_flat_multiset&& other); + ``` -**Effects:** -Move assignment operator. -Replaces the contents with those of `other` using move semantics. + **Effects:** + Move assignment operator. + Replaces the contents with those of `other` using move semantics. -`other` is not guaranteed to be empty after the move. + `other` is not guaranteed to be empty after the move. -`other` is in a valid but unspecified state after the move. + `other` is in a valid but unspecified state after the move. -**Returns:** -`*this()`. + **Returns:** + `*this()`. -**Complexity:** + **Complexity:** -* The best case: Linear in `this->size()` plus constant. -* The worst case: Linear in `this->size()` plus linear in `other.size()`. + * The best case: Linear in `this->size()` plus constant. + * The worst case: Linear in `this->size()` plus linear in `other.size()`. -

+

-``` -small_unordered_flat_multiset& operator=(std::initializer_list ilist); -``` +3. ``` + small_unordered_flat_multiset& operator=(std::initializer_list ilist); + ``` -**Effects:** -Replaces the contents with those identified by initializer list `ilist`. + **Effects:** + Replaces the contents with those identified by initializer list `ilist`. -**Returns:** -`*this()`. + **Returns:** + `*this()`. -**Complexity:** -Linear in `this->size()` plus linear in `ilist.size()`. + **Complexity:** + Linear in `this->size()` plus linear in `ilist.size()`. -

+

### get_allocator -``` -allocator_type get_allocator() const noexcept; -``` +1. ``` + allocator_type get_allocator() const noexcept; + ``` -**Effects:** -Returns the allocator associated with the container. + **Effects:** + Returns the allocator associated with the container. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

### key_eq -``` -key_equal key_eq() const; -``` +1. ``` + key_equal key_eq() const; + ``` -**Effects:** -Returns the function object that compares keys for equality, which is a copy of this container's constructor argument `equal`. + **Effects:** + Returns the function object that compares keys for equality, which is a copy of this container's constructor argument `equal`. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

### begin, cbegin -``` -iterator begin() noexcept; -``` -``` -const_iterator begin() const noexcept; -``` -``` -const_iterator cbegin() const noexcept; -``` - -**Effects:** -Returns an iterator to the first element of the container. +1. ``` + iterator begin() noexcept; + ``` +2. ``` + const_iterator begin() const noexcept; + ``` +3. ``` + const_iterator cbegin() const noexcept; + ``` -If the container is empty, the returned iterator will be equal to `end()`. + **Effects:** + Returns an iterator to the first element of the container. + If the container is empty, the returned iterator will be equal to `end()`. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

### end, cend -``` -iterator end() noexcept; -``` -``` -const_iterator end() const noexcept; -``` -``` -const_iterator cend() const noexcept; -``` - -**Effects:** -Returns an iterator to the element following the last element of the container. +1. ``` + iterator end() noexcept; + ``` +2. ``` + const_iterator end() const noexcept; + ``` +3. ``` + const_iterator cend() const noexcept; + ``` -This element acts as a placeholder; attempting to access it results in undefined behavior. + **Effects:** + Returns an iterator to the element following the last element of the container. + This element acts as a placeholder; attempting to access it results in undefined behavior. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

### nth -``` -iterator nth(size_type pos) noexcept; -``` -``` -const_iterator nth(size_type pos) const noexcept; -``` +1. ``` + iterator nth(size_type pos) noexcept; + ``` +2. ``` + const_iterator nth(size_type pos) const noexcept; + ``` -**Preconditions:** -`pos <= size()` + **Preconditions:** + `pos <= size()` -**Effects:** -Returns an iterator to the element at position `pos`. -If `pos == size()`, the returned iterator is equal to `end()`. + **Effects:** + Returns an iterator to the element at position `pos`. -**Complexity:** -Constant. + If `pos == size()`, the returned iterator is equal to `end()`. -

+ **Complexity:** + Constant. + +

### index_of -``` -size_type index_of(const_iterator pos) const noexcept; -``` +1. ``` + size_type index_of(const_iterator pos) const noexcept; + ``` -**Preconditions:** -`cbegin() <= pos && pos <= cend()` + **Preconditions:** + `cbegin() <= pos && pos <= cend()` -**Effects:** -Returns position of the element pointed by iterator `pos`, i.e. `std::distance(begin(), pos)`. + **Effects:** + Returns position of the element pointed by iterator `pos`, i.e. `std::distance(begin(), pos)`. -If `pos == end()`, the returned value is equal to `size()`. + If `pos == end()`, the returned value is equal to `size()`. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

### empty -``` -bool empty() const noexcept; -``` +1. ``` + bool empty() const noexcept; + ``` -**Effects:** -Returns `true` if the container has no elements, i.e. whether `begin() == end()`. + **Effects:** + Returns `true` if the container has no elements, i.e. whether `begin() == end()`. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

### size -``` -size_type size() const noexcept; -``` +1. ``` + size_type size() const noexcept; + ``` -**Effects:** -Returns the number of elements in the container, i.e. `std::distance(begin(), end())`. + **Effects:** + Returns the number of elements in the container, i.e. `std::distance(begin(), end())`. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

### max_size -``` -size_type max_size() const noexcept; -``` +1. ``` + size_type max_size() const noexcept; + ``` -**Effects:** -Returns the maximum number of elements the container is able to hold, i.e. `std::distance(begin(), end())` for the largest container. + **Effects:** + Returns the maximum number of elements the container is able to hold, i.e. `std::distance(begin(), end())` for the largest container. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

### capacity -``` -size_type capacity() const noexcept; -``` +1. ``` + size_type capacity() const noexcept; + ``` -**Effects:** -Returns the number of elements that the container has currently allocated space for. + **Effects:** + Returns the number of elements that the container has currently allocated space for. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

### available -``` -size_type available() const noexcept; -``` +1. ``` + size_type available() const noexcept; + ``` -**Effects:** -Returns the number of elements that can be inserted into the container without requiring allocation of additional memory. + **Effects:** + Returns the number of elements that can be inserted into the container without requiring allocation of additional memory. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

### reserve -``` -void reserve(size_type new_cap); -``` +1. ``` + void reserve(size_type new_cap); + ``` -**Effects:** -Tries to increase capacity by allocating additional memory. + **Effects:** + Tries to increase capacity by allocating additional memory. -If `new_cap > capacity()`, the function allocates memory for new storage of capacity equal to the value of `new_cap`, moves elements from old storage to new storage, and deallocates memory used by old storage. Otherwise, the function does nothing. + If `new_cap > capacity()`, the function allocates memory for new storage of capacity equal to the value of `new_cap`, moves elements from old storage to new storage, and deallocates memory used by old storage. Otherwise, the function does nothing. -This function does not change size of the container. + This function does not change size of the container. -If the capacity is changed, all iterators and all references to the elements are invalidated. Otherwise, no iterators or references are invalidated. + If the capacity is changed, all iterators and all references to the elements are invalidated. Otherwise, no iterators or references are invalidated. -**Complexity:** -Linear. + **Complexity:** + Linear. -**Exceptions:** + **Exceptions:** -* `Allocator::allocate` may throw. -* `T`'s move or copy constructor may throw. + * `Allocator::allocate` may throw. + * `T`'s move or copy constructor may throw. -If an exception is thrown: + If an exception is thrown: -* If type `T` has available `noexcept` move constructor: - * This function has no effects (strong exception guarantee). -* Else if type `T` has available copy constructor: - * This function has no effects (strong exception guarantee). -* Else if type `T` has available throwing move constructor: - * Container is changed but in valid state (basic exception guarantee). + * If type `T` has available `noexcept` move constructor: + * This function has no effects (strong exception guarantee). + * Else if type `T` has available copy constructor: + * This function has no effects (strong exception guarantee). + * Else if type `T` has available throwing move constructor: + * Container is changed but in valid state (basic exception guarantee). -

+

### shrink_to_fit -``` -void shrink_to_fit(); -``` +1. ``` + void shrink_to_fit(); + ``` -**Effects:** -Tries to reduce memory usage by freeing unused memory. + **Effects:** + Tries to reduce memory usage by freeing unused memory. -1. If `size() > N && size() < capacity()`, the function allocates memory for new storage of capacity equal to the value of `size()`, moves elements from old storage to new storage, and deallocates memory used by old storage. -2. If `size() <= N && N < capacity()`, the function sets new storage to be internal statically allocated array of capacity `N`, moves elements from old storage to new storage, and deallocates memory used by old storage. -3. Otherwise the function does nothing. + 1. If `size() > N && size() < capacity()`, the function allocates memory for new storage of capacity equal to the value of `size()`, moves elements from old storage to new storage, and deallocates memory used by old storage. -This function does not change size of the container. + 2. If `size() <= N && N < capacity()`, the function sets new storage to be internal statically allocated array of capacity `N`, moves elements from old storage to new storage, and deallocates memory used by old storage. -If the capacity is changed, all iterators and all references to the elements are invalidated. Otherwise, no iterators or references are invalidated. + 3. Otherwise the function does nothing. -**Complexity:** -Linear. + This function does not change size of the container. -**Exceptions:** + If the capacity is changed, all iterators and all references to the elements are invalidated. Otherwise, no iterators or references are invalidated. -* `Allocator::allocate` may throw. -* `T`'s move or copy constructor may throw. + **Complexity:** + Linear. -If an exception is thrown: + **Exceptions:** -* If type `T` has available `noexcept` move constructor: - * This function has no effects (strong exception guarantee). -* Else if type `T` has available copy constructor: - * This function has no effects (strong exception guarantee). -* Else if type `T` has available throwing move constructor: - * Container is changed but in valid state (basic exception guarantee). + * `Allocator::allocate` may throw. + * `T`'s move or copy constructor may throw. -

+ If an exception is thrown: + + * If type `T` has available `noexcept` move constructor: + * This function has no effects (strong exception guarantee). + * Else if type `T` has available copy constructor: + * This function has no effects (strong exception guarantee). + * Else if type `T` has available throwing move constructor: + * Container is changed but in valid state (basic exception guarantee). + +

### clear -``` -void clear() noexcept; -``` +1. ``` + void clear() noexcept; + ``` -**Effects:** -Erases all elements from the container. -After this call, `size()` returns zero and `capacity()` remains unchanged. + **Effects:** + Erases all elements from the container. + After this call, `size()` returns zero and `capacity()` remains unchanged. -**Complexity:** -Linear in `size()`. + **Complexity:** + Linear in `size()`. -

+

### emplace -``` -template -iterator emplace(Args&&... args); -``` +1. ``` + template + iterator emplace(Args&&... args); + ``` -**Effects:** -Inserts a new element into the container. + **Effects:** + Inserts a new element into the container. -New element is constructed as `value_type(std::forward(args)...)`. + New element is constructed as `value_type(std::forward(args)...)`. -**Returns:** -Iterator to the inserted element. + **Returns:** + Iterator to the inserted element. -

+

### emplace_hint -``` -template -iterator emplace_hint(const_iterator hint, Args&&... args); -``` - -**Preconditions:** -`cbegin() <= hint && hint <= cend()` - -**Effects:** -Inserts a new element into the container. +1. ``` + template + iterator emplace_hint(const_iterator hint, Args&&... args); + ``` -New element is constructed as `value_type(std::forward(args)...)`. + **Preconditions:** + `cbegin() <= hint && hint <= cend()` -Iterator `hint` is used as a suggestion where to start to search insert position. + **Effects:** + Inserts a new element into the container. -**Returns:** -Iterator to the inserted element. + New element is constructed as `value_type(std::forward(args)...)`. -

+ Iterator `hint` is used as a suggestion where to start to search insert position. + Iterator `hint` is ignored due to container's underlying storage implementation. This overload exists just to have this container compatible with standard C++ containers as much as possible. + **Returns:** + Iterator to the inserted element. -### insert +

-``` -iterator insert(const value_type& value); -``` -**Effects:** -Inserts copy of `value`. -**Returns:** -Iterator to the inserted element. +### insert -

+1. ``` + iterator insert(const value_type& value); + ``` + **Effects:** + Inserts copy of `value`. + **Returns:** + Iterator to the inserted element. -``` -iterator insert(value_type&& value); -``` +

-**Effects:** -Inserts `value` using move semantics. -**Returns:** -Iterator to the inserted element. - -

+2. ``` + iterator insert(value_type&& value); + ``` + **Effects:** + Inserts `value` using move semantics. -``` -iterator insert(const_iterator hint, const value_type& value); -``` + **Returns:** + Iterator to the inserted element. -**Preconditions:** -`cbegin() <= hint && hint <= cend()` +

-**Effects:** -Inserts copy of `value`. -Iterator `hint` is used as a suggestion where to start to search insert position. -**Returns:** -Iterator to the inserted element. +3. ``` + iterator insert(const_iterator hint, const value_type& value); + ``` -

+ **Preconditions:** + `cbegin() <= hint && hint <= cend()` + **Effects:** + Inserts copy of `value`. + Iterator `hint` is used as a suggestion where to start to search insert position. -``` -iterator insert(const_iterator hint, value_type&& value); -``` + **Returns:** + Iterator to the inserted element. -**Preconditions:** -`cbegin() <= hint && hint <= cend()` +

-**Effects:** -Inserts `value` using move semantics. -Iterator `hint` is used as a suggestion where to start to search insert position. -**Returns:** -Iterator to the inserted element. - -

+4. ``` + iterator insert(const_iterator hint, value_type&& value); + ``` + **Preconditions:** + `cbegin() <= hint && hint <= cend()` + **Effects:** + Inserts `value` using move semantics. -``` -template -void insert(InputIt first, InputIt last); -``` + Iterator `hint` is used as a suggestion where to start to search insert position. -**Effects:** -Inserts elements from range `[first, last)`. + Iterator `hint` is ignored due to container's underlying storage implementation. This overload exists just to have this container compatible with standard C++ containers as much as possible. -The call to this function is equivalent to: -``` -while (first != last) -{ - insert(*first); - ++first; -} -``` + **Returns:** + Iterator to the inserted element. -**Note:** -This overload participates in overload resolution only if `InputIt` satisfies requirements of [*LegacyInputIterator*](https://en.cppreference.com/w/cpp/named_req/InputIterator). +

-

+6. ``` + template + void insert(InputIt first, InputIt last); + ``` -``` -void insert(std::initializer_list ilist); -``` + **Effects:** + Inserts elements from range `[first, last)`. -**Effects:** -Inserts elements from initializer list `ilist`. + The call to this function is equivalent to: + ``` + while (first != last) + { + insert(*first); + ++first; + } + ``` -The call to this function is equivalent to: -``` -insert(ilist.begin(), ilist.end()); -``` + **Note:** + This overload participates in overload resolution only if `InputIt` satisfies requirements of [*LegacyInputIterator*](https://en.cppreference.com/w/cpp/named_req/InputIterator). -

+

-### erase +7. ``` + void insert(std::initializer_list ilist); + ``` -``` -iterator erase(iterator pos); -``` -``` -iterator erase(const_iterator pos); -``` + **Effects:** + Inserts elements from initializer list `ilist`. -**Preconditions:** -`cbegin() <= pos && pos < cend()` + The call to this function is equivalent to `insert(ilist.begin(), ilist.end())`. -**Effects:** -Removes the element at `pos`. +

-**Returns:** -Iterator following the last removed element. -

+### erase +1. ``` + iterator erase(iterator pos); + ``` +2. ``` + iterator erase(const_iterator pos); + ``` -``` -iterator erase(const_iterator first, const_iterator last); -``` + **Preconditions:** + `cbegin() <= pos && pos < cend()` -**Preconditions:** -`cbegin() <= first && first <= last && last <= cend()` + **Effects:** + Removes the element at `pos`. -**Effects:** -Removes the elements in the range `[first, last)`. + **Returns:** + Iterator following the last removed element. -**Returns:** -Iterator following the last removed element. +

-

+3. ``` + iterator erase(const_iterator first, const_iterator last); + ``` -``` -size_type erase(const Key& key); -``` + **Preconditions:** + `cbegin() <= first && first <= last && last <= cend()` -**Effects:** -Removes all elements with the key equivalent to `key`. + **Effects:** + Removes the elements in the range `[first, last)`. -**Returns:** -Number of elements removed. + **Returns:** + Iterator following the last removed element. -

+

-``` -template -size_type erase(K&& x); -``` +4. ``` + size_type erase(const Key& key); + ``` +5. ``` + template + size_type erase(K&& x); + ``` -**Effects:** -Removes all elements with key that compares equivalent to the value `x`. + **Effects:** + Removes all elements with the key equivalent to `key` or `x`. -**Note:** -This overload participates in overload resolution only if `KeyEqual::is_transparent` exists and is a valid type. It allows calling this function without constructing an instance of `Key`. + **Note:** + Overload (5) participates in overload resolution only if `KeyEqual::is_transparent` exists and is a valid type. It allows calling this function without constructing an instance of `Key`. -**Returns:** -Number of elements removed. + **Returns:** + Number of elements removed. -

+

### swap -``` -void swap(small_unordered_flat_multiset& other); -``` +1. ``` + void swap(small_unordered_flat_multiset& other); + ``` -**Preconditions:** -`allocator_traits::propagate_on_container_swap::value || get_allocator() == other.get_allocator()` + **Preconditions:** + `allocator_traits::propagate_on_container_swap::value || get_allocator() == other.get_allocator()` -**Effects:** -Exchanges the contents of the container with those of `other`. + **Effects:** + Exchanges the contents of the container with those of `other`. -**Complexity:** -Constant in the best case. Linear in `this->size()` plus linear in `other.size()` in the worst case. + **Complexity:** + Constant in the best case. Linear in `this->size()` plus linear in `other.size()` in the worst case. -

+

### find -``` -iterator find(const Key& key); -``` -``` -const_iterator find(const Key& key) const; -``` - -**Effects:** -Returns an iterator to an element with key equivalent to `key`, or `end()` if such an element is not found. If there are several elements with key in the container, any of them may be returned. - -**Complexity:** -Constant in the best case. Linear in `size()` in the worst case. - -

- - - -``` -template -iterator find(const K& x); -``` -``` -template -const_iterator find(const K& x) const; -``` +1. ``` + iterator find(const Key& key); + ``` +2. ``` + const_iterator find(const Key& key) const; + ``` +3. ``` + template + iterator find(const K& x); + ``` +4. ``` + template + const_iterator find(const K& x) const; + ``` -**Effects:** -Returns an iterator to an element with key that compares equivalent to `x`, or `end()` if such an element is not found. If there are several elements with key in the container, any of them may be returned. + **Effects:** + Returns an iterator pointing to the element with key equivalent to `key` or `x`. Returns `end()` if no such element is found. + If there are several elements with key in the container, any of them may be returned. -**Note:** -This overload participates in overload resolution only if `KeyEqual::is_transparent` exists and is a valid type. It allows calling this function without constructing an instance of `Key`. + **Note:** + Overloads (3) and (4) participate in overload resolution only if `KeyEqual::is_transparent` exists and is a valid type. It allows calling these functions without constructing an instance of `Key`. -**Complexity:** -Constant in the best case. Linear in `size()` in the worst case. + **Complexity:** + Constant in the best case. Linear in `size()` in the worst case. -

+

### count -``` -size_type count(const Key& key) const; -``` - -**Effects:** -Returns the number of elements with key equivalent to `key`. - -**Complexity:** -Linear in `size()`. - -

- - - -``` -template -size_type count(const K& x) const; -``` +1. ``` + size_type count(const Key& key) const; + ``` +2. ``` + template + size_type count(const K& x) const; + ``` -**Effects:** -Returns the number of elements with key that compares equivalent to the value `x`. + **Effects:** + Returns the number of elements with key equivalent to `key` or `x`. -**Note:** -This overload participates in overload resolution only if `KeyEqual::is_transparent` exists and is a valid type. It allows calling this function without constructing an instance of `Key`. + **Note:** + Overload (2) participates in overload resolution only if `KeyEqual::is_transparent` exists and is a valid type. It allows calling this function without constructing an instance of `Key`. -**Complexity:** -Linear in `size()`. + **Complexity:** + Linear in `size()`. -

+

### contains -``` -bool contains(const Key& key) const; -``` - -**Effects:** -Returns `true` if the container contains an element with key equivalent to `key`, otherwise returns `false`. - -**Complexity:** -Constant in the best case. Linear in `size()` in the worst case. - -

- - - -``` -template -bool contains(const K& x) const; -``` +1. ``` + bool contains(const Key& key) const; + ``` +2. ``` + template + bool contains(const K& x) const; + ``` -**Effects:** -Returns `true` if the container contains an element with the key that compares equivalent to `x`, otherwise returns `false`. + **Effects:** + Returns `true` if the container contains an element with key equivalent to `key` or `x`, otherwise returns `false`. -**Note:** -This overload participates in overload resolution only if `KeyEqual::is_transparent` exists and is a valid type. It allows calling this function without constructing an instance of `Key`. + **Note:** + Overload (2) participates in overload resolution only if `KeyEqual::is_transparent` exists and is a valid type. It allows calling this function without constructing an instance of `Key`. -**Complexity:** -Constant in the best case. Linear in `size()` in the worst case. + **Complexity:** + Constant in the best case. Linear in `size()` in the worst case. -

+

### data -``` -value_type* data() noexcept; -``` -``` -const value_type* data() const noexcept; -``` +1. ``` + value_type* data() noexcept; + ``` +2. ``` + const value_type* data() const noexcept; + ``` -**Effects:** -Returns pointer to the underlying array serving as element storage. The pointer is such that range `[data(), data() + size())` is always a valid range, even if the container is empty. `data()` is not dereferenceable if the container is empty. + **Effects:** + Returns pointer to the underlying array serving as element storage. The pointer is such that range `[data(), data() + size())` is always a valid range, even if the container is empty. `data()` is not dereferenceable if the container is empty. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

@@ -1015,93 +971,93 @@ Constant. ### operator== -``` -template -bool operator== -( - const small_unordered_flat_multiset& x, - const small_unordered_flat_multiset& y -); -``` +1. ``` + template + bool operator== + ( + const small_unordered_flat_multiset& x, + const small_unordered_flat_multiset& y + ); + ``` -**Effects:** -Checks if the contents of `x` and `y` are equal. + **Effects:** + Checks if the contents of `x` and `y` are equal. -The contents of `x` and `y` are equal if the following conditions hold: -* `x.size() == y.size()` -* For each element in `x` there is equal element in `y`. + The contents of `x` and `y` are equal if the following conditions hold: + * `x.size() == y.size()` + * For each element in `x` there is equal element in `y`. -The comparison is performed by `std::is_permutation`. -This comparison ignores the container's `KeyEqual` function. + The comparison is performed by `std::is_permutation`. + This comparison ignores the container's `KeyEqual` function. -**Returns:** -`true` if the contents of the `x` and `y` are equal, `false` otherwise. + **Returns:** + `true` if the contents of the `x` and `y` are equal, `false` otherwise. -

+

### operator!= -``` -template -bool operator!= -( - const small_unordered_flat_multiset& x, - const small_unordered_flat_multiset& y -); -``` +1. ``` + template + bool operator!= + ( + const small_unordered_flat_multiset& x, + const small_unordered_flat_multiset& y + ); + ``` -**Effects:** -Checks if the contents of `x` and `y` are equal. + **Effects:** + Checks if the contents of `x` and `y` are equal. -For details see `operator==`. + For details see `operator==`. -**Returns:** -`true` if the contents of the `x` and `y` are not equal, `false` otherwise. + **Returns:** + `true` if the contents of the `x` and `y` are not equal, `false` otherwise. -

+

### swap -``` -template -void swap -( - small_unordered_flat_multiset& x, - small_unordered_flat_multiset& y -); -``` +1. ``` + template + void swap + ( + small_unordered_flat_multiset& x, + small_unordered_flat_multiset& y + ); + ``` -**Effects:** -Swaps the contents of `x` and `y`. Calls `x.swap(y)`. + **Effects:** + Swaps the contents of `x` and `y`. Calls `x.swap(y)`. -

+

### erase_if -``` -template -typename small_unordered_flat_multiset::size_type - erase_if(small_unordered_flat_multiset& c, Predicate pred); -``` +1. ``` + template + typename small_unordered_flat_multiset::size_type + erase_if(small_unordered_flat_multiset& c, Predicate pred); + ``` -**Effects:** -Erases all elements that satisfy the predicate `pred` from the container. + **Effects:** + Erases all elements that satisfy the predicate `pred` from the container. -`pred` is unary predicate which returns `true` if the element should be removed. + `pred` is unary predicate which returns `true` if the element should be removed. -**Returns:** -The number of erased elements. + **Returns:** + The number of erased elements. -**Complexity:** -Linear. + **Complexity:** + Linear. -

+

diff --git a/doc/small_unordered_flat_set.md b/doc/small_unordered_flat_set.md index dcb65e8..2edf20a 100644 --- a/doc/small_unordered_flat_set.md +++ b/doc/small_unordered_flat_set.md @@ -88,7 +88,8 @@ Iterators to elements of `sfl::small_unordered_flat_set` are random access itera std::size_t N ``` - Size of the internal statically allocated array. + Size of the internal statically allocated array, i.e. the maximal number of elements that can fit into this array. + This parameter can be zero. 3. ``` @@ -147,871 +148,875 @@ static constexpr size_type static_capacity = N; ### (constructor) -``` -small_unordered_flat_set() - noexcept( +1. ``` + small_unordered_flat_set() noexcept( std::is_nothrow_default_constructible::value && std::is_nothrow_default_constructible::value ); -``` -``` -explicit small_unordered_flat_set(const KeyEqual& equal) - noexcept( + ``` +2. ``` + explicit small_unordered_flat_set(const KeyEqual& equal) noexcept( std::is_nothrow_default_constructible::value && std::is_nothrow_copy_constructible::value ); -``` -``` -explicit small_unordered_flat_set(const Allocator& alloc) - noexcept( + ``` +3. ``` + explicit small_unordered_flat_set(const Allocator& alloc) noexcept( std::is_nothrow_copy_constructible::value && std::is_nothrow_default_constructible::value ); -``` -``` -explicit small_unordered_flat_set(const KeyEqual& equal, const Allocator& alloc) - noexcept( + ``` +4. ``` + explicit small_unordered_flat_set(const KeyEqual& equal, const Allocator& alloc) noexcept( std::is_nothrow_copy_constructible::value && std::is_nothrow_copy_constructible::value ); -``` + ``` -**Effects:** -Constructs an empty container. + **Effects:** + Constructs an empty container. -

+

-``` -template -small_unordered_flat_set(InputIt first, InputIt last); -``` -``` -template -small_unordered_flat_set(InputIt first, InputIt last, const KeyEqual& equal); -``` -``` -template -small_unordered_flat_set(InputIt first, InputIt last, const Allocator& alloc); -``` -``` -template -small_unordered_flat_set(InputIt first, InputIt last, const KeyEqual& equal, const Allocator& alloc); -``` +5. ``` + template + small_unordered_flat_set(InputIt first, InputIt last); + ``` +6. ``` + template + small_unordered_flat_set(InputIt first, InputIt last, const KeyEqual& equal); + ``` +7. ``` + template + small_unordered_flat_set(InputIt first, InputIt last, const Allocator& alloc); + ``` +8. ``` + template + small_unordered_flat_set(InputIt first, InputIt last, const KeyEqual& equal, const Allocator& alloc); + ``` -**Effects:** -Constructs an empty container and inserts elements from the range `[first, last)`. + **Effects:** + Constructs an empty container and inserts elements from the range `[first, last)`. -**Note:** -This overload participates in overload resolution only if `InputIt` satisfies requirements of [*LegacyInputIterator*](https://en.cppreference.com/w/cpp/named_req/InputIterator). + **Note:** + This overload participates in overload resolution only if `InputIt` satisfies requirements of [*LegacyInputIterator*](https://en.cppreference.com/w/cpp/named_req/InputIterator). -

+

-``` -small_unordered_flat_set(std::initializer_list ilist); -``` -``` -small_unordered_flat_set(std::initializer_list ilist, const KeyEqual& equal); -``` -``` -small_unordered_flat_set(std::initializer_list ilist, const Allocator& alloc); -``` -``` -small_unordered_flat_set(std::initializer_list ilist, const KeyEqual& equal, const Allocator& alloc); -``` +9. ``` + small_unordered_flat_set(std::initializer_list ilist); + ``` +10. ``` + small_unordered_flat_set(std::initializer_list ilist, const KeyEqual& equal); + ``` +11. ``` + small_unordered_flat_set(std::initializer_list ilist, const Allocator& alloc); + ``` +12. ``` + small_unordered_flat_set(std::initializer_list ilist, const KeyEqual& equal, const Allocator& alloc); + ``` -**Effects:** -Constructs an empty container and inserts elements from the initializer list `ilist`. + **Effects:** + Constructs an empty container and inserts elements from the initializer list `ilist`. -

+

-``` -small_unordered_flat_set(const small_unordered_flat_set& other); -``` -``` -small_unordered_flat_set(const small_unordered_flat_set& other, const Allocator& alloc); -``` +13. ``` + small_unordered_flat_set(const small_unordered_flat_set& other); + ``` +14. ``` + small_unordered_flat_set(const small_unordered_flat_set& other, const Allocator& alloc); + ``` -**Effects:** -Copy constructor. -Constructs the container with the copy of the contents of `other`. + **Effects:** + Copy constructor. + Constructs the container with the copy of the contents of `other`. -**Complexity:** -Linear in `other.size()`. + **Complexity:** + Linear in `other.size()`. -

+

-``` -small_unordered_flat_set(small_unordered_flat_set&& other); -``` -``` -small_unordered_flat_set(small_unordered_flat_set&& other, const Allocator& alloc); -``` +15. ``` + small_unordered_flat_set(small_unordered_flat_set&& other); + ``` +16. ``` + small_unordered_flat_set(small_unordered_flat_set&& other, const Allocator& alloc); + ``` -**Effects:** -Move constructor. -Constructs the container with the contents of `other` using move semantics. + **Effects:** + Move constructor. + Constructs the container with the contents of `other` using move semantics. -`other` is not guaranteed to be empty after the move. + `other` is not guaranteed to be empty after the move. -`other` is in a valid but unspecified state after the move. + `other` is in a valid but unspecified state after the move. -**Complexity:** -Constant in the best case. Linear in `N` in the worst case. + **Complexity:** + Constant in the best case. Linear in `N` in the worst case. -

+

### (destructor) -``` -~small_unordered_flat_set(); -``` +1. ``` + ~small_unordered_flat_set(); + ``` -**Effects:** -Destructs the container. The destructors of the elements are called and the used storage is deallocated. + **Effects:** + Destructs the container. The destructors of the elements are called and the used storage is deallocated. -**Complexity:** -Linear in `size()`. + **Complexity:** + Linear in `size()`. -

+

### operator= -``` -small_unordered_flat_set& operator=(const small_unordered_flat_set& other); -``` +1. ``` + small_unordered_flat_set& operator=(const small_unordered_flat_set& other); + ``` -**Effects:** -Copy assignment operator. -Replaces the contents with a copy of the contents of `other`. + **Effects:** + Copy assignment operator. + Replaces the contents with a copy of the contents of `other`. -**Returns:** -`*this()`. + **Returns:** + `*this()`. -**Complexity:** -Linear in `this->size()` plus linear in `other.size()`. + **Complexity:** + Linear in `this->size()` plus linear in `other.size()`. -

+

-``` -small_unordered_flat_set& operator=(small_unordered_flat_set&& other); -``` +2. ``` + small_unordered_flat_set& operator=(small_unordered_flat_set&& other); + ``` -**Effects:** -Move assignment operator. -Replaces the contents with those of `other` using move semantics. + **Effects:** + Move assignment operator. + Replaces the contents with those of `other` using move semantics. -`other` is not guaranteed to be empty after the move. + `other` is not guaranteed to be empty after the move. -`other` is in a valid but unspecified state after the move. + `other` is in a valid but unspecified state after the move. -**Returns:** -`*this()`. + **Returns:** + `*this()`. -**Complexity:** + **Complexity:** -* The best case: Linear in `this->size()` plus constant. -* The worst case: Linear in `this->size()` plus linear in `other.size()`. + * The best case: Linear in `this->size()` plus constant. + * The worst case: Linear in `this->size()` plus linear in `other.size()`. -

+

-``` -small_unordered_flat_set& operator=(std::initializer_list ilist); -``` +3. ``` + small_unordered_flat_set& operator=(std::initializer_list ilist); + ``` -**Effects:** -Replaces the contents with those identified by initializer list `ilist`. + **Effects:** + Replaces the contents with those identified by initializer list `ilist`. -**Returns:** -`*this()`. + **Returns:** + `*this()`. -**Complexity:** -Linear in `this->size()` plus linear in `ilist.size()`. + **Complexity:** + Linear in `this->size()` plus linear in `ilist.size()`. -

+

### get_allocator -``` -allocator_type get_allocator() const noexcept; -``` +1. ``` + allocator_type get_allocator() const noexcept; + ``` -**Effects:** -Returns the allocator associated with the container. + **Effects:** + Returns the allocator associated with the container. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

### key_eq -``` -key_equal key_eq() const; -``` +1. ``` + key_equal key_eq() const; + ``` -**Effects:** -Returns the function object that compares keys for equality, which is a copy of this container's constructor argument `equal`. + **Effects:** + Returns the function object that compares keys for equality, which is a copy of this container's constructor argument `equal`. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

### begin, cbegin -``` -iterator begin() noexcept; -``` -``` -const_iterator begin() const noexcept; -``` -``` -const_iterator cbegin() const noexcept; -``` - -**Effects:** -Returns an iterator to the first element of the container. +1. ``` + iterator begin() noexcept; + ``` +2. ``` + const_iterator begin() const noexcept; + ``` +3. ``` + const_iterator cbegin() const noexcept; + ``` -If the container is empty, the returned iterator will be equal to `end()`. + **Effects:** + Returns an iterator to the first element of the container. + If the container is empty, the returned iterator will be equal to `end()`. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

### end, cend -``` -iterator end() noexcept; -``` -``` -const_iterator end() const noexcept; -``` -``` -const_iterator cend() const noexcept; -``` - -**Effects:** -Returns an iterator to the element following the last element of the container. +1. ``` + iterator end() noexcept; + ``` +2. ``` + const_iterator end() const noexcept; + ``` +3. ``` + const_iterator cend() const noexcept; + ``` -This element acts as a placeholder; attempting to access it results in undefined behavior. + **Effects:** + Returns an iterator to the element following the last element of the container. + This element acts as a placeholder; attempting to access it results in undefined behavior. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

### nth -``` -iterator nth(size_type pos) noexcept; -``` -``` -const_iterator nth(size_type pos) const noexcept; -``` +1. ``` + iterator nth(size_type pos) noexcept; + ``` +2. ``` + const_iterator nth(size_type pos) const noexcept; + ``` -**Preconditions:** -`pos <= size()` + **Preconditions:** + `pos <= size()` -**Effects:** -Returns an iterator to the element at position `pos`. -If `pos == size()`, the returned iterator is equal to `end()`. + **Effects:** + Returns an iterator to the element at position `pos`. -**Complexity:** -Constant. + If `pos == size()`, the returned iterator is equal to `end()`. -

+ **Complexity:** + Constant. + +

### index_of -``` -size_type index_of(const_iterator pos) const noexcept; -``` +1. ``` + size_type index_of(const_iterator pos) const noexcept; + ``` -**Preconditions:** -`cbegin() <= pos && pos <= cend()` + **Preconditions:** + `cbegin() <= pos && pos <= cend()` -**Effects:** -Returns position of the element pointed by iterator `pos`, i.e. `std::distance(begin(), pos)`. + **Effects:** + Returns position of the element pointed by iterator `pos`, i.e. `std::distance(begin(), pos)`. -If `pos == end()`, the returned value is equal to `size()`. + If `pos == end()`, the returned value is equal to `size()`. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

### empty -``` -bool empty() const noexcept; -``` +1. ``` + bool empty() const noexcept; + ``` -**Effects:** -Returns `true` if the container has no elements, i.e. whether `begin() == end()`. + **Effects:** + Returns `true` if the container has no elements, i.e. whether `begin() == end()`. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

### size -``` -size_type size() const noexcept; -``` +1. ``` + size_type size() const noexcept; + ``` -**Effects:** -Returns the number of elements in the container, i.e. `std::distance(begin(), end())`. + **Effects:** + Returns the number of elements in the container, i.e. `std::distance(begin(), end())`. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

### max_size -``` -size_type max_size() const noexcept; -``` +1. ``` + size_type max_size() const noexcept; + ``` -**Effects:** -Returns the maximum number of elements the container is able to hold, i.e. `std::distance(begin(), end())` for the largest container. + **Effects:** + Returns the maximum number of elements the container is able to hold, i.e. `std::distance(begin(), end())` for the largest container. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

### capacity -``` -size_type capacity() const noexcept; -``` +1. ``` + size_type capacity() const noexcept; + ``` -**Effects:** -Returns the number of elements that the container has currently allocated space for. + **Effects:** + Returns the number of elements that the container has currently allocated space for. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

### available -``` -size_type available() const noexcept; -``` +1. ``` + size_type available() const noexcept; + ``` -**Effects:** -Returns the number of elements that can be inserted into the container without requiring allocation of additional memory. + **Effects:** + Returns the number of elements that can be inserted into the container without requiring allocation of additional memory. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

### reserve -``` -void reserve(size_type new_cap); -``` +1. ``` + void reserve(size_type new_cap); + ``` -**Effects:** -Tries to increase capacity by allocating additional memory. + **Effects:** + Tries to increase capacity by allocating additional memory. -If `new_cap > capacity()`, the function allocates memory for new storage of capacity equal to the value of `new_cap`, moves elements from old storage to new storage, and deallocates memory used by old storage. Otherwise, the function does nothing. + If `new_cap > capacity()`, the function allocates memory for new storage of capacity equal to the value of `new_cap`, moves elements from old storage to new storage, and deallocates memory used by old storage. Otherwise, the function does nothing. -This function does not change size of the container. + This function does not change size of the container. -If the capacity is changed, all iterators and all references to the elements are invalidated. Otherwise, no iterators or references are invalidated. + If the capacity is changed, all iterators and all references to the elements are invalidated. Otherwise, no iterators or references are invalidated. -**Complexity:** -Linear. + **Complexity:** + Linear. -**Exceptions:** + **Exceptions:** -* `Allocator::allocate` may throw. -* `T`'s move or copy constructor may throw. + * `Allocator::allocate` may throw. + * `T`'s move or copy constructor may throw. -If an exception is thrown: + If an exception is thrown: -* If type `T` has available `noexcept` move constructor: - * This function has no effects (strong exception guarantee). -* Else if type `T` has available copy constructor: - * This function has no effects (strong exception guarantee). -* Else if type `T` has available throwing move constructor: - * Container is changed but in valid state (basic exception guarantee). + * If type `T` has available `noexcept` move constructor: + * This function has no effects (strong exception guarantee). + * Else if type `T` has available copy constructor: + * This function has no effects (strong exception guarantee). + * Else if type `T` has available throwing move constructor: + * Container is changed but in valid state (basic exception guarantee). -

+

### shrink_to_fit -``` -void shrink_to_fit(); -``` +1. ``` + void shrink_to_fit(); + ``` -**Effects:** -Tries to reduce memory usage by freeing unused memory. + **Effects:** + Tries to reduce memory usage by freeing unused memory. -1. If `size() > N && size() < capacity()`, the function allocates memory for new storage of capacity equal to the value of `size()`, moves elements from old storage to new storage, and deallocates memory used by old storage. -2. If `size() <= N && N < capacity()`, the function sets new storage to be internal statically allocated array of capacity `N`, moves elements from old storage to new storage, and deallocates memory used by old storage. -3. Otherwise the function does nothing. + 1. If `size() > N && size() < capacity()`, the function allocates memory for new storage of capacity equal to the value of `size()`, moves elements from old storage to new storage, and deallocates memory used by old storage. -This function does not change size of the container. + 2. If `size() <= N && N < capacity()`, the function sets new storage to be internal statically allocated array of capacity `N`, moves elements from old storage to new storage, and deallocates memory used by old storage. -If the capacity is changed, all iterators and all references to the elements are invalidated. Otherwise, no iterators or references are invalidated. + 3. Otherwise the function does nothing. -**Complexity:** -Linear. + This function does not change size of the container. -**Exceptions:** + If the capacity is changed, all iterators and all references to the elements are invalidated. Otherwise, no iterators or references are invalidated. -* `Allocator::allocate` may throw. -* `T`'s move or copy constructor may throw. + **Complexity:** + Linear. -If an exception is thrown: + **Exceptions:** -* If type `T` has available `noexcept` move constructor: - * This function has no effects (strong exception guarantee). -* Else if type `T` has available copy constructor: - * This function has no effects (strong exception guarantee). -* Else if type `T` has available throwing move constructor: - * Container is changed but in valid state (basic exception guarantee). + * `Allocator::allocate` may throw. + * `T`'s move or copy constructor may throw. -

+ If an exception is thrown: + + * If type `T` has available `noexcept` move constructor: + * This function has no effects (strong exception guarantee). + * Else if type `T` has available copy constructor: + * This function has no effects (strong exception guarantee). + * Else if type `T` has available throwing move constructor: + * Container is changed but in valid state (basic exception guarantee). + +

### clear -``` -void clear() noexcept; -``` +1. ``` + void clear() noexcept; + ``` -**Effects:** -Erases all elements from the container. -After this call, `size()` returns zero and `capacity()` remains unchanged. + **Effects:** + Erases all elements from the container. + After this call, `size()` returns zero and `capacity()` remains unchanged. -**Complexity:** -Linear in `size()`. + **Complexity:** + Linear in `size()`. -

+

### emplace -``` -template -std::pair emplace(Args&&... args); -``` +1. ``` + template + std::pair emplace(Args&&... args); + ``` -**Effects:** -Inserts a new element into the container only if the container does not already contain an element with an equivalent key. + **Effects:** + Inserts new element into the container if the container doesn't already contain an element with an equivalent key. -New element is constructed as `value_type(std::forward(args)...)`. + New element is constructed as `value_type(std::forward(args)...)`. -The element may be constructed even if there already is an element with the key in the container, in which case the newly constructed element will be destroyed immediately. + The element may be constructed even if there already is an element with the key in the container, in which case the newly constructed element will be destroyed immediately. -**Returns:** -Pair consisting of an iterator to the inserted element, or the already-existing element if no insertion happened, and a `bool` denoting whether the insertion took place (`true` if insertion happened, `false` if it did not). + **Returns:** + The iterator component points to the inserted element or to the already existing element. The `bool` component is `true` if insertion happened and `false` if it did not. -

+

### emplace_hint -``` -template -iterator emplace_hint(const_iterator hint, Args&&... args); -``` +1. ``` + template + iterator emplace_hint(const_iterator hint, Args&&... args); + ``` -**Preconditions:** -`cbegin() <= hint && hint <= cend()` + **Preconditions:** + `cbegin() <= hint && hint <= cend()` -**Effects:** -Inserts a new element into the container only if the container does not already contain an element with an equivalent key. + **Effects:** + Inserts new element into the container if the container doesn't already contain an element with an equivalent key. -New element is constructed as `value_type(std::forward(args)...)`. + New element is constructed as `value_type(std::forward(args)...)`. -The element may be constructed even if there already is an element with the key in the container, in which case the newly constructed element will be destroyed immediately. + The element may be constructed even if there already is an element with the key in the container, in which case the newly constructed element will be destroyed immediately. -Iterator `hint` is used as a suggestion where to start to search insert position. + Iterator `hint` is used as a suggestion where to start to search insert position. -**Returns:** -Iterator to the inserted element or to the already existing element. + Iterator `hint` is ignored due to container's underlying storage implementation. This overload exists just to have this container compatible with standard C++ containers as much as possible. -

+ **Returns:** + Iterator to the inserted element or to the already existing element. +

-### insert -``` -std::pair insert(const value_type& value); -``` +### insert -**Effects:** -Inserts copy of `value` only if the container does not already contain an element with an key equivalent to the key of `value`. +1. ``` + std::pair insert(const value_type& value); + ``` -**Returns:** -Pair consisting of an iterator to the inserted element, or the already-existing element if no insertion happened, and a `bool` denoting whether the insertion took place (`true` if insertion happened, `false` if it did not). + **Effects:** + Inserts copy of `value` if the container doesn't already contain an element with an equivalent key. -

+ **Returns:** + The iterator component points to the inserted element or to the already existing element. The `bool` component is `true` if insertion happened and `false` if it did not. +

-``` -std::pair insert(value_type&& value); -``` -**Effects:** -Inserts `value` using move semantics only if the container does not already contain an element with an key equivalent to the key of `value`. +2. ``` + std::pair insert(value_type&& value); + ``` -**Returns:** -Pair consisting of an iterator to the inserted element, or the already-existing element if no insertion happened, and a `bool` denoting whether the insertion took place (`true` if insertion happened, `false` if it did not). + **Effects:** + Inserts `value` using move semantics if the container doesn't already contain an element with an equivalent key. -

+ **Returns:** + The iterator component points to the inserted element or to the already existing element. The `bool` component is `true` if insertion happened and `false` if it did not. +

-``` -iterator insert(const_iterator hint, const value_type& value); -``` -**Preconditions:** -`cbegin() <= hint && hint <= cend()` +3. ``` + template + std::pair insert(K&& x); + ``` -**Effects:** -Inserts copy of `value` only if the container does not already contain an element with an key equivalent to the key of `value`. + **Effects:** + Inserts new element if the container doesn't already contain an element with a key equivalent to `x`. -Iterator `hint` is used as a suggestion where to start to search insert position. + New element is constructed as `value_type(std::forward(x))`. -**Returns:** -Iterator to the inserted element or to the already existing element. + **Note:** This overload participates in overload resolution only if `KeyEqual::is_transparent` exists and is a valid type. It allows calling this function without constructing an instance of `Key`. -

+ **Returns:** + The iterator component points to the inserted element or to the already existing element. The `bool` component is `true` if insertion happened and `false` if it did not. +

-``` -iterator insert(const_iterator hint, value_type&& value); -``` -**Preconditions:** -`cbegin() <= hint && hint <= cend()` +4. ``` + iterator insert(const_iterator hint, const value_type& value); + ``` -**Effects:** -Inserts `value` using move semantics only if the container does not already contain an element with an key equivalent to the key of `value`. + **Preconditions:** + `cbegin() <= hint && hint <= cend()` -Iterator `hint` is used as a suggestion where to start to search insert position. + **Effects:** + Inserts copy of `value` if the container doesn't already contain an element with an equivalent key. -**Returns:** -Iterator to the inserted element or to the already existing element. + Iterator `hint` is used as a suggestion where to start to search insert position. -

+ Iterator `hint` is ignored due to container's underlying storage implementation. This overload exists just to have this container compatible with standard C++ containers as much as possible. + **Returns:** + Iterator to the inserted element or to the already existing element. +

-``` -template -void insert(InputIt first, InputIt last); -``` -**Effects:** -Inserts elements from range `[first, last)`. -The call to this function is equivalent to: -``` -while (first != last) -{ - insert(*first); - ++first; -} -``` +5. ``` + iterator insert(const_iterator hint, value_type&& value); + ``` -**Note:** -This overload participates in overload resolution only if `InputIt` satisfies requirements of [*LegacyInputIterator*](https://en.cppreference.com/w/cpp/named_req/InputIterator). + **Preconditions:** + `cbegin() <= hint && hint <= cend()` -

+ **Effects:** + Inserts `value` using move semantics if the container doesn't already contain an element with an equivalent key. + Iterator `hint` is used as a suggestion where to start to search insert position. + Iterator `hint` is ignored due to container's underlying storage implementation. This overload exists just to have this container compatible with standard C++ containers as much as possible. -``` -void insert(std::initializer_list ilist); -``` + **Returns:** + Iterator to the inserted element or to the already existing element. -**Effects:** -Inserts elements from initializer list `ilist`. +

-The call to this function is equivalent to: -``` -insert(ilist.begin(), ilist.end()); -``` -

+6. ``` + template + iterator insert(const_iterator hint, K&& x); + ``` + **Preconditions:** + `cbegin() <= hint && hint <= cend()` -### erase + **Effects:** + Inserts new element if the container doesn't already contain an element with a key equivalent to `x`. -``` -iterator erase(iterator pos); -``` -``` -iterator erase(const_iterator pos); -``` - -**Preconditions:** -`cbegin() <= pos && pos < cend()` + New element is constructed as `value_type(std::forward(x))`. -**Effects:** -Removes the element at `pos`. + Iterator `hint` is used as a suggestion where to start to search insert position. -**Returns:** -Iterator following the last removed element. + Iterator `hint` is ignored due to container's underlying storage implementation. This overload exists just to have this container compatible with standard C++ containers as much as possible. -

+ **Note:** This overload participates in overload resolution only if all following conditions are satisfied: + 1. `KeyEqual::is_transparent` exists and is a valid type. It allows calling this function without constructing an instance of `Key`. + 2. `std::is_convertible_v` is `false`. + 3. `std::is_convertible_v` is `false`. + **Returns:** + Iterator to the inserted element or to the already existing element. +

-``` -iterator erase(const_iterator first, const_iterator last); -``` -**Preconditions:** -`cbegin() <= first && first <= last && last <= cend()` -**Effects:** -Removes the elements in the range `[first, last)`. +7. ``` + template + void insert(InputIt first, InputIt last); + ``` -**Returns:** -Iterator following the last removed element. - -

+ **Effects:** + Inserts elements from range `[first, last)`. + The call to this function is equivalent to: + ``` + while (first != last) + { + insert(*first); + ++first; + } + ``` + **Note:** + This overload participates in overload resolution only if `InputIt` satisfies requirements of [*LegacyInputIterator*](https://en.cppreference.com/w/cpp/named_req/InputIterator). -``` -size_type erase(const Key& key); -``` +

-**Effects:** -Removes the element (if one exists) with the key equivalent to `key`. -**Returns:** -Number of elements removed (0 or 1). -

+8. ``` + void insert(std::initializer_list ilist); + ``` + **Effects:** + Inserts elements from initializer list `ilist`. + The call to this function is equivalent to `insert(ilist.begin(), ilist.end())`. -``` -template -size_type erase(K&& x); -``` +

-**Effects:** -Removes the element (if one exists) with key that compares equivalent to the value `x`. -**Note:** -This overload participates in overload resolution only if `KeyEqual::is_transparent` exists and is a valid type. It allows calling this function without constructing an instance of `Key`. -**Returns:** -Number of elements removed (0 or 1). +### erase -

+1. ``` + iterator erase(iterator pos); + ``` +2. ``` + iterator erase(const_iterator pos); + ``` + **Preconditions:** + `cbegin() <= pos && pos < cend()` + **Effects:** + Removes the element at `pos`. -### swap + **Returns:** + Iterator following the last removed element. -``` -void swap(small_unordered_flat_set& other); -``` +

-**Preconditions:** -`allocator_traits::propagate_on_container_swap::value || get_allocator() == other.get_allocator()` -**Effects:** -Exchanges the contents of the container with those of `other`. -**Complexity:** -Constant in the best case. Linear in `this->size()` plus linear in `other.size()` in the worst case. +3. ``` + iterator erase(const_iterator first, const_iterator last); + ``` -

+ **Preconditions:** + `cbegin() <= first && first <= last && last <= cend()` + **Effects:** + Removes the elements in the range `[first, last)`. + **Returns:** + Iterator following the last removed element. -### find +

-``` -iterator find(const Key& key); -``` -``` -const_iterator find(const Key& key) const; -``` -**Effects:** -Returns an iterator to an element with key equivalent to `key`, or `end()` if such an element is not found. -**Complexity:** -Constant in the best case. Linear in `size()` in the worst case. +4. ``` + size_type erase(const Key& key); + ``` +5. ``` + template + size_type erase(K&& x); + ``` -

+ **Effects:** + Removes the element (if one exists) with the key equivalent to `key` or `x`. + **Note:** + Overload (5) participates in overload resolution only if `KeyEqual::is_transparent` exists and is a valid type. It allows calling this function without constructing an instance of `Key`. + **Returns:** + Number of elements removed (0 or 1). -``` -template -iterator find(const K& x); -``` -``` -template -const_iterator find(const K& x) const; -``` +

-**Effects:** -Returns an iterator to an element with key that compares equivalent to `x`, or `end()` if such an element is not found. -**Note:** -This overload participates in overload resolution only if `KeyEqual::is_transparent` exists and is a valid type. It allows calling this function without constructing an instance of `Key`. -**Complexity:** -Constant in the best case. Linear in `size()` in the worst case. +### swap -

+1. ``` + void swap(small_unordered_flat_set& other); + ``` + **Preconditions:** + `allocator_traits::propagate_on_container_swap::value || get_allocator() == other.get_allocator()` + **Effects:** + Exchanges the contents of the container with those of `other`. -### count + **Complexity:** + Constant in the best case. Linear in `this->size()` plus linear in `other.size()` in the worst case. -``` -size_type count(const Key& key) const; -``` +

-**Effects:** -Returns the number of elements with key equivalent to `key`, which is either 1 or 0 since this container does not allow duplicates. -**Complexity:** -Constant in the best case. Linear in `size()` in the worst case. -

+### find +1. ``` + iterator find(const Key& key); + ``` +2. ``` + const_iterator find(const Key& key) const; + ``` +3. ``` + template + iterator find(const K& x); + ``` +4. ``` + template + const_iterator find(const K& x) const; + ``` + **Effects:** + Returns an iterator pointing to the element with key equivalent to `key` or `x`. Returns `end()` if no such element is found. -``` -template -size_type count(const K& x) const; -``` + **Note:** + Overloads (3) and (4) participate in overload resolution only if `KeyEqual::is_transparent` exists and is a valid type. It allows calling these functions without constructing an instance of `Key`. -**Effects:** -Returns the number of elements with key that compares equivalent to `x`, which is either 1 or 0 since this container does not allow duplicates. + **Complexity:** + Constant in the best case. Linear in `size()` in the worst case. -**Note:** -This overload participates in overload resolution only if `KeyEqual::is_transparent` exists and is a valid type. It allows calling this function without constructing an instance of `Key`. +

-**Complexity:** -Constant in the best case. Linear in `size()` in the worst case. -

+### count +1. ``` + size_type count(const Key& key) const; + ``` +2. ``` + template + size_type count(const K& x) const; + ``` -### contains + **Effects:** + Returns the number of elements with key equivalent to `key` or `x`, which is either 1 or 0 since this container does not allow duplicates. -``` -bool contains(const Key& key) const; -``` + **Note:** + Overload (2) participates in overload resolution only if `KeyEqual::is_transparent` exists and is a valid type. It allows calling this function without constructing an instance of `Key`. -**Effects:** -Returns `true` if the container contains an element with key equivalent to `key`, otherwise returns `false`. + **Complexity:** + Constant in the best case. Linear in `size()` in the worst case. -**Complexity:** -Constant in the best case. Linear in `size()` in the worst case. +

-

+### contains -``` -template -bool contains(const K& x) const; -``` +1. ``` + bool contains(const Key& key) const; + ``` +2. ``` + template + bool contains(const K& x) const; + ``` -**Effects:** -Returns `true` if the container contains an element with the key that compares equivalent to `x`, otherwise returns `false`. + **Effects:** + Returns `true` if the container contains an element with key equivalent to `key` or `x`, otherwise returns `false`. -**Note:** -This overload participates in overload resolution only if `KeyEqual::is_transparent` exists and is a valid type. It allows calling this function without constructing an instance of `Key`. + **Note:** + Overload (2) participates in overload resolution only if `KeyEqual::is_transparent` exists and is a valid type. It allows calling this function without constructing an instance of `Key`. -**Complexity:** -Constant in the best case. Linear in `size()` in the worst case. + **Complexity:** + Constant in the best case. Linear in `size()` in the worst case. -

+

### data -``` -value_type* data() noexcept; -``` -``` -const value_type* data() const noexcept; -``` +1. ``` + value_type* data() noexcept; + ``` +2. ``` + const value_type* data() const noexcept; + ``` -**Effects:** -Returns pointer to the underlying array serving as element storage. The pointer is such that range `[data(), data() + size())` is always a valid range, even if the container is empty. `data()` is not dereferenceable if the container is empty. + **Effects:** + Returns pointer to the underlying array serving as element storage. The pointer is such that range `[data(), data() + size())` is always a valid range, even if the container is empty. `data()` is not dereferenceable if the container is empty. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

@@ -1019,93 +1024,93 @@ Constant. ### operator== -``` -template -bool operator== -( - const small_unordered_flat_set& x, - const small_unordered_flat_set& y -); -``` +1. ``` + template + bool operator== + ( + const small_unordered_flat_set& x, + const small_unordered_flat_set& y + ); + ``` -**Effects:** -Checks if the contents of `x` and `y` are equal. + **Effects:** + Checks if the contents of `x` and `y` are equal. -The contents of `x` and `y` are equal if the following conditions hold: -* `x.size() == y.size()` -* For each element in `x` there is equal element in `y`. + The contents of `x` and `y` are equal if the following conditions hold: + * `x.size() == y.size()` + * For each element in `x` there is equal element in `y`. -The comparison is performed by `std::is_permutation`. -This comparison ignores the container's `KeyEqual` function. + The comparison is performed by `std::is_permutation`. + This comparison ignores the container's `KeyEqual` function. -**Returns:** -`true` if the contents of the `x` and `y` are equal, `false` otherwise. + **Returns:** + `true` if the contents of the `x` and `y` are equal, `false` otherwise. -

+

### operator!= -``` -template -bool operator!= -( - const small_unordered_flat_set& x, - const small_unordered_flat_set& y -); -``` +1. ``` + template + bool operator!= + ( + const small_unordered_flat_set& x, + const small_unordered_flat_set& y + ); + ``` -**Effects:** -Checks if the contents of `x` and `y` are equal. + **Effects:** + Checks if the contents of `x` and `y` are equal. -For details see `operator==`. + For details see `operator==`. -**Returns:** -`true` if the contents of the `x` and `y` are not equal, `false` otherwise. + **Returns:** + `true` if the contents of the `x` and `y` are not equal, `false` otherwise. -

+

### swap -``` -template -void swap -( - small_unordered_flat_set& x, - small_unordered_flat_set& y -); -``` +1. ``` + template + void swap + ( + small_unordered_flat_set& x, + small_unordered_flat_set& y + ); + ``` -**Effects:** -Swaps the contents of `x` and `y`. Calls `x.swap(y)`. + **Effects:** + Swaps the contents of `x` and `y`. Calls `x.swap(y)`. -

+

### erase_if -``` -template -typename small_unordered_flat_set::size_type - erase_if(small_unordered_flat_set& c, Predicate pred); -``` +1. ``` + template + typename small_unordered_flat_set::size_type + erase_if(small_unordered_flat_set& c, Predicate pred); + ``` -**Effects:** -Erases all elements that satisfy the predicate `pred` from the container. + **Effects:** + Erases all elements that satisfy the predicate `pred` from the container. -`pred` is unary predicate which returns `true` if the element should be removed. + `pred` is unary predicate which returns `true` if the element should be removed. -**Returns:** -The number of erased elements. + **Returns:** + The number of erased elements. -**Complexity:** -Linear. + **Complexity:** + Linear. -

+

diff --git a/doc/small_vector.md b/doc/small_vector.md index c770261..3e5040b 100644 --- a/doc/small_vector.md +++ b/doc/small_vector.md @@ -94,7 +94,8 @@ Size `N` is specified at the compile time as a template parameter. In case when std::size_t N ``` - Size of the internal statically allocated array. + Size of the internal statically allocated array, i.e. the maximal number of elements that can fit into this array. + This parameter can be zero. 3. ``` @@ -147,1005 +148,1006 @@ static constexpr size_type static_capacity = N; ### (constructor) -``` -small_vector() noexcept; -``` -``` -explicit small_vector(const Allocator& alloc) - noexcept(std::is_nothrow_copy_constructible::value); -``` +1. ``` + small_vector() noexcept; + ``` +2. ``` + explicit small_vector(const Allocator& alloc) + noexcept(std::is_nothrow_copy_constructible::value); + ``` -**Effects:** -Constructs an empty container. + **Effects:** + Constructs an empty container. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

-``` -small_vector(size_type n); -``` -``` -explicit small_vector(size_type n, const Allocator& alloc); -``` +3. ``` + small_vector(size_type n); + ``` +4. ``` + explicit small_vector(size_type n, const Allocator& alloc); + ``` -**Effects:** -Constructs the container with `n` default-constructed elements. + **Effects:** + Constructs the container with `n` default-constructed elements. -**Complexity:** -Linear in `n`. + **Complexity:** + Linear in `n`. -

+

-``` -small_vector(size_type n, const T& value); -``` -``` -small_vector(size_type n, const T& value, const Allocator& alloc); -``` +5. ``` + small_vector(size_type n, const T& value); + ``` +6. ``` + small_vector(size_type n, const T& value, const Allocator& alloc); + ``` -**Effects:** -Constructs the container with `n` copies of elements with value `value`. + **Effects:** + Constructs the container with `n` copies of elements with value `value`. -**Complexity:** -Linear in `n`. + **Complexity:** + Linear in `n`. -

+

-``` -template -small_vector(InputIt first, InputIt last); -``` -``` -template -small_vector(InputIt first, InputIt last, const Allocator& alloc); -``` +7. ``` + template + small_vector(InputIt first, InputIt last); + ``` +8. ``` + template + small_vector(InputIt first, InputIt last, const Allocator& alloc); + ``` -**Effects:** -Constructs the container with the contents of the range `[first, last)`. + **Effects:** + Constructs the container with the contents of the range `[first, last)`. -**Note:** -This overload participates in overload resolution only if `InputIt` satisfies requirements of [*LegacyInputIterator*](https://en.cppreference.com/w/cpp/named_req/InputIterator). + **Note:** + This overload participates in overload resolution only if `InputIt` satisfies requirements of [*LegacyInputIterator*](https://en.cppreference.com/w/cpp/named_req/InputIterator). -**Complexity:** -Linear in `std::distance(first, last)`. + **Complexity:** + Linear in `std::distance(first, last)`. -

+

-``` -small_vector(std::initializer_list ilist); -``` -``` -small_vector(std::initializer_list ilist, const Allocator& alloc); -``` +9. ``` + small_vector(std::initializer_list ilist); + ``` +10. ``` + small_vector(std::initializer_list ilist, const Allocator& alloc); + ``` -**Effects:** -Constructs the container with the contents of the initializer list `ilist`. + **Effects:** + Constructs the container with the contents of the initializer list `ilist`. -**Complexity:** -Linear in `ilist.size()`. + **Complexity:** + Linear in `ilist.size()`. -

+

-``` -small_vector(const small_vector& other); -``` -``` -small_vector(const small_vector& other, const Allocator& alloc); -``` +11. ``` + small_vector(const small_vector& other); + ``` +12. ``` + small_vector(const small_vector& other, const Allocator& alloc); + ``` -**Effects:** -Copy constructor. -Constructs the container with the copy of the contents of `other`. + **Effects:** + Copy constructor. + Constructs the container with the copy of the contents of `other`. -**Complexity:** -Linear in `other.size()`. + **Complexity:** + Linear in `other.size()`. -

+

-``` -small_vector(small_vector&& other); -``` -``` -small_vector(small_vector&& other, const Allocator& alloc); -``` +13. ``` + small_vector(small_vector&& other); + ``` +14. ``` + small_vector(small_vector&& other, const Allocator& alloc); + ``` -**Effects:** -Move constructor. -Constructs the container with the contents of `other` using move semantics. + **Effects:** + Move constructor. + Constructs the container with the contents of `other` using move semantics. -`other` is not guaranteed to be empty after the move. + `other` is not guaranteed to be empty after the move. -`other` is in a valid but unspecified state after the move. + `other` is in a valid but unspecified state after the move. -**Complexity:** -Constant in the best case. Linear in `N` in the worst case. + **Complexity:** + Constant in the best case. Linear in `N` in the worst case. -

+

### (destructor) -``` -~small_vector(); -``` +1. ``` + ~small_vector(); + ``` -**Effects:** -Destructs the container. The destructors of the elements are called and the used storage is deallocated. + **Effects:** + Destructs the container. The destructors of the elements are called and the used storage is deallocated. -**Complexity:** -Linear in `size()`. + **Complexity:** + Linear in `size()`. -

+

### assign -``` -void assign(size_type n, const T& value); -``` +1. ``` + void assign(size_type n, const T& value); + ``` -**Effects:** -Replaces the contents of the container with `n` copies of value `value`. + **Effects:** + Replaces the contents of the container with `n` copies of value `value`. -**Complexity:** -Linear in `n`. + **Complexity:** + Linear in `n`. -

+

-``` -template -void assign(InputIt first, InputIt last); -``` +2. ``` + template + void assign(InputIt first, InputIt last); + ``` -**Effects:** -Replaces the contents of the container with the contents of the range `[first, last)`. + **Effects:** + Replaces the contents of the container with the contents of the range `[first, last)`. -**Note:** -This overload participates in overload resolution only if `InputIt` satisfies requirements of [*LegacyInputIterator*](https://en.cppreference.com/w/cpp/named_req/InputIterator). + **Note:** + This overload participates in overload resolution only if `InputIt` satisfies requirements of [*LegacyInputIterator*](https://en.cppreference.com/w/cpp/named_req/InputIterator). -**Note:** -The behavior is undefined if either `first` or `last` is an iterator into `*this`. + **Note:** + The behavior is undefined if either `first` or `last` is an iterator into `*this`. -**Complexity:** -Linear in `std::distance(first, last)`. + **Complexity:** + Linear in `std::distance(first, last)`. -

+

-``` -void assign(std::initializer_list ilist); -``` +3. ``` + void assign(std::initializer_list ilist); + ``` -**Effects:** -Replaces the contents of the container with the contents of the initializer list `ilist`. + **Effects:** + Replaces the contents of the container with the contents of the initializer list `ilist`. -**Complexity:** -Linear in `ilist.size()`. + **Complexity:** + Linear in `ilist.size()`. -

+

### operator= -``` -small_vector& operator=(const small_vector& other); -``` +1. ``` + small_vector& operator=(const small_vector& other); + ``` -**Effects:** -Copy assignment operator. -Replaces the contents with a copy of the contents of `other`. + **Effects:** + Copy assignment operator. + Replaces the contents with a copy of the contents of `other`. -**Returns:** -`*this()`. + **Returns:** + `*this()`. -**Complexity:** -Linear in `this->size()` plus linear in `other.size()`. + **Complexity:** + Linear in `this->size()` plus linear in `other.size()`. -

+

-``` -small_vector& operator=(small_vector&& other); -``` +2. ``` + small_vector& operator=(small_vector&& other); + ``` -**Effects:** -Move assignment operator. -Replaces the contents with those of `other` using move semantics. + **Effects:** + Move assignment operator. + Replaces the contents with those of `other` using move semantics. -`other` is not guaranteed to be empty after the move. + `other` is not guaranteed to be empty after the move. -`other` is in a valid but unspecified state after the move. + `other` is in a valid but unspecified state after the move. -**Returns:** -`*this()`. + **Returns:** + `*this()`. -**Complexity:** + **Complexity:** -* The best case: Linear in `this->size()` plus constant. -* The worst case: Linear in `this->size()` plus linear in `other.size()`. + * The best case: Linear in `this->size()` plus constant. + * The worst case: Linear in `this->size()` plus linear in `other.size()`. -

+

-``` -small_vector& operator=(std::initializer_list ilist); -``` +3. ``` + small_vector& operator=(std::initializer_list ilist); + ``` -**Effects:** -Replaces the contents with those identified by initializer list `ilist`. + **Effects:** + Replaces the contents with those identified by initializer list `ilist`. -**Returns:** -`*this()`. + **Returns:** + `*this()`. -**Complexity:** -Linear in `this->size()` plus linear in `ilist.size()`. + **Complexity:** + Linear in `this->size()` plus linear in `ilist.size()`. -

+

### get_allocator -``` -allocator_type get_allocator() const noexcept; -``` +1. ``` + allocator_type get_allocator() const noexcept; + ``` -**Effects:** -Returns the allocator associated with the container. + **Effects:** + Returns the allocator associated with the container. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

### begin, cbegin -``` -iterator begin() noexcept; -``` -``` -const_iterator begin() const noexcept; -``` -``` -const_iterator cbegin() const noexcept; -``` - -**Effects:** -Returns an iterator to the first element of the container. +1. ``` + iterator begin() noexcept; + ``` +2. ``` + const_iterator begin() const noexcept; + ``` +3. ``` + const_iterator cbegin() const noexcept; + ``` -If the container is empty, the returned iterator will be equal to `end()`. + **Effects:** + Returns an iterator to the first element of the container. + If the container is empty, the returned iterator will be equal to `end()`. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

### end, cend -``` -iterator end() noexcept; -``` -``` -const_iterator end() const noexcept; -``` -``` -const_iterator cend() const noexcept; -``` - -**Effects:** -Returns an iterator to the element following the last element of the container. +1. ``` + iterator end() noexcept; + ``` +2. ``` + const_iterator end() const noexcept; + ``` +3. ``` + const_iterator cend() const noexcept; + ``` -This element acts as a placeholder; attempting to access it results in undefined behavior. + **Effects:** + Returns an iterator to the element following the last element of the container. + This element acts as a placeholder; attempting to access it results in undefined behavior. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

### rbegin, crbegin -``` -reverse_iterator rbegin() noexcept; -``` -``` -const_reverse_iterator rbegin() const noexcept; -``` -``` -const_reverse_iterator crbegin() const noexcept; -``` +1. ``` + reverse_iterator rbegin() noexcept; + ``` +2. ``` + const_reverse_iterator rbegin() const noexcept; + ``` +3. ``` + const_reverse_iterator crbegin() const noexcept; + ``` -**Effects:** -Returns a reverse iterator to the first element of the reversed container. -It corresponds to the last element of the non-reversed container. -If the container is empty, the returned iterator is equal to `rend()`. + **Effects:** + Returns a reverse iterator to the first element of the reversed container. + It corresponds to the last element of the non-reversed container. + If the container is empty, the returned iterator is equal to `rend()`. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

### rend, crend -``` -reverse_iterator rend() noexcept; -``` -``` -const_reverse_iterator rend() const noexcept; -``` -``` -const_reverse_iterator crend() const noexcept; -``` +1. ``` + reverse_iterator rend() noexcept; + ``` +2. ``` + const_reverse_iterator rend() const noexcept; + ``` +3. ``` + const_reverse_iterator crend() const noexcept; + ``` -**Effects:** -Returns a reverse iterator to the element following the last element of the reversed container. -It corresponds to the element preceding the first element of the non-reversed container. -This element acts as a placeholder, attempting to access it results in undefined behavior. + **Effects:** + Returns a reverse iterator to the element following the last element of the reversed container. + It corresponds to the element preceding the first element of the non-reversed container. + This element acts as a placeholder, attempting to access it results in undefined behavior. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

### nth -``` -iterator nth(size_type pos) noexcept; -``` -``` -const_iterator nth(size_type pos) const noexcept; -``` +1. ``` + iterator nth(size_type pos) noexcept; + ``` +2. ``` + const_iterator nth(size_type pos) const noexcept; + ``` -**Preconditions:** -`pos <= size()` + **Preconditions:** + `pos <= size()` -**Effects:** -Returns an iterator to the element at position `pos`. -If `pos == size()`, the returned iterator is equal to `end()`. + **Effects:** + Returns an iterator to the element at position `pos`. -**Complexity:** -Constant. + If `pos == size()`, the returned iterator is equal to `end()`. -

+ **Complexity:** + Constant. + +

### index_of -``` -size_type index_of(const_iterator pos) const noexcept; -``` +1. ``` + size_type index_of(const_iterator pos) const noexcept; + ``` -**Preconditions:** -`cbegin() <= pos && pos <= cend()` + **Preconditions:** + `cbegin() <= pos && pos <= cend()` -**Effects:** -Returns position of the element pointed by iterator `pos`, i.e. `std::distance(begin(), pos)`. + **Effects:** + Returns position of the element pointed by iterator `pos`, i.e. `std::distance(begin(), pos)`. -If `pos == end()`, the returned value is equal to `size()`. + If `pos == end()`, the returned value is equal to `size()`. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

### empty -``` -bool empty() const noexcept; -``` +1. ``` + bool empty() const noexcept; + ``` -**Effects:** -Returns `true` if the container has no elements, i.e. whether `begin() == end()`. + **Effects:** + Returns `true` if the container has no elements, i.e. whether `begin() == end()`. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

### size -``` -size_type size() const noexcept; -``` +1. ``` + size_type size() const noexcept; + ``` -**Effects:** -Returns the number of elements in the container, i.e. `std::distance(begin(), end())`. + **Effects:** + Returns the number of elements in the container, i.e. `std::distance(begin(), end())`. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

### max_size -``` -size_type max_size() const noexcept; -``` +1. ``` + size_type max_size() const noexcept; + ``` -**Effects:** -Returns the maximum number of elements the container is able to hold, i.e. `std::distance(begin(), end())` for the largest container. + **Effects:** + Returns the maximum number of elements the container is able to hold, i.e. `std::distance(begin(), end())` for the largest container. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

### capacity -``` -size_type capacity() const noexcept; -``` +1. ``` + size_type capacity() const noexcept; + ``` -**Effects:** -Returns the number of elements that the container has currently allocated space for. + **Effects:** + Returns the number of elements that the container has currently allocated space for. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

### available -``` -size_type available() const noexcept; -``` +1. ``` + size_type available() const noexcept; + ``` -**Effects:** -Returns the number of elements that can be inserted into the container without requiring allocation of additional memory. + **Effects:** + Returns the number of elements that can be inserted into the container without requiring allocation of additional memory. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

### reserve -``` -void reserve(size_type new_cap); -``` +1. ``` + void reserve(size_type new_cap); + ``` -**Effects:** -Tries to increase capacity by allocating additional memory. + **Effects:** + Tries to increase capacity by allocating additional memory. -If `new_cap > capacity()`, the function allocates memory for new storage of capacity equal to the value of `new_cap`, moves elements from old storage to new storage, and deallocates memory used by old storage. Otherwise, the function does nothing. + If `new_cap > capacity()`, the function allocates memory for new storage of capacity equal to the value of `new_cap`, moves elements from old storage to new storage, and deallocates memory used by old storage. Otherwise, the function does nothing. -This function does not change size of the container. + This function does not change size of the container. -If the capacity is changed, all iterators and all references to the elements are invalidated. Otherwise, no iterators or references are invalidated. + If the capacity is changed, all iterators and all references to the elements are invalidated. Otherwise, no iterators or references are invalidated. -**Complexity:** -Linear. + **Complexity:** + Linear. -**Exceptions:** + **Exceptions:** -* `Allocator::allocate` may throw. -* `T`'s move or copy constructor may throw. + * `Allocator::allocate` may throw. + * `T`'s move or copy constructor may throw. -If an exception is thrown: + If an exception is thrown: -* If type `T` has available `noexcept` move constructor: - * This function has no effects (strong exception guarantee). -* Else if type `T` has available copy constructor: - * This function has no effects (strong exception guarantee). -* Else if type `T` has available throwing move constructor: - * Container is changed but in valid state (basic exception guarantee). + * If type `T` has available `noexcept` move constructor: + * This function has no effects (strong exception guarantee). + * Else if type `T` has available copy constructor: + * This function has no effects (strong exception guarantee). + * Else if type `T` has available throwing move constructor: + * Container is changed but in valid state (basic exception guarantee). -

+

### shrink_to_fit -``` -void shrink_to_fit(); -``` +1. ``` + void shrink_to_fit(); + ``` -**Effects:** -Tries to reduce memory usage by freeing unused memory. + **Effects:** + Tries to reduce memory usage by freeing unused memory. -1. If `size() > N && size() < capacity()`, the function allocates memory for new storage of capacity equal to the value of `size()`, moves elements from old storage to new storage, and deallocates memory used by old storage. -2. If `size() <= N && N < capacity()`, the function sets new storage to be internal statically allocated array of capacity `N`, moves elements from old storage to new storage, and deallocates memory used by old storage. -3. Otherwise the function does nothing. + 1. If `size() > N && size() < capacity()`, the function allocates memory for new storage of capacity equal to the value of `size()`, moves elements from old storage to new storage, and deallocates memory used by old storage. -This function does not change size of the container. + 2. If `size() <= N && N < capacity()`, the function sets new storage to be internal statically allocated array of capacity `N`, moves elements from old storage to new storage, and deallocates memory used by old storage. -If the capacity is changed, all iterators and all references to the elements are invalidated. Otherwise, no iterators or references are invalidated. + 3. Otherwise the function does nothing. -**Complexity:** -Linear. + This function does not change size of the container. -**Exceptions:** + If the capacity is changed, all iterators and all references to the elements are invalidated. Otherwise, no iterators or references are invalidated. -* `Allocator::allocate` may throw. -* `T`'s move or copy constructor may throw. + **Complexity:** + Linear. -If an exception is thrown: + **Exceptions:** -* If type `T` has available `noexcept` move constructor: - * This function has no effects (strong exception guarantee). -* Else if type `T` has available copy constructor: - * This function has no effects (strong exception guarantee). -* Else if type `T` has available throwing move constructor: - * Container is changed but in valid state (basic exception guarantee). + * `Allocator::allocate` may throw. + * `T`'s move or copy constructor may throw. -

+ If an exception is thrown: + + * If type `T` has available `noexcept` move constructor: + * This function has no effects (strong exception guarantee). + * Else if type `T` has available copy constructor: + * This function has no effects (strong exception guarantee). + * Else if type `T` has available throwing move constructor: + * Container is changed but in valid state (basic exception guarantee). + +

### at -``` -reference at(size_type pos); -``` -``` -const_reference at(size_type pos) const; -``` +1. ``` + reference at(size_type pos); + ``` +2. ``` + const_reference at(size_type pos) const; + ``` -**Effects:** -Returns a reference to the element at specified location `pos`, with bounds checking. + **Effects:** + Returns a reference to the element at specified location `pos`, with bounds checking. -**Complexity:** -Constant. + **Complexity:** + Constant. -**Exceptions:** -`std::out_of_range` if `pos >= size()`. + **Exceptions:** + `std::out_of_range` if `pos >= size()`. -

+

### operator[] -``` -reference operator[](size_type pos) noexcept; -``` -``` -const_reference operator[](size_type pos) const noexcept; -``` +1. ``` + reference operator[](size_type pos) noexcept; + ``` +2. ``` + const_reference operator[](size_type pos) const noexcept; + ``` -**Preconditions:** -`pos < size()` + **Preconditions:** + `pos < size()` -**Effects:** -Returns a reference to the element at specified location pos. No bounds checking is performed. + **Effects:** + Returns a reference to the element at specified location pos. No bounds checking is performed. -**Note:** -This operator never inserts a new element into the container. + **Note:** + This operator never inserts a new element into the container. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

### front -``` -reference front() noexcept; -``` -``` -const_reference front() const noexcept; -``` +1. ``` + reference front() noexcept; + ``` +2. ``` + const_reference front() const noexcept; + ``` -**Preconditions:** -`!empty()` + **Preconditions:** + `!empty()` -**Effects:** -Returns a reference to the first element in the container. + **Effects:** + Returns a reference to the first element in the container. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

### back -``` -reference back() noexcept; -``` -``` -const_reference back() const noexcept; -``` +1. ``` + reference back() noexcept; + ``` +2. ``` + const_reference back() const noexcept; + ``` -**Preconditions:** -`!empty()` + **Preconditions:** + `!empty()` -**Effects:** -Returns a reference to the last element in the container. + **Effects:** + Returns a reference to the last element in the container. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

### data -``` -T* data() noexcept; -``` -``` -const T* data() const noexcept; -``` +1. ``` + T* data() noexcept; + ``` +2. ``` + const T* data() const noexcept; + ``` -**Effects:** -Returns pointer to the underlying array serving as element storage. The pointer is such that range `[data(), data() + size())` is always a valid range, even if the container is empty. `data()` is not dereferenceable if the container is empty. + **Effects:** + Returns pointer to the underlying array serving as element storage. The pointer is such that range `[data(), data() + size())` is always a valid range, even if the container is empty. `data()` is not dereferenceable if the container is empty. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

### clear -``` -void clear() noexcept; -``` +1. ``` + void clear() noexcept; + ``` -**Effects:** -Erases all elements from the container. -After this call, `size()` returns zero and `capacity()` remains unchanged. + **Effects:** + Erases all elements from the container. + After this call, `size()` returns zero and `capacity()` remains unchanged. -**Complexity:** -Linear in `size()`. + **Complexity:** + Linear in `size()`. -

+

### emplace -``` -template -iterator emplace(const_iterator pos, Args&&... args); -``` +1. ``` + template + iterator emplace(const_iterator pos, Args&&... args); + ``` -**Preconditions:** -`cbegin() <= pos && pos <= cend()` + **Preconditions:** + `cbegin() <= pos && pos <= cend()` -**Effects:** -Inserts a new element into the container at position `pos`. + **Effects:** + Inserts a new element into the container at position `pos`. -New element is constructed as `value_type(std::forward(args)...)`. + New element is constructed as `value_type(std::forward(args)...)`. -`args...` may directly or indirectly refer to a value in the container. + `args...` may directly or indirectly refer to a value in the container. -**Returns:** -Iterator to the inserted element. + **Returns:** + Iterator to the inserted element. -**Complexity:** -Constant plus linear in `std::distance(pos, end())`. + **Complexity:** + Constant plus linear in `std::distance(pos, end())`. -

+

### insert -``` -iterator insert(const_iterator pos, const T& value); -``` +1. ``` + iterator insert(const_iterator pos, const T& value); + ``` -**Preconditions:** -`cbegin() <= pos && pos <= cend()` + **Preconditions:** + `cbegin() <= pos && pos <= cend()` -**Effects:** -Inserts copy of `value` at position `pos`. + **Effects:** + Inserts copy of `value` at position `pos`. -**Returns:** -Iterator to the inserted element. + **Returns:** + Iterator to the inserted element. -**Complexity:** -Constant plus linear in `std::distance(pos, end())`. + **Complexity:** + Constant plus linear in `std::distance(pos, end())`. -

+

-``` -iterator insert(const_iterator pos, T&& value); -``` +2. ``` + iterator insert(const_iterator pos, T&& value); + ``` -**Preconditions:** -`cbegin() <= pos && pos <= cend()` + **Preconditions:** + `cbegin() <= pos && pos <= cend()` -**Effects:** -Inserts `value` using move semantics at position `pos`. + **Effects:** + Inserts `value` using move semantics at position `pos`. -**Returns:** -Iterator to the inserted element. + **Returns:** + Iterator to the inserted element. -**Complexity:** -Constant plus linear in `std::distance(pos, end())`. + **Complexity:** + Constant plus linear in `std::distance(pos, end())`. -

+

-``` -iterator insert(const_iterator pos, size_type n, const T& value); -``` +3. ``` + iterator insert(const_iterator pos, size_type n, const T& value); + ``` -**Preconditions:** -`cbegin() <= pos && pos <= cend()` + **Preconditions:** + `cbegin() <= pos && pos <= cend()` -**Effects:** -Inserts `n` copies of `value` before position `pos`. + **Effects:** + Inserts `n` copies of `value` before position `pos`. -**Returns:** -Iterator to the first element inserted, or `pos` if `n == 0`. + **Returns:** + Iterator to the first element inserted, or `pos` if `n == 0`. -**Complexity:** -Linear in `n` plus linear in `std::distance(pos, end())`. + **Complexity:** + Linear in `n` plus linear in `std::distance(pos, end())`. -

+

-``` -template -iterator insert(const_iterator pos, InputIt first, InputIt last); -``` +4. ``` + template + iterator insert(const_iterator pos, InputIt first, InputIt last); + ``` -**Preconditions:** -`cbegin() <= pos && pos <= cend()` + **Preconditions:** + `cbegin() <= pos && pos <= cend()` -**Effects:** -Inserts elements from the range `[first, last)` before position `pos`. + **Effects:** + Inserts elements from the range `[first, last)` before position `pos`. -**Note:** -This overload participates in overload resolution only if `InputIt` satisfies requirements of [*LegacyInputIterator*](https://en.cppreference.com/w/cpp/named_req/InputIterator). + **Note:** + This overload participates in overload resolution only if `InputIt` satisfies requirements of [*LegacyInputIterator*](https://en.cppreference.com/w/cpp/named_req/InputIterator). -**Note:** -The behavior is undefined if either `first` or `last` is an iterator into `*this`. + **Note:** + The behavior is undefined if either `first` or `last` is an iterator into `*this`. -**Returns:** -Iterator to the first element inserted, or `pos` if `first == last`. + **Returns:** + Iterator to the first element inserted, or `pos` if `first == last`. -**Complexity:** -Linear in `std::distance(first, last)` plus linear in `std::distance(pos, end())`. + **Complexity:** + Linear in `std::distance(first, last)` plus linear in `std::distance(pos, end())`. -

+

-``` -iterator insert(const_iterator pos, std::initializer_list ilist); -``` +5. ``` + iterator insert(const_iterator pos, std::initializer_list ilist); + ``` -**Preconditions:** -`cbegin() <= pos && pos <= cend()` + **Preconditions:** + `cbegin() <= pos && pos <= cend()` -**Effects:** -Inserts elements from initializer list `ilist` before position `pos`. + **Effects:** + Inserts elements from initializer list `ilist` before position `pos`. -**Returns:** -Iterator to the first element inserted, or `pos` if `ilist` is empty. + **Returns:** + Iterator to the first element inserted, or `pos` if `ilist` is empty. -**Complexity:** -Linear in `ilist.size()` plus linear in `std::distance(pos, end())`. + **Complexity:** + Linear in `ilist.size()` plus linear in `std::distance(pos, end())`. -

+

### emplace_back -``` -template -reference emplace_back(Args&&... args); -``` +1. ``` + template + reference emplace_back(Args&&... args); + ``` -**Effects:** -Inserts a new element at the end of container. + **Effects:** + Inserts a new element at the end of container. -New element is constructed as `value_type(std::forward(args)...)`. + New element is constructed as `value_type(std::forward(args)...)`. -**Returns:** -Reference to the inserted element. + **Returns:** + Reference to the inserted element. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

### push_back -``` -void push_back(const T& value); -``` +1. ``` + void push_back(const T& value); + ``` -**Effects:** -Inserts copy of `value` at the end of container. + **Effects:** + Inserts copy of `value` at the end of container. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

-``` -void push_back(T&& value); -``` +2. ``` + void push_back(T&& value); + ``` -**Effects:** -Inserts `value` using move semantics at the end of container. + **Effects:** + Inserts `value` using move semantics at the end of container. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

### pop_back -``` -void pop_back(); -``` +1. ``` + void pop_back(); + ``` -**Preconditions:** -`!empty()` + **Preconditions:** + `!empty()` -**Effects:** -Removes the last element of the container. + **Effects:** + Removes the last element of the container. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

### erase -``` -iterator erase(const_iterator pos); -``` +1. ``` + iterator erase(const_iterator pos); + ``` -**Preconditions:** -`cbegin() <= pos && pos < cend()` + **Preconditions:** + `cbegin() <= pos && pos < cend()` -**Effects:** -Removes the element at `pos`. + **Effects:** + Removes the element at `pos`. -**Returns:** -Iterator following the last removed element. + **Returns:** + Iterator following the last removed element. -If `pos` refers to the last element, then the `end()` iterator is returned. + If `pos` refers to the last element, then the `end()` iterator is returned. -

+

-``` -iterator erase(const_iterator first, const_iterator last); -``` +2. ``` + iterator erase(const_iterator first, const_iterator last); + ``` -**Preconditions:** -`cbegin() <= first && first <= last && last <= cend()` + **Preconditions:** + `cbegin() <= first && first <= last && last <= cend()` -**Effects:** -Removes the elements in the range `[first, last)`. + **Effects:** + Removes the elements in the range `[first, last)`. -**Returns:** -Iterator following the last removed element. + **Returns:** + Iterator following the last removed element. -If `last == end()` prior to removal, then the updated `end()` iterator is returned. + If `last == end()` prior to removal, then the updated `end()` iterator is returned. -If `[first, last)` is an empty range, then `last` is returned. + If `[first, last)` is an empty range, then `last` is returned. -

+

### resize -``` -void resize(size_type n); -``` +1. ``` + void resize(size_type n); + ``` -**Effects:** -Resizes the container to contain `n` elements. + **Effects:** + Resizes the container to contain `n` elements. -1. If the `size() > n`, the last `size() - n` elements are removed. -2. If the `size() < n`, additional default-constructed elements are inserted at the end of container. + 1. If the `size() > n`, the last `size() - n` elements are removed. + 2. If the `size() < n`, additional default-constructed elements are inserted at the end of container. -**Complexity:** -Linear in difference between `size()` and `n`. -Additional complexity possible due to reallocation if `n > capacity()`. + **Complexity:** + Linear in difference between `size()` and `n`. + Additional complexity possible due to reallocation if `n > capacity()`. -

+

-``` -void resize(size_type n, const T& value); -``` +2. ``` + void resize(size_type n, const T& value); + ``` -**Effects:** -Resizes the container to contain `n` elements. + **Effects:** + Resizes the container to contain `n` elements. -1. If the `size() > n`, the last `size() - n` elements are removed. -2. If the `size() < n`, additional copies of `value` are inserted at the end of container. + 1. If the `size() > n`, the last `size() - n` elements are removed. + 2. If the `size() < n`, additional copies of `value` are inserted at the end of container. -**Complexity:** -Linear in difference between `size()` and `n`. -Additional complexity possible due to reallocation if `n > capacity()`. + **Complexity:** + Linear in difference between `size()` and `n`. + Additional complexity possible due to reallocation if `n > capacity()`. -

+

### swap -``` -void swap(small_vector& other); -``` +1. ``` + void swap(small_vector& other); + ``` -**Preconditions:** -`allocator_traits::propagate_on_container_swap::value || get_allocator() == other.get_allocator()` + **Preconditions:** + `allocator_traits::propagate_on_container_swap::value || get_allocator() == other.get_allocator()` -**Effects:** -Exchanges the contents of the container with those of `other`. + **Effects:** + Exchanges the contents of the container with those of `other`. -**Complexity:** -Constant in the best case. Linear in `this->size()` plus linear in `other.size()` in the worst case. + **Complexity:** + Constant in the best case. Linear in `this->size()` plus linear in `other.size()` in the worst case. -

+

@@ -1153,217 +1155,217 @@ Constant in the best case. Linear in `this->size()` plus linear in `other.size() ### operator== -``` -template -bool operator== -( - const small_vector& x, - const small_vector& y -); -``` +1. ``` + template + bool operator== + ( + const small_vector& x, + const small_vector& y + ); + ``` -**Effects:** -Checks if the contents of `x` and `y` are equal. + **Effects:** + Checks if the contents of `x` and `y` are equal. -The contents of `x` and `y` are equal if the following conditions hold: -* `x.size() == y.size()` -* Each element in `x` compares equal with the element in `y` at the same position. + The contents of `x` and `y` are equal if the following conditions hold: + * `x.size() == y.size()` + * Each element in `x` compares equal with the element in `y` at the same position. -**Returns:** -`true` if the contents of the `x` and `y` are equal, `false` otherwise. + **Returns:** + `true` if the contents of the `x` and `y` are equal, `false` otherwise. -**Complexity:** -Constant if `x` and `y` are of different size, otherwise linear in the size of the container. + **Complexity:** + Constant if `x` and `y` are of different size, otherwise linear in the size of the container. -

+

### operator!= -``` -template -bool operator!= -( - const small_vector& x, - const small_vector& y -); -``` +1. ``` + template + bool operator!= + ( + const small_vector& x, + const small_vector& y + ); + ``` -**Effects:** -Checks if the contents of `x` and `y` are equal. + **Effects:** + Checks if the contents of `x` and `y` are equal. -For details see `operator==`. + For details see `operator==`. -**Returns:** -`true` if the contents of the `x` and `y` are not equal, `false` otherwise. + **Returns:** + `true` if the contents of the `x` and `y` are not equal, `false` otherwise. -**Complexity:** -Constant if `x` and `y` are of different size, otherwise linear in the size of the container. + **Complexity:** + Constant if `x` and `y` are of different size, otherwise linear in the size of the container. -

+

### operator< -``` -template -bool operator< -( - const small_vector& x, - const small_vector& y -); -``` +1. ``` + template + bool operator< + ( + const small_vector& x, + const small_vector& y + ); + ``` -**Effects:** -Compares the contents of `x` and `y` lexicographically. -The comparison is performed by a function `std::lexicographical_compare`. + **Effects:** + Compares the contents of `x` and `y` lexicographically. + The comparison is performed by a function `std::lexicographical_compare`. -**Returns:** -`true` if the contents of the `x` are lexicographically less than the contents of `y`, `false` otherwise. + **Returns:** + `true` if the contents of the `x` are lexicographically less than the contents of `y`, `false` otherwise. -**Complexity:** -Linear in the size of the container. + **Complexity:** + Linear in the size of the container. -

+

### operator> -``` -template -bool operator> -( - const small_vector& x, - const small_vector& y -); -``` +1. ``` + template + bool operator> + ( + const small_vector& x, + const small_vector& y + ); + ``` -**Effects:** -Compares the contents of `x` and `y` lexicographically. -The comparison is performed by a function `std::lexicographical_compare`. + **Effects:** + Compares the contents of `x` and `y` lexicographically. + The comparison is performed by a function `std::lexicographical_compare`. -**Returns:** -`true` if the contents of the `x` are lexicographically greater than the contents of `y`, `false` otherwise. + **Returns:** + `true` if the contents of the `x` are lexicographically greater than the contents of `y`, `false` otherwise. -**Complexity:** -Linear in the size of the container. + **Complexity:** + Linear in the size of the container. -

+

### operator<= -``` -template -bool operator<= -( - const small_vector& x, - const small_vector& y -); -``` +1. ``` + template + bool operator<= + ( + const small_vector& x, + const small_vector& y + ); + ``` -**Effects:** -Compares the contents of `x` and `y` lexicographically. -The comparison is performed by a function `std::lexicographical_compare`. + **Effects:** + Compares the contents of `x` and `y` lexicographically. + The comparison is performed by a function `std::lexicographical_compare`. -**Returns:** -`true` if the contents of the `x` are lexicographically less than or equal to the contents of `y`, `false` otherwise. + **Returns:** + `true` if the contents of the `x` are lexicographically less than or equal to the contents of `y`, `false` otherwise. -**Complexity:** -Linear in the size of the container. + **Complexity:** + Linear in the size of the container. -

+

### operator>= -``` -template -bool operator>= -( - const small_vector& x, - const small_vector& y -); -``` +1. ``` + template + bool operator>= + ( + const small_vector& x, + const small_vector& y + ); + ``` -**Effects:** -Compares the contents of `x` and `y` lexicographically. -The comparison is performed by a function `std::lexicographical_compare`. + **Effects:** + Compares the contents of `x` and `y` lexicographically. + The comparison is performed by a function `std::lexicographical_compare`. -**Returns:** -`true` if the contents of the `x` are lexicographically greater than or equal to the contents of `y`, `false` otherwise. + **Returns:** + `true` if the contents of the `x` are lexicographically greater than or equal to the contents of `y`, `false` otherwise. -**Complexity:** -Linear in the size of the container. + **Complexity:** + Linear in the size of the container. -

+

### swap -``` -template -void swap -( - small_vector& x, - small_vector& y -); -``` +1. ``` + template + void swap + ( + small_vector& x, + small_vector& y + ); + ``` -**Effects:** -Swaps the contents of `x` and `y`. Calls `x.swap(y)`. + **Effects:** + Swaps the contents of `x` and `y`. Calls `x.swap(y)`. -

+

### erase -``` -template -typename small_vector::size_type - erase(small_vector& c, const U& value); -``` +1. ``` + template + typename small_vector::size_type + erase(small_vector& c, const U& value); + ``` -**Effects:** -Erases all elements that compare equal to `value` from the container. + **Effects:** + Erases all elements that compare equal to `value` from the container. -**Returns:** -The number of erased elements. + **Returns:** + The number of erased elements. -**Complexity:** -Linear. + **Complexity:** + Linear. -

+

### erase_if -``` -template -typename small_vector::size_type - erase_if(small_vector& c, Predicate pred); -``` +1. ``` + template + typename small_vector::size_type + erase_if(small_vector& c, Predicate pred); + ``` -**Effects:** -Erases all elements that satisfy the predicate `pred` from the container. + **Effects:** + Erases all elements that satisfy the predicate `pred` from the container. -`pred` is unary predicate which returns `true` if the element should be removed. + `pred` is unary predicate which returns `true` if the element should be removed. -**Returns:** -The number of erased elements. + **Returns:** + The number of erased elements. -**Complexity:** -Linear. + **Complexity:** + Linear. -

+

diff --git a/doc/static_flat_map.md b/doc/static_flat_map.md index 0a9d912..2998c5a 100644 --- a/doc/static_flat_map.md +++ b/doc/static_flat_map.md @@ -174,1273 +174,1248 @@ static constexpr size_type static_capacity = N; ### (constructor) -``` -static_flat_map() noexcept(std::is_nothrow_default_constructible::value); -``` -``` -explicit static_flat_map(const Compare& comp) noexcept(std::is_nothrow_copy_constructible::value); -``` - -**Effects:** -Constructs an empty container. - -**Complexity:** -Constant. +1. ``` + static_flat_map() noexcept(std::is_nothrow_default_constructible::value); + ``` +2. ``` + explicit static_flat_map(const Compare& comp) noexcept(std::is_nothrow_copy_constructible::value); + ``` -

+ **Effects:** + Constructs an empty container. + **Complexity:** + Constant. +

-``` -template -static_flat_map(InputIt first, InputIt last); -``` -``` -template -static_flat_map(InputIt first, InputIt last, const Compare& comp); -``` -**Preconditions:** -`std::distance(first, last) <= capacity()` -**Effects:** -Constructs an empty container and inserts elements from the range `[first, last)`. +3. ``` + template + static_flat_map(InputIt first, InputIt last); + ``` +4. ``` + template + static_flat_map(InputIt first, InputIt last, const Compare& comp); + ``` -**Note:** -This overload participates in overload resolution only if `InputIt` satisfies requirements of [*LegacyInputIterator*](https://en.cppreference.com/w/cpp/named_req/InputIterator). + **Preconditions:** + `std::distance(first, last) <= capacity()` -**Note:** -The behavior is undefined if preconditions are not satisfied. + **Effects:** + Constructs an empty container and inserts elements from the range `[first, last)`. -**Complexity:** -Linear in `std::distance(first, last)`. + **Note:** + These overloads participate in overload resolution only if `InputIt` satisfies requirements of [*LegacyInputIterator*](https://en.cppreference.com/w/cpp/named_req/InputIterator). -

+ **Complexity:** + Linear in `std::distance(first, last)`. +

-``` -static_flat_map(std::initializer_list ilist); -``` -``` -static_flat_map(std::initializer_list ilist, const Compare& comp); -``` -**Preconditions:** -`ilist.size() <= capacity()` +5. ``` + static_flat_map(std::initializer_list ilist); + ``` +6. ``` + static_flat_map(std::initializer_list ilist, const Compare& comp); + ``` -**Effects:** -Constructs an empty container and inserts elements from the initializer list `ilist`. + **Preconditions:** + `ilist.size() <= capacity()` -**Note:** -The behavior is undefined if preconditions are not satisfied. + **Effects:** + Constructs an empty container and inserts elements from the initializer list `ilist`. -**Complexity:** -Linear in `ilist.size()`. + **Complexity:** + Linear in `ilist.size()`. -

+

-``` -static_flat_map(const static_flat_map& other); -``` +7. ``` + static_flat_map(const static_flat_map& other); + ``` -**Effects:** -Copy constructor. -Constructs the container with the copy of the contents of `other`. + **Effects:** + Copy constructor. + Constructs the container with the copy of the contents of `other`. -**Complexity:** -Linear in size. + **Complexity:** + Linear in size. -

+

-``` -static_flat_map(static_flat_map&& other); -``` +8. ``` + static_flat_map(static_flat_map&& other); + ``` -**Effects:** -Move constructor. -Constructs the container with the contents of `other` using move semantics. + **Effects:** + Move constructor. + Constructs the container with the contents of `other` using move semantics. -`other` is not guaranteed to be empty after the move. + `other` is not guaranteed to be empty after the move. -`other` is in a valid but unspecified state after the move. + `other` is in a valid but unspecified state after the move. -**Complexity:** -Linear in size. + **Complexity:** + Linear in size. -

+

### (destructor) -``` -~static_flat_map(); -``` +1. ``` + ~static_flat_map(); + ``` -**Effects:** -Destructs the container. The destructors of the elements are called and the used storage is deallocated. + **Effects:** + Destructs the container. The destructors of the elements are called and the used storage is deallocated. -**Complexity:** -Linear in size. + **Complexity:** + Linear in size. -

+

### operator= -``` -static_flat_map& operator=(const static_flat_map& other); -``` +1. ``` + static_flat_map& operator=(const static_flat_map& other); + ``` -**Effects:** -Copy assignment operator. -Replaces the contents with a copy of the contents of `other`. + **Effects:** + Copy assignment operator. + Replaces the contents with a copy of the contents of `other`. -**Returns:** -`*this()`. + **Returns:** + `*this()`. -**Complexity:** -Linear in size. + **Complexity:** + Linear in size. -

+

-``` -static_flat_map& operator=(static_flat_map&& other); -``` +2. ``` + static_flat_map& operator=(static_flat_map&& other); + ``` -**Effects:** -Move assignment operator. -Replaces the contents with those of `other` using move semantics. + **Effects:** + Move assignment operator. + Replaces the contents with those of `other` using move semantics. -`other` is not guaranteed to be empty after the move. + `other` is not guaranteed to be empty after the move. -`other` is in a valid but unspecified state after the move. + `other` is in a valid but unspecified state after the move. -**Returns:** -`*this()`. + **Returns:** + `*this()`. -**Complexity:** -Linear in size. + **Complexity:** + Linear in size. -

+

-``` -static_flat_map& operator=(std::initializer_list ilist); -``` +3. ``` + static_flat_map& operator=(std::initializer_list ilist); + ``` -**Preconditions:** -`ilist.size() <= capacity()` + **Preconditions:** + `ilist.size() <= capacity()` -**Effects:** -Replaces the contents with those identified by initializer list `ilist`. + **Effects:** + Replaces the contents with those identified by initializer list `ilist`. -**Note:** -The behavior is undefined if preconditions are not satisfied. + **Returns:** + `*this()`. -**Returns:** -`*this()`. + **Complexity:** + Linear in size. -**Complexity:** -Linear in size. - -

+

### key_comp -``` -key_compare key_comp() const; -``` +1. ``` + key_compare key_comp() const; + ``` -**Effects:** -Returns the function object that compares the keys, which is a copy of this container's constructor argument `comp`. + **Effects:** + Returns the function object that compares the keys, which is a copy of this container's constructor argument `comp`. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

### value_comp -``` -value_compare value_comp() const; -``` +1. ``` + value_compare value_comp() const; + ``` -**Effects:** -Returns a function object that compares objects of type `value_type`. + **Effects:** + Returns a function object that compares objects of type `value_type`. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

### begin, cbegin -``` -iterator begin() noexcept; -``` -``` -const_iterator begin() const noexcept; -``` -``` -const_iterator cbegin() const noexcept; -``` - -**Effects:** -Returns an iterator to the first element of the container. +1. ``` + iterator begin() noexcept; + ``` +2. ``` + const_iterator begin() const noexcept; + ``` +3. ``` + const_iterator cbegin() const noexcept; + ``` -If the container is empty, the returned iterator will be equal to `end()`. + **Effects:** + Returns an iterator to the first element of the container. + If the container is empty, the returned iterator will be equal to `end()`. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

### end, cend -``` -iterator end() noexcept; -``` -``` -const_iterator end() const noexcept; -``` -``` -const_iterator cend() const noexcept; -``` - -**Effects:** -Returns an iterator to the element following the last element of the container. +1. ``` + iterator end() noexcept; + ``` +2. ``` + const_iterator end() const noexcept; + ``` +3. ``` + const_iterator cend() const noexcept; + ``` -This element acts as a placeholder; attempting to access it results in undefined behavior. + **Effects:** + Returns an iterator to the element following the last element of the container. + This element acts as a placeholder; attempting to access it results in undefined behavior. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

### rbegin, crbegin -``` -reverse_iterator rbegin() noexcept; -``` -``` -const_reverse_iterator rbegin() const noexcept; -``` -``` -const_reverse_iterator crbegin() const noexcept; -``` +1. ``` + reverse_iterator rbegin() noexcept; + ``` +2. ``` + const_reverse_iterator rbegin() const noexcept; + ``` +3. ``` + const_reverse_iterator crbegin() const noexcept; + ``` -**Effects:** -Returns a reverse iterator to the first element of the reversed container. -It corresponds to the last element of the non-reversed container. -If the container is empty, the returned iterator is equal to `rend()`. + **Effects:** + Returns a reverse iterator to the first element of the reversed container. + It corresponds to the last element of the non-reversed container. + If the container is empty, the returned iterator is equal to `rend()`. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

### rend, crend -``` -reverse_iterator rend() noexcept; -``` -``` -const_reverse_iterator rend() const noexcept; -``` -``` -const_reverse_iterator crend() const noexcept; -``` +1. ``` + reverse_iterator rend() noexcept; + ``` +2. ``` + const_reverse_iterator rend() const noexcept; + ``` +3. ``` + const_reverse_iterator crend() const noexcept; + ``` -**Effects:** -Returns a reverse iterator to the element following the last element of the reversed container. -It corresponds to the element preceding the first element of the non-reversed container. -This element acts as a placeholder, attempting to access it results in undefined behavior. + **Effects:** + Returns a reverse iterator to the element following the last element of the reversed container. + It corresponds to the element preceding the first element of the non-reversed container. + This element acts as a placeholder, attempting to access it results in undefined behavior. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

### nth -``` -iterator nth(size_type pos) noexcept; -``` -``` -const_iterator nth(size_type pos) const noexcept; -``` +1. ``` + iterator nth(size_type pos) noexcept; + ``` +2. ``` + const_iterator nth(size_type pos) const noexcept; + ``` -**Preconditions:** -`pos <= size()` + **Preconditions:** + `pos <= size()` -**Effects:** -Returns an iterator to the element at position `pos`. -If `pos == size()`, the returned iterator is equal to `end()`. + **Effects:** + Returns an iterator to the element at position `pos`. -**Complexity:** -Constant. + If `pos == size()`, the returned iterator is equal to `end()`. -

+ **Complexity:** + Constant. + +

### index_of -``` -size_type index_of(const_iterator pos) const noexcept; -``` +1. ``` + size_type index_of(const_iterator pos) const noexcept; + ``` -**Preconditions:** -`cbegin() <= pos && pos <= cend()` + **Preconditions:** + `cbegin() <= pos && pos <= cend()` -**Effects:** -Returns position of the element pointed by iterator `pos`, i.e. `std::distance(begin(), pos)`. + **Effects:** + Returns position of the element pointed by iterator `pos`, i.e. `std::distance(begin(), pos)`. -If `pos == end()`, the returned value is equal to `size()`. + If `pos == end()`, the returned value is equal to `size()`. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

### empty -``` -bool empty() const noexcept; -``` +1. ``` + bool empty() const noexcept; + ``` -**Effects:** -Returns `true` if the container has no elements, i.e. whether `begin() == end()`. + **Effects:** + Returns `true` if the container has no elements, i.e. whether `begin() == end()`. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

### full -``` -bool full() const noexcept; -``` +1. ``` + bool full() const noexcept; + ``` -**Effects:** -Returns `true` if the container is full, i.e. whether `size() == capacity()`. + **Effects:** + Returns `true` if the container is full, i.e. whether `size() == capacity()`. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

### size -``` -size_type size() const noexcept; -``` +1. ``` + size_type size() const noexcept; + ``` -**Effects:** -Returns the number of elements in the container, i.e. `std::distance(begin(), end())`. + **Effects:** + Returns the number of elements in the container, i.e. `std::distance(begin(), end())`. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

### max_size -``` -static constexpr size_type max_size() const noexcept; -``` +1. ``` + static constexpr size_type max_size() const noexcept; + ``` -**Effects:** -Returns the maximum number of elements the container is able to hold, i.e. returns `N`. + **Effects:** + Returns the maximum number of elements the container is able to hold, i.e. `N`. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

### capacity -``` -static constexpr size_type capacity() const noexcept; -``` +1. ``` + static constexpr size_type capacity() const noexcept; + ``` -**Effects:** -Returns the maximum number of elements the container is able to hold, i.e. returns `N`. + **Effects:** + Returns the maximum number of elements the container is able to hold, i.e. `N`. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

### available -``` -size_type available() const noexcept; -``` +1. ``` + size_type available() const noexcept; + ``` -**Effects:** -Returns the number of elements that can be inserted into the container, i.e. returns `capacity() - size()`. + **Effects:** + Returns the number of elements that can be inserted into the container, i.e. `capacity() - size()`. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

### clear -``` -void clear() noexcept; -``` +1. ``` + void clear() noexcept; + ``` -**Effects:** -Erases all elements from the container. -After this call, `size()` returns zero and `capacity()` remains unchanged. + **Effects:** + Erases all elements from the container. + After this call, `size()` returns zero and `capacity()` remains unchanged. -**Complexity:** -Linear in `size()`. + **Complexity:** + Linear in `size()`. -

+

### emplace -``` -template -std::pair emplace(Args&&... args); -``` - -**Preconditions:** -`!full()` +1. ``` + template + std::pair emplace(Args&&... args); + ``` -**Effects:** -Inserts a new element into the container only if the container does not already contain an element with an equivalent key. + **Preconditions:** + `!full()` -New element is constructed as `value_type(std::forward(args)...)`. + **Effects:** + Inserts new element into the container if the container doesn't already contain an element with an equivalent key. -The element may be constructed even if there already is an element with the key in the container, in which case the newly constructed element will be destroyed immediately. + New element is constructed as `value_type(std::forward(args)...)`. -**Note:** -The behavior is undefined if preconditions are not satisfied. + The element may be constructed even if there already is an element with the key in the container, in which case the newly constructed element will be destroyed immediately. -**Returns:** -Pair consisting of an iterator to the inserted element, or the already-existing element if no insertion happened, and a `bool` denoting whether the insertion took place (`true` if insertion happened, `false` if it did not). + **Returns:** + The iterator component points to the inserted element or to the already existing element. The `bool` component is `true` if insertion happened and `false` if it did not. -

+

### emplace_hint -``` -template -iterator emplace_hint(const_iterator hint, Args&&... args); -``` - -**Preconditions:** -1. `!full()` -2. `cbegin() <= hint && hint <= cend()` +1. ``` + template + iterator emplace_hint(const_iterator hint, Args&&... args); + ``` -**Effects:** -Inserts a new element into the container only if the container does not already contain an element with an equivalent key. + **Preconditions:** + 1. `!full()` + 2. `cbegin() <= hint && hint <= cend()` -New element is constructed as `value_type(std::forward(args)...)`. + **Effects:** + Inserts new element into the container if the container doesn't already contain an element with an equivalent key. -The element may be constructed even if there already is an element with the key in the container, in which case the newly constructed element will be destroyed immediately. + New element is constructed as `value_type(std::forward(args)...)`. -Iterator `hint` is used as a suggestion where to start to search insert position. + The element may be constructed even if there already is an element with the key in the container, in which case the newly constructed element will be destroyed immediately. -**Note:** -The behavior is undefined if preconditions are not satisfied. + Iterator `hint` is used as a suggestion where to start to search insert position. -**Returns:** -Iterator to the inserted element or to the already existing element. + **Returns:** + Iterator to the inserted element or to the already existing element. -

+

### insert -``` -std::pair insert(const value_type& value); -``` - -**Preconditions:** -`!full()` +1. ``` + std::pair insert(const value_type& value); + ``` -**Effects:** -Inserts copy of `value` only if the container does not already contain an element with an key equivalent to the key of `value`. + **Preconditions:** + `!full()` -**Note:** -The behavior is undefined if preconditions are not satisfied. + **Effects:** + Inserts copy of `value` if the container doesn't already contain an element with an equivalent key. -**Returns:** -Pair consisting of an iterator to the inserted element, or the already-existing element if no insertion happened, and a `bool` denoting whether the insertion took place (`true` if insertion happened, `false` if it did not). + **Returns:** + The iterator component points to the inserted element or to the already existing element. The `bool` component is `true` if insertion happened and `false` if it did not. -

+

-``` -std::pair insert(value_type&& value); -``` +2. ``` + std::pair insert(value_type&& value); + ``` -**Preconditions:** -`!full()` + **Preconditions:** + `!full()` -**Effects:** -Inserts `value` using move semantics only if the container does not already contain an element with an key equivalent to the key of `value`. + **Effects:** + Inserts `value` using move semantics if the container doesn't already contain an element with an equivalent key. -**Note:** -The behavior is undefined if preconditions are not satisfied. + **Returns:** + The iterator component points to the inserted element or to the already existing element. The `bool` component is `true` if insertion happened and `false` if it did not. -**Returns:** -Pair consisting of an iterator to the inserted element, or the already-existing element if no insertion happened, and a `bool` denoting whether the insertion took place (`true` if insertion happened, `false` if it did not). +

-

+3. ``` + template + std::pair insert(P&& value); + ``` -``` -template -std::pair insert(P&& value); -``` + **Preconditions:** + `!full()` -**Preconditions:** -`!full()` + **Effects:** + Inserts new element into the container if the container doesn't already contain an element with an equivalent key. -**Effects:** -Inserts a new element into the container only if the container does not already contain an element with an equivalent key. + New element is constructed as `value_type(std::forward

(value))`. -New element is constructed as `value_type(std::forward

(value))`. + **Note:** + This overload participates in overload resolution only if `std::is_constructible::value` is `true`. -**Note:** -This overload participates in overload resolution only if `std::is_constructible::value` is `true`. + **Returns:** + The iterator component points to the inserted element or to the already existing element. The `bool` component is `true` if insertion happened and `false` if it did not. -**Note:** -The behavior is undefined if preconditions are not satisfied. +

-**Returns:** -Pair consisting of an iterator to the inserted element, or the already-existing element if no insertion happened, and a `bool` denoting whether the insertion took place (`true` if insertion happened, `false` if it did not). -

+4. ``` + iterator insert(const_iterator hint, const value_type& value); + ``` + **Preconditions:** + 1. `!full()` + 2. `cbegin() <= hint && hint <= cend()` -``` -iterator insert(const_iterator hint, const value_type& value); -``` + **Effects:** + Inserts copy of `value` if the container doesn't already contain an element with an equivalent key. -**Preconditions:** -1. `!full()` -2. `cbegin() <= hint && hint <= cend()` + Iterator `hint` is used as a suggestion where to start to search insert position. -**Effects:** -Inserts copy of `value` only if the container does not already contain an element with an key equivalent to the key of `value`. + **Returns:** + Iterator to the inserted element or to the already existing element. -Iterator `hint` is used as a suggestion where to start to search insert position. +

-**Note:** -The behavior is undefined if preconditions are not satisfied. -**Returns:** -Iterator to the inserted element or to the already existing element. -

+5. ``` + iterator insert(const_iterator hint, value_type&& value); + ``` + **Preconditions:** + 1. `!full()` + 2. `cbegin() <= hint && hint <= cend()` + **Effects:** + Inserts `value` using move semantics if the container doesn't already contain an element with an equivalent key. -``` -iterator insert(const_iterator hint, value_type&& value); -``` + Iterator `hint` is used as a suggestion where to start to search insert position. -**Preconditions:** -1. `!full()` -2. `cbegin() <= hint && hint <= cend()` + **Returns:** + Iterator to the inserted element or to the already existing element. -**Effects:** -Inserts `value` using move semantics only if the container does not already contain an element with an key equivalent to the key of `value`. +

-Iterator `hint` is used as a suggestion where to start to search insert position. -**Note:** -The behavior is undefined if preconditions are not satisfied. -**Returns:** -Iterator to the inserted element or to the already existing element. +6. ``` + template + iterator insert(const_iterator hint, P&& value); + ``` -

+ **Preconditions:** + 1. `!full()` + 2. `cbegin() <= hint && hint <= cend()` + **Effects:** + Inserts new element into the container if the container doesn't already contain an element with an equivalent key. + New element is constructed as `value_type(std::forward

(value))`. -``` -template -iterator insert(const_iterator hint, P&& value); -``` + Iterator `hint` is used as a suggestion where to start to search insert position. -**Preconditions:** -1. `!full()` -2. `cbegin() <= hint && hint <= cend()` + **Note:** + This overload participates in overload resolution only if `std::is_constructible::value` is `true`. -**Effects:** -Inserts a new element into the container only if the container does not already contain an element with an equivalent key. + **Returns:** + Iterator to the inserted element or to the already existing element. -New element is constructed as `value_type(std::forward

(value))`. +

-Iterator `hint` is used as a suggestion where to start to search insert position. -**Note:** -This overload participates in overload resolution only if `std::is_constructible::value` is `true`. -**Note:** -The behavior is undefined if preconditions are not satisfied. +7. ``` + template + void insert(InputIt first, InputIt last); + ``` -**Returns:** -Iterator to the inserted element or to the already existing element. + **Preconditions:** + `std::distance(first, last) <= available()` -

+ **Effects:** + Inserts elements from range `[first, last)`. + The call to this function is equivalent to: + ``` + while (first != last) + { + insert(*first); + ++first; + } + ``` + **Note:** + This overload participates in overload resolution only if `InputIt` satisfies requirements of [*LegacyInputIterator*](https://en.cppreference.com/w/cpp/named_req/InputIterator). -``` -template -void insert(InputIt first, InputIt last); -``` +

-**Preconditions:** -`std::distance(first, last) <= available()` -**Effects:** -Inserts elements from range `[first, last)`. -The call to this function is equivalent to: -``` -while (first != last) -{ - insert(*first); - ++first; -} -``` +8. ``` + void insert(std::initializer_list ilist); + ``` -**Note:** -This overload participates in overload resolution only if `InputIt` satisfies requirements of [*LegacyInputIterator*](https://en.cppreference.com/w/cpp/named_req/InputIterator). + **Preconditions:** + `ilist.size() <= available()` -**Note:** -The behavior is undefined if preconditions are not satisfied. + **Effects:** + Inserts elements from initializer list `ilist`. -

+ The call to this function is equivalent to `insert(ilist.begin(), ilist.end())`. +

-``` -void insert(std::initializer_list ilist); -``` -**Preconditions:** -`ilist.size() <= available()` +### insert_or_assign -**Effects:** -Inserts elements from initializer list `ilist`. +1. ``` + template + std::pair insert_or_assign(const Key& key, M&& obj); + ``` +2. ``` + template + std::pair insert_or_assign(Key&& key, M&& obj); + ``` +3. ``` + template + std::pair insert_or_assign(K&& key, M&& obj); + ``` -The call to this function is equivalent to: -``` -insert(ilist.begin(), ilist.end()); -``` + **Effects:** + If a key equivalent to `key` already exists in the container, assigns `std::forward(obj)` to the mapped type corresponding to the key `key`. If the key does not exist, inserts the new element. -**Note:** -The behavior is undefined if preconditions are not satisfied. + * **Overload (1):** New element is constructed as -

+ ``` + value_type( std::piecewise_construct, + std::forward_as_tuple(key), + std::forward_as_tuple(std::forward(obj)) ) + ``` + **Note:** This overload participates in overload resolution only if `std::is_assignable_v` is `true`. + * **Overload (2):** New element is constructed as -### insert_or_assign + ``` + value_type( std::piecewise_construct, + std::forward_as_tuple(std::move(key)), + std::forward_as_tuple(std::forward(obj)) ) + ``` -``` -template -std::pair insert_or_assign(const Key& key, M&& obj); -``` -``` -template -std::pair insert_or_assign(Key&& key, M&& obj); -``` + **Note:** This overload participates in overload resolution only if `std::is_assignable_v` is `true`. -**Preconditions:** -`!full()` + * **Overload (3):** New element is constructed as -**Effects:** -If a key equivalent to `key` already exists in the container, assigns `std::forward(obj)` to the mapped type corresponding to the key `key`. If the key does not exist, inserts the new element. + ``` + value_type( std::piecewise_construct, + std::forward_as_tuple(std::forward(key)), + std::forward_as_tuple(std::forward(obj)) ) + ``` -* If the first overload is used, the new element is constructed as - ``` - value_type( std::piecewise_construct, - std::forward_as_tuple(key), - std::forward_as_tuple(std::forward(obj)) ) - ``` -* If the second overload is used, the new element is constructed as - ``` - value_type( std::piecewise_construct, - std::forward_as_tuple(std::move(key)), - std::forward_as_tuple(std::forward(obj)) ) - ``` + **Note:** This overload participates in overload resolution only if all following conditions are satisfied: + 1. `Compare::is_transparent` exists and is a valid type. It allows calling this function without constructing an instance of `Key`. + 2. `std::is_assignable_v` is `true`. -**Note:** -This overload participates in overload resolution only if `std::is_assignable_v` is `true`. + **Returns:** + The iterator component points to the inserted element or to the updated element. The `bool` component is `true` if insertion took place and `false` if assignment took place. -**Note:** -The behavior is undefined if preconditions are not satisfied. +

-**Returns:** -A pair of iterator and `bool`: -* The iterator component points at the element that was inserted or updated. -* The `bool` component is `true` if the insertion took place and `false` if the assignment took place. -

+4. ``` + template + iterator insert_or_assign(const_iterator hint, const Key& key, M&& obj); + ``` +5. ``` + template + iterator insert_or_assign(const_iterator hint, Key&& key, M&& obj); + ``` +6. ``` + template + iterator insert_or_assign(const_iterator hint, K&& key, M&& obj); + ``` + **Preconditions:** + `cbegin() <= hint && hint <= cend()` -``` -template -iterator insert_or_assign(const_iterator hint, const Key& key, M&& obj); -``` -``` -template -iterator insert_or_assign(const_iterator hint, Key&& key, M&& obj); -``` + **Effects:** + If a key equivalent to `key` already exists in the container, assigns `std::forward(obj)` to the mapped type corresponding to the key `key`. If the key does not exist, inserts the new element. -**Preconditions:** -1. `!full()` -2. `cbegin() <= hint && hint <= cend()` + Iterator `hint` is used as a suggestion where to start to search insert position. -**Effects:** -Same as `insert_or_assign` overloads that do not take `hint`. + * **Overload (4):** New element is constructed as -Iterator `hint` is used as a suggestion where to start to search insert position. + ``` + value_type( std::piecewise_construct, + std::forward_as_tuple(key), + std::forward_as_tuple(std::forward(obj)) ) + ``` -**Note:** -This overload participates in overload resolution only if `std::is_assignable_v` is `true`. + **Note:** This overload participates in overload resolution only if `std::is_assignable_v` is `true`. -**Note:** -The behavior is undefined if preconditions are not satisfied. + * **Overload (5):** New element is constructed as -**Returns:** -Iterator to the element that was inserted or updated. + ``` + value_type( std::piecewise_construct, + std::forward_as_tuple(std::move(key)), + std::forward_as_tuple(std::forward(obj)) ) + ``` -

+ **Note:** This overload participates in overload resolution only if `std::is_assignable_v` is `true`. + * **Overload (6):** New element is constructed as + ``` + value_type( std::piecewise_construct, + std::forward_as_tuple(std::forward(key)), + std::forward_as_tuple(std::forward(obj)) ) + ``` -### try_emplace + **Note:** This overload participates in overload resolution only if all following conditions are satisfied: + 1. `Compare::is_transparent` exists and is a valid type. It allows calling this function without constructing an instance of `Key`. + 2. `std::is_assignable_v` is `true`. -``` -template -std::pair try_emplace(const Key& key, Args&&... args); -``` -``` -template -std::pair try_emplace(Key&& key, Args&&... args); -``` + **Returns:** + Iterator to the element that was inserted or updated. -**Preconditions:** -`!full()` - -**Effects:** -If a key equivalent to `key` already exists in the container, does nothing. Otherwise, behaves like `emplace`. - -* If the first overload is used, the new element is constructed as - ``` - value_type( std::piecewise_construct, - std::forward_as_tuple(key), - std::forward_as_tuple(std::forward(args)...) ) - ``` -* If the second overload is used, the new element is constructed as - ``` - value_type( std::piecewise_construct, - std::forward_as_tuple(std::move(key)), - std::forward_as_tuple(std::forward(args)...) ) - ``` - -**Note:** -The behavior is undefined if preconditions are not satisfied. - -**Returns:** -A pair of iterator and `bool`: -* The iterator component points at the inserted element or to the already existing element. -* The `bool` component is `true` if insertion happened and `false` if it did not. +

-

+### try_emplace -``` -template -iterator try_emplace(const_iterator hint, const Key& key, Args&&... args); -``` -``` -template -iterator try_emplace(const_iterator hint, Key&& key, Args&&... args); -``` +1. ``` + template + std::pair try_emplace(const Key& key, Args&&... args); + ``` +2. ``` + template + std::pair try_emplace(Key&& key, Args&&... args); + ``` +3. ``` + template + std::pair try_emplace(K&& key, Args&&... args); + ``` -**Preconditions:** -1. `!full()` -2. `cbegin() <= hint && hint <= cend()` + **Preconditions:** + `!full()` -**Effects:** -Same as `try_emplace` overloads that do not take `hint`. + **Effects:** + If a key equivalent to `key` already exists in the container, does nothing. + Otherwise, inserts a new element into the container. -Iterator `hint` is used as a suggestion where to start to search insert position. + * **Overload (1):** Behaves like `emplace` except that the element is constructed as -**Note:** -The behavior is undefined if preconditions are not satisfied. + ``` + value_type( std::piecewise_construct, + std::forward_as_tuple(key), + std::forward_as_tuple(std::forward(args)...) ) + ``` -**Returns:** -Iterator to the inserted element or to the already existing element. + * **Overload (2):** Behaves like `emplace` except that the element is constructed as -

+ ``` + value_type( std::piecewise_construct, + std::forward_as_tuple(std::move(key)), + std::forward_as_tuple(std::forward(args)...) ) + ``` + * **Overload (3):** Behaves like `emplace` except that the element is constructed as + ``` + value_type( std::piecewise_construct, + std::forward_as_tuple(std::forward(key)), + std::forward_as_tuple(std::forward(args)...) ) + ``` -### erase + **Note:** This overload participates in overload resolution only if all following conditions are satisfied: + 1. `Compare::is_transparent` exists and is a valid type. It allows calling this function without constructing an instance of `Key`. + 2. `std::is_convertible_v` is `false`. + 3. `std::is_convertible_v` is `false`. -``` -iterator erase(iterator pos); -``` -``` -iterator erase(const_iterator pos); -``` + **Returns:** + The iterator component points to the inserted element or to the already existing element. The `bool` component is `true` if insertion happened and `false` if it did not. -**Preconditions:** -`cbegin() <= pos && pos < cend()` +

-**Effects:** -Removes the element at `pos`. -**Note:** -The behavior is undefined if preconditions are not satisfied. -**Returns:** -Iterator following the last removed element. +4. ``` + template + iterator try_emplace(const_iterator hint, const Key& key, Args&&... args); + ``` +5. ``` + template + iterator try_emplace(const_iterator hint, Key&& key, Args&&... args); + ``` +6. ``` + template + iterator try_emplace(const_iterator hint, K&& key, Args&&... args); + ``` -

+ **Preconditions:** + 1. `!full()` + 2. `cbegin() <= hint && hint <= cend()` + **Effects:** + If a key equivalent to `key` already exists in the container, does nothing. + Otherwise, inserts a new element into the container. + Iterator `hint` is used as a suggestion where to start to search insert position. -``` -iterator erase(const_iterator first, const_iterator last); -``` + * **Overload (4):** Behaves like `emplace_hint` except that the element is constructed as -**Preconditions:** -`cbegin() <= first && first <= last && last <= cend()` + ``` + value_type( std::piecewise_construct, + std::forward_as_tuple(key), + std::forward_as_tuple(std::forward(args)...) ) + ``` -**Effects:** -Removes the elements in the range `[first, last)`. + * **Overload (5):** Behaves like `emplace_hint` except that the element is constructed as -**Note:** -The behavior is undefined if preconditions are not satisfied. + ``` + value_type( std::piecewise_construct, + std::forward_as_tuple(std::move(key)), + std::forward_as_tuple(std::forward(args)...) ) + ``` -**Returns:** -Iterator following the last removed element. + * **Overload (6):** Behaves like `emplace_hint` except that the element is constructed as -

+ ``` + value_type( std::piecewise_construct, + std::forward_as_tuple(std::forward(key)), + std::forward_as_tuple(std::forward(args)...) ) + ``` + **Note:** This overload participates in overload resolution only if `Compare::is_transparent` exists and is a valid type. It allows calling this function without constructing an instance of `Key`. + **Returns:** + Iterator to the inserted element or to the already existing element. -``` -size_type erase(const Key& key); -``` +

-**Effects:** -Removes the element (if one exists) with the key equivalent to `key`. -**Returns:** -Number of elements removed (0 or 1). -

+### erase +1. ``` + iterator erase(iterator pos); + ``` +2. ``` + iterator erase(const_iterator pos); + ``` + **Preconditions:** + `cbegin() <= pos && pos < cend()` -``` -template -size_type erase(K&& x); -``` + **Effects:** + Removes the element at `pos`. -**Effects:** -Removes the element (if one exists) with key that compares equivalent to the value `x`. + **Returns:** + Iterator following the last removed element. -**Note:** -This overload participates in overload resolution only if `Compare::is_transparent` exists and is a valid type. It allows calling this function without constructing an instance of `Key`. +

-**Returns:** -Number of elements removed (0 or 1). -

+3. ``` + iterator erase(const_iterator first, const_iterator last); + ``` + **Preconditions:** + `cbegin() <= first && first <= last && last <= cend()` -### swap + **Effects:** + Removes the elements in the range `[first, last)`. -``` -void swap(static_flat_map& other); -``` + **Returns:** + Iterator following the last removed element. -**Effects:** -Exchanges the contents of the container with those of `other`. +

-**Complexity:** -Linear in size. -

+4. ``` + size_type erase(const Key& key); + ``` +5. ``` + template + size_type erase(K&& x); + ``` + **Effects:** + Removes the element (if one exists) with the key equivalent to `key` or `x`. -### lower_bound + **Note:** + Overload (5) participates in overload resolution only if `Compare::is_transparent` exists and is a valid type. It allows calling this function without constructing an instance of `Key`. -``` -iterator lower_bound(const Key& key); -``` -``` -const_iterator lower_bound(const Key& key) const; -``` + **Returns:** + Number of elements removed (0 or 1). -**Effects:** -Returns an iterator pointing to the first element with key that is not less than `key`, or `end()` if such an element is not found. +

-**Complexity:** -Logarithmic in `size()`. -

+### swap +1. ``` + void swap(static_flat_map& other); + ``` -``` -template -iterator lower_bound(const K& x); -``` -``` -template -const_iterator lower_bound(const K& x) const; -``` + **Effects:** + Exchanges the contents of the container with those of `other`. -**Effects:** -Returns an iterator pointing to the first element with key that compares not less to the value `x`, or `end()` if such an element is not found. + **Complexity:** + Linear in size. -**Note:** -This overload participates in overload resolution only if `Compare::is_transparent` exists and is a valid type. It allows calling this function without constructing an instance of `Key`. +

-**Complexity:** -Logarithmic in `size()`. -

+### lower_bound +1. ``` + iterator lower_bound(const Key& key); + ``` +2. ``` + const_iterator lower_bound(const Key& key) const; + ``` +3. ``` + template + iterator lower_bound(const K& x); + ``` +4. ``` + template + const_iterator lower_bound(const K& x) const; + ``` -### upper_bound + **Effects:** + Returns an iterator pointing to the first element with key that compares **not less than** `key` or `x`. Returns `end()` if no such element is found. -``` -iterator upper_bound(const Key& key); -``` -``` -const_iterator upper_bound(const Key& key) const; -``` + **Note:** + Overloads (3) and (4) participate in overload resolution only if `Compare::is_transparent` exists and is a valid type. It allows calling these functions without constructing an instance of `Key`. -**Effects:** -Returns an iterator pointing to the first element with key that is greater than `key`, or `end()` if such an element is not found. + **Complexity:** + Logarithmic in `size()`. -**Complexity:** -Logarithmic in `size()`. +

-

+### upper_bound -``` -template -iterator upper_bound(const K& x); -``` -``` -template -const_iterator upper_bound(const K& x) const; -``` +1. ``` + iterator upper_bound(const Key& key); + ``` +2. ``` + const_iterator upper_bound(const Key& key) const; + ``` +3. ``` + template + iterator upper_bound(const K& x); + ``` +4. ``` + template + const_iterator upper_bound(const K& x) const; + ``` -**Effects:** -Returns an iterator pointing to the first element with key that compares greater to the value `x`, or `end()` if such an element is not found. + **Effects:** + Returns an iterator pointing to the first element with key that compares **greater than** `key` or `x`. Returns `end()` if no such element is found. -**Note:** -This overload participates in overload resolution only if `Compare::is_transparent` exists and is a valid type. It allows calling this function without constructing an instance of `Key`. + **Note:** + Overloads (3) and (4) participate in overload resolution only if `Compare::is_transparent` exists and is a valid type. It allows calling these functions without constructing an instance of `Key`. -**Complexity:** -Logarithmic in `size()`. + **Complexity:** + Logarithmic in `size()`. -

+

### equal_range -``` -std::pair equal_range(const Key& key); -``` -``` -std::pair equal_range(const Key& key) const; -``` - -**Effects:** -Returns a range containing all elements with the key that is equal to `key`: -* The first iterator in pair points to the first element that is not less than `key`, or `end()` if such an element does not exist. -* The second iterator in pair points to the first element that is greater that `key`, or `end()` is such an element does not exist. - -**Complexity:** -Logarithmic in `size()`. - -

- - - -``` -template -std::pair equal_range(const K& x); -``` -``` -template -std::pair equal_range(const K& x) const; -``` +1. ``` + std::pair equal_range(const Key& key); + ``` +2. ``` + std::pair equal_range(const Key& key) const; + ``` +3. ``` + template + std::pair equal_range(const K& x); + ``` +4. ``` + template + std::pair equal_range(const K& x) const; + ``` -**Effects:** -Returns a range containing all elements with the key that compares equal to the value `x`: -* The first iterator in pair points to the first element that compares not less to the value `x`, or `end()` if such an element does not exist. -* The second iterator in pair points to the first element that compares greater to the value `x`, or `end()` is such an element does not exist. + **Effects:** + Returns a range containing all elements with key that compares equivalent to `key` or `x`. + * The first iterator in pair points to the first element that compares **not less than** `key` or `x`. It is equal to `end()` if no such element is found. + * The second iterator in pair points to the first element that compares **greater than** `key` or `x`. It is equal to `end()` is no such element is found. -**Note:** -This overload participates in overload resolution only if `Compare::is_transparent` exists and is a valid type. It allows calling this function without constructing an instance of `Key`. + **Note:** + Overloads (3) and (4) participate in overload resolution only if `Compare::is_transparent` exists and is a valid type. It allows calling these functions without constructing an instance of `Key`. -**Complexity:** -Logarithmic in `size()`. + **Complexity:** + Logarithmic in `size()`. -

+

### find -``` -iterator find(const Key& key); -``` -``` -const_iterator find(const Key& key) const; -``` - -**Effects:** -Returns an iterator to an element with key equivalent to `key`, or `end()` if such an element is not found. - -**Complexity:** -Logarithmic in `size()`. - -

- - - -``` -template -iterator find(const K& x); -``` -``` -template -const_iterator find(const K& x) const; -``` +1. ``` + iterator find(const Key& key); + ``` +2. ``` + const_iterator find(const Key& key) const; + ``` +3. ``` + template + iterator find(const K& x); + ``` +4. ``` + template + const_iterator find(const K& x) const; + ``` -**Effects:** -Returns an iterator to an element with key that compares equivalent to `x`, or `end()` if such an element is not found. + **Effects:** + Returns an iterator pointing to the element with key equivalent to `key` or `x`. Returns `end()` if no such element is found. -**Note:** -This overload participates in overload resolution only if `Compare::is_transparent` exists and is a valid type. It allows calling this function without constructing an instance of `Key`. + **Note:** + Overloads (3) and (4) participate in overload resolution only if `Compare::is_transparent` exists and is a valid type. It allows calling these functions without constructing an instance of `Key`. -**Complexity:** -Logarithmic in `size()`. + **Complexity:** + Logarithmic in `size()`. -

+

### count -``` -size_type count(const Key& key) const; -``` - -**Effects:** -Returns the number of elements with key equivalent to `key`, which is either 1 or 0 since this container does not allow duplicates. - -**Complexity:** -Logarithmic in `size()`. - -

- - - -``` -template -size_type count(const K& x) const; -``` +1. ``` + size_type count(const Key& key) const; + ``` +2. ``` + template + size_type count(const K& x) const; + ``` -**Effects:** -Returns the number of elements with key that compares equivalent to `x`, which is either 1 or 0 since this container does not allow duplicates. + **Effects:** + Returns the number of elements with key equivalent to `key` or `x`, which is either 1 or 0 since this container does not allow duplicates. -**Note:** -This overload participates in overload resolution only if `Compare::is_transparent` exists and is a valid type. It allows calling this function without constructing an instance of `Key`. + **Note:** + Overload (2) participates in overload resolution only if `Compare::is_transparent` exists and is a valid type. It allows calling this function without constructing an instance of `Key`. -**Complexity:** -Logarithmic in `size()`. + **Complexity:** + Logarithmic in `size()`. -

+

### contains -``` -bool contains(const Key& key) const; -``` - -**Effects:** -Returns `true` if the container contains an element with key equivalent to `key`, otherwise returns `false`. - -**Complexity:** -Logarithmic in `size()`. +1. ``` + bool contains(const Key& key) const; + ``` +2. ``` + template + bool contains(const K& x) const; + ``` -

+ **Effects:** + Returns `true` if the container contains an element with key equivalent to `key` or `x`, otherwise returns `false`. + **Note:** + Overload (2) participates in overload resolution only if `Compare::is_transparent` exists and is a valid type. It allows calling this function without constructing an instance of `Key`. + **Complexity:** + Logarithmic in `size()`. -``` -template -bool contains(const K& x) const; -``` +

-**Effects:** -Returns `true` if the container contains an element with the key that compares equivalent to `x`, otherwise returns `false`. -**Note:** -This overload participates in overload resolution only if `Compare::is_transparent` exists and is a valid type. It allows calling this function without constructing an instance of `Key`. -**Complexity:** -Logarithmic in `size()`. +### at -

+1. ``` + T& at(const Key& key); + ``` +2. ``` + const T& at(const Key& key) const; + ``` +3. ``` + template + const T& at(const K& x) const; + ``` + **Effects:** + Returns a reference to the mapped value of the element with key equivalent to `key` or `x`. If no such element exists, an exception of type `std::out_of_range` is thrown. + **Note:** + Overload (3) participates in overload resolution only if `Compare::is_transparent` exists and is a valid type. It allows calling this function without constructing an instance of `Key`. -### at + **Complexity:** + Logarithmic in `size()`. -``` -T& at(const Key& key); -``` -``` -const T& at(const Key& key) const; -``` + **Exceptions:** + `std::out_of_range` if the container does not have an element with the specified key. -**Effects:** -Returns a reference to the mapped value of the element with key equivalent to `key`. If no such element exists, an exception of type `std::out_of_range` is thrown. +

-**Complexity:** -Logarithmic in `size()`. -**Exceptions:** -`std::out_of_range` if the container does not have an element with the specified key. -

+### operator[] +1. ``` + T& operator[](const Key& key); + ``` +2. ``` + T& operator[](Key&& key); + ``` +3. ``` + template + T& operator[](const K& x); + ``` +4. ``` + template + T& operator[](K&& x); + ``` + **Preconditions:** + `!full()` -### operator[] + **Effects:** + Returns a reference to the value that is mapped to a key equivalent to `key` or `x`, performing an insertion if such key does not already exist. -``` -T& operator[](const Key& key); -``` -``` -T& operator[](Key&& key); -``` + * Overload (1) is equivalent to + `return try_emplace(key).first->second;` -**Preconditions:** -`!full()` + * Overload (2) is equivalent to + `return try_emplace(std::move(key)).first->second;` -**Effects:** -Returns a reference to the value that is mapped to a key equivalent to `key`, performing an insertion if such key does not already exist. + * Overload (3) is equivalent to + `return try_emplace(x).first->second;` -* The first overload is equivalent to: - ``` - return try_emplace(key).first->second; - ``` -* The second overload is equivalent to: - ``` - return try_emplace(std::move(key)).first->second; - ``` + * Overload (4) is equivalent to + `return try_emplace(std::forward(x)).first->second;` -**Note:** -The behavior is undefined if preconditions are not satisfied. + **Note:** + Overloads (3) and (4) participate in overload resolution only if `Compare::is_transparent` exists and is a valid type. It allows calling these functions without constructing an instance of `Key`. -**Complexity:** -Logarithmic in `size()`. + **Complexity:** + Logarithmic in `size()`. -

+

### data -``` -value_type* data() noexcept; -``` -``` -const value_type* data() const noexcept; -``` +1. ``` + value_type* data() noexcept; + ``` +2. ``` + const value_type* data() const noexcept; + ``` -**Effects:** -Returns pointer to the underlying array serving as element storage. The pointer is such that range `[data(), data() + size())` is always a valid range, even if the container is empty. `data()` is not dereferenceable if the container is empty. + **Effects:** + Returns pointer to the underlying array serving as element storage. The pointer is such that range `[data(), data() + size())` is always a valid range, even if the container is empty. `data()` is not dereferenceable if the container is empty. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

@@ -1448,186 +1423,186 @@ Constant. ### operator== -``` -template -bool operator== -( - const static_flat_map& x, - const static_flat_map& y -); -``` +1. ``` + template + bool operator== + ( + const static_flat_map& x, + const static_flat_map& y + ); + ``` -**Effects:** -Checks if the contents of `x` and `y` are equal. + **Effects:** + Checks if the contents of `x` and `y` are equal. -The contents of `x` and `y` are equal if the following conditions hold: -* `x.size() == y.size()` -* Each element in `x` compares equal with the element in `y` at the same position. + The contents of `x` and `y` are equal if the following conditions hold: + * `x.size() == y.size()` + * Each element in `x` compares equal with the element in `y` at the same position. -The comparison is performed by `std::equal`. -This comparison ignores the container's ordering `Compare`. + The comparison is performed by `std::equal`. + This comparison ignores the container's ordering `Compare`. -**Returns:** -Returns `true` if the contents of the `x` and `y` are equal, `false` otherwise. + **Returns:** + Returns `true` if the contents of the `x` and `y` are equal, `false` otherwise. -

+

### operator!= -``` -template -bool operator!= -( - const static_flat_map& x, - const static_flat_map& y -); -``` +1. ``` + template + bool operator!= + ( + const static_flat_map& x, + const static_flat_map& y + ); + ``` -**Effects:** -Checks if the contents of `x` and `y` are equal. + **Effects:** + Checks if the contents of `x` and `y` are equal. -For details see `operator==`. + For details see `operator==`. -**Returns:** -Returns `true` if the contents of the `x` and `y` are not equal, `false` otherwise. + **Returns:** + Returns `true` if the contents of the `x` and `y` are not equal, `false` otherwise. -

+

### operator< -``` -template -bool operator< -( - const static_flat_map& x, - const static_flat_map& y -); -``` +1. ``` + template + bool operator< + ( + const static_flat_map& x, + const static_flat_map& y + ); + ``` -**Effects:** -Compares the contents of `x` and `y` lexicographically. -The comparison is performed by a function `std::lexicographical_compare`. -This comparison ignores the container's ordering `Compare`. + **Effects:** + Compares the contents of `x` and `y` lexicographically. + The comparison is performed by a function `std::lexicographical_compare`. + This comparison ignores the container's ordering `Compare`. -**Returns:** -`true` if the contents of the `x` are lexicographically less than the contents of `y`, `false` otherwise. + **Returns:** + `true` if the contents of the `x` are lexicographically less than the contents of `y`, `false` otherwise. -

+

### operator> -``` -template -bool operator> -( - const static_flat_map& x, - const static_flat_map& y -); -``` +1. ``` + template + bool operator> + ( + const static_flat_map& x, + const static_flat_map& y + ); + ``` -**Effects:** -Compares the contents of lhs and rhs lexicographically. + **Effects:** + Compares the contents of lhs and rhs lexicographically. -The comparison is performed by a function `std::lexicographical_compare`. -This comparison ignores the container's ordering `Compare`. + The comparison is performed by a function `std::lexicographical_compare`. + This comparison ignores the container's ordering `Compare`. -**Returns:** -`true` if the contents of the `x` are lexicographically greater than the contents of `y`, `false` otherwise. + **Returns:** + `true` if the contents of the `x` are lexicographically greater than the contents of `y`, `false` otherwise. -

+

### operator<= -``` -template -bool operator<= -( - const static_flat_map& x, - const static_flat_map& y -); -``` +1. ``` + template + bool operator<= + ( + const static_flat_map& x, + const static_flat_map& y + ); + ``` -**Effects:** -Compares the contents of `x` and `y` lexicographically. -The comparison is performed by a function `std::lexicographical_compare`. -This comparison ignores the container's ordering `Compare`. + **Effects:** + Compares the contents of `x` and `y` lexicographically. + The comparison is performed by a function `std::lexicographical_compare`. + This comparison ignores the container's ordering `Compare`. -**Returns:** -`true` if the contents of the `x` are lexicographically less than or equal to the contents of `y`, `false` otherwise. + **Returns:** + `true` if the contents of the `x` are lexicographically less than or equal to the contents of `y`, `false` otherwise. -

+

### operator>= -``` -template -bool operator>= -( - const static_flat_map& x, - const static_flat_map& y -); -``` +1. ``` + template + bool operator>= + ( + const static_flat_map& x, + const static_flat_map& y + ); + ``` -**Effects:** -Compares the contents of `x` and `y` lexicographically. -The comparison is performed by a function `std::lexicographical_compare`. -This comparison ignores the container's ordering `Compare`. + **Effects:** + Compares the contents of `x` and `y` lexicographically. + The comparison is performed by a function `std::lexicographical_compare`. + This comparison ignores the container's ordering `Compare`. -**Returns:** -`true` if the contents of the `x` are lexicographically greater than or equal to the contents of `y`, `false` otherwise. + **Returns:** + `true` if the contents of the `x` are lexicographically greater than or equal to the contents of `y`, `false` otherwise. -

+

### swap -``` -template -void swap -( - static_flat_map& x, - static_flat_map& y -); -``` +1. ``` + template + void swap + ( + static_flat_map& x, + static_flat_map& y + ); + ``` -**Effects:** -Swaps the contents of `x` and `y`. Calls `x.swap(y)`. + **Effects:** + Swaps the contents of `x` and `y`. Calls `x.swap(y)`. -

+

### erase_if -``` -template -typename static_flat_map::size_type - erase_if(static_flat_map& c, Predicate pred) -``` +1. ``` + template + typename static_flat_map::size_type + erase_if(static_flat_map& c, Predicate pred) + ``` -**Effects:** -Erases all elements that satisfy the predicate `pred` from the container. + **Effects:** + Erases all elements that satisfy the predicate `pred` from the container. -`pred` is unary predicate which returns `true` if the element should be removed. + `pred` is unary predicate which returns `true` if the element should be removed. -**Returns:** -The number of erased elements. + **Returns:** + The number of erased elements. -**Complexity:** -Linear. + **Complexity:** + Linear. -

+

diff --git a/doc/static_flat_multimap.md b/doc/static_flat_multimap.md index 3191469..a7c85fb 100644 --- a/doc/static_flat_multimap.md +++ b/doc/static_flat_multimap.md @@ -170,1067 +170,942 @@ static constexpr size_type static_capacity = N; ### (constructor) -``` -static_flat_multimap() noexcept(std::is_nothrow_default_constructible::value); -``` -``` -explicit static_flat_multimap(const Compare& comp) noexcept(std::is_nothrow_copy_constructible::value); -``` - -**Effects:** -Constructs an empty container. - -**Complexity:** -Constant. +1. ``` + static_flat_multimap() noexcept(std::is_nothrow_default_constructible::value); + ``` +2. ``` + explicit static_flat_multimap(const Compare& comp) noexcept(std::is_nothrow_copy_constructible::value); + ``` -

+ **Effects:** + Constructs an empty container. + **Complexity:** + Constant. +

-``` -template -static_flat_multimap(InputIt first, InputIt last); -``` -``` -template -static_flat_multimap(InputIt first, InputIt last, const Compare& comp); -``` -**Preconditions:** -`std::distance(first, last) <= capacity()` -**Effects:** -Constructs an empty container and inserts elements from the range `[first, last)`. +3. ``` + template + static_flat_multimap(InputIt first, InputIt last); + ``` +4. ``` + template + static_flat_multimap(InputIt first, InputIt last, const Compare& comp); + ``` -**Note:** -This overload participates in overload resolution only if `InputIt` satisfies requirements of [*LegacyInputIterator*](https://en.cppreference.com/w/cpp/named_req/InputIterator). + **Preconditions:** + `std::distance(first, last) <= capacity()` -**Note:** -The behavior is undefined if preconditions are not satisfied. + **Effects:** + Constructs an empty container and inserts elements from the range `[first, last)`. -**Complexity:** -Linear in `std::distance(first, last)`. + **Note:** + These overloads participate in overload resolution only if `InputIt` satisfies requirements of [*LegacyInputIterator*](https://en.cppreference.com/w/cpp/named_req/InputIterator). -

+ **Complexity:** + Linear in `std::distance(first, last)`. +

-``` -static_flat_multimap(std::initializer_list ilist); -``` -``` -static_flat_multimap(std::initializer_list ilist, const Compare& comp); -``` -**Preconditions:** -`ilist.size() <= capacity()` +5. ``` + static_flat_multimap(std::initializer_list ilist); + ``` +6. ``` + static_flat_multimap(std::initializer_list ilist, const Compare& comp); + ``` -**Effects:** -Constructs an empty container and inserts elements from the initializer list `ilist`. + **Preconditions:** + `ilist.size() <= capacity()` -**Note:** -The behavior is undefined if preconditions are not satisfied. + **Effects:** + Constructs an empty container and inserts elements from the initializer list `ilist`. -**Complexity:** -Linear in `ilist.size()`. + **Complexity:** + Linear in `ilist.size()`. -

+

-``` -static_flat_multimap(const static_flat_multimap& other); -``` +7. ``` + static_flat_multimap(const static_flat_multimap& other); + ``` -**Effects:** -Copy constructor. -Constructs the container with the copy of the contents of `other`. + **Effects:** + Copy constructor. + Constructs the container with the copy of the contents of `other`. -**Complexity:** -Linear in size. + **Complexity:** + Linear in size. -

+

-``` -static_flat_multimap(static_flat_multimap&& other); -``` +8. ``` + static_flat_multimap(static_flat_multimap&& other); + ``` -**Effects:** -Move constructor. -Constructs the container with the contents of `other` using move semantics. + **Effects:** + Move constructor. + Constructs the container with the contents of `other` using move semantics. -`other` is not guaranteed to be empty after the move. + `other` is not guaranteed to be empty after the move. -`other` is in a valid but unspecified state after the move. + `other` is in a valid but unspecified state after the move. -**Complexity:** -Linear in size. + **Complexity:** + Linear in size. -

+

### (destructor) -``` -~static_flat_multimap(); -``` +1. ``` + ~static_flat_multimap(); + ``` -**Effects:** -Destructs the container. The destructors of the elements are called and the used storage is deallocated. + **Effects:** + Destructs the container. The destructors of the elements are called and the used storage is deallocated. -**Complexity:** -Linear in size. + **Complexity:** + Linear in size. -

+

### operator= -``` -static_flat_multimap& operator=(const static_flat_multimap& other); -``` - -**Effects:** -Copy assignment operator. -Replaces the contents with a copy of the contents of `other`. +1. ``` + static_flat_multimap& operator=(const static_flat_multimap& other); + ``` -**Returns:** -`*this()`. + **Effects:** + Copy assignment operator. + Replaces the contents with a copy of the contents of `other`. -**Complexity:** -Linear in size. + **Returns:** + `*this()`. -

+ **Complexity:** + Linear in size. +

-``` -static_flat_multimap& operator=(static_flat_multimap&& other); -``` -**Effects:** -Move assignment operator. -Replaces the contents with those of `other` using move semantics. +2. ``` + static_flat_multimap& operator=(static_flat_multimap&& other); + ``` -`other` is not guaranteed to be empty after the move. + **Effects:** + Move assignment operator. + Replaces the contents with those of `other` using move semantics. -`other` is in a valid but unspecified state after the move. + `other` is not guaranteed to be empty after the move. -**Returns:** -`*this()`. + `other` is in a valid but unspecified state after the move. -**Complexity:** -Linear in size. + **Returns:** + `*this()`. -

+ **Complexity:** + Linear in size. +

-``` -static_flat_multimap& operator=(std::initializer_list ilist); -``` -**Preconditions:** -`ilist.size() <= capacity()` +3. ``` + static_flat_multimap& operator=(std::initializer_list ilist); + ``` -**Effects:** -Replaces the contents with those identified by initializer list `ilist`. + **Preconditions:** + `ilist.size() <= capacity()` -**Note:** -The behavior is undefined if preconditions are not satisfied. + **Effects:** + Replaces the contents with those identified by initializer list `ilist`. -**Returns:** -`*this()`. + **Returns:** + `*this()`. -**Complexity:** -Linear in size. + **Complexity:** + Linear in size. -

+

### key_comp -``` -key_compare key_comp() const; -``` +1. ``` + key_compare key_comp() const; + ``` -**Effects:** -Returns the function object that compares the keys, which is a copy of this container's constructor argument `comp`. + **Effects:** + Returns the function object that compares the keys, which is a copy of this container's constructor argument `comp`. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

### value_comp -``` -value_compare value_comp() const; -``` +1. ``` + value_compare value_comp() const; + ``` -**Effects:** -Returns a function object that compares objects of type `value_type`. + **Effects:** + Returns a function object that compares objects of type `value_type`. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

### begin, cbegin -``` -iterator begin() noexcept; -``` -``` -const_iterator begin() const noexcept; -``` -``` -const_iterator cbegin() const noexcept; -``` - -**Effects:** -Returns an iterator to the first element of the container. +1. ``` + iterator begin() noexcept; + ``` +2. ``` + const_iterator begin() const noexcept; + ``` +3. ``` + const_iterator cbegin() const noexcept; + ``` -If the container is empty, the returned iterator will be equal to `end()`. + **Effects:** + Returns an iterator to the first element of the container. + If the container is empty, the returned iterator will be equal to `end()`. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

### end, cend -``` -iterator end() noexcept; -``` -``` -const_iterator end() const noexcept; -``` -``` -const_iterator cend() const noexcept; -``` - -**Effects:** -Returns an iterator to the element following the last element of the container. +1. ``` + iterator end() noexcept; + ``` +2. ``` + const_iterator end() const noexcept; + ``` +3. ``` + const_iterator cend() const noexcept; + ``` -This element acts as a placeholder; attempting to access it results in undefined behavior. + **Effects:** + Returns an iterator to the element following the last element of the container. + This element acts as a placeholder; attempting to access it results in undefined behavior. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

### rbegin, crbegin -``` -reverse_iterator rbegin() noexcept; -``` -``` -const_reverse_iterator rbegin() const noexcept; -``` -``` -const_reverse_iterator crbegin() const noexcept; -``` +1. ``` + reverse_iterator rbegin() noexcept; + ``` +2. ``` + const_reverse_iterator rbegin() const noexcept; + ``` +3. ``` + const_reverse_iterator crbegin() const noexcept; + ``` -**Effects:** -Returns a reverse iterator to the first element of the reversed container. -It corresponds to the last element of the non-reversed container. -If the container is empty, the returned iterator is equal to `rend()`. + **Effects:** + Returns a reverse iterator to the first element of the reversed container. + It corresponds to the last element of the non-reversed container. + If the container is empty, the returned iterator is equal to `rend()`. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

### rend, crend -``` -reverse_iterator rend() noexcept; -``` -``` -const_reverse_iterator rend() const noexcept; -``` -``` -const_reverse_iterator crend() const noexcept; -``` +1. ``` + reverse_iterator rend() noexcept; + ``` +2. ``` + const_reverse_iterator rend() const noexcept; + ``` +3. ``` + const_reverse_iterator crend() const noexcept; + ``` -**Effects:** -Returns a reverse iterator to the element following the last element of the reversed container. -It corresponds to the element preceding the first element of the non-reversed container. -This element acts as a placeholder, attempting to access it results in undefined behavior. + **Effects:** + Returns a reverse iterator to the element following the last element of the reversed container. + It corresponds to the element preceding the first element of the non-reversed container. + This element acts as a placeholder, attempting to access it results in undefined behavior. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

### nth -``` -iterator nth(size_type pos) noexcept; -``` -``` -const_iterator nth(size_type pos) const noexcept; -``` +1. ``` + iterator nth(size_type pos) noexcept; + ``` +2. ``` + const_iterator nth(size_type pos) const noexcept; + ``` -**Preconditions:** -`pos <= size()` + **Preconditions:** + `pos <= size()` -**Effects:** -Returns an iterator to the element at position `pos`. -If `pos == size()`, the returned iterator is equal to `end()`. + **Effects:** + Returns an iterator to the element at position `pos`. -**Complexity:** -Constant. + If `pos == size()`, the returned iterator is equal to `end()`. -

+ **Complexity:** + Constant. + +

### index_of -``` -size_type index_of(const_iterator pos) const noexcept; -``` +1. ``` + size_type index_of(const_iterator pos) const noexcept; + ``` -**Preconditions:** -`cbegin() <= pos && pos <= cend()` + **Preconditions:** + `cbegin() <= pos && pos <= cend()` -**Effects:** -Returns position of the element pointed by iterator `pos`, i.e. `std::distance(begin(), pos)`. + **Effects:** + Returns position of the element pointed by iterator `pos`, i.e. `std::distance(begin(), pos)`. -If `pos == end()`, the returned value is equal to `size()`. + If `pos == end()`, the returned value is equal to `size()`. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

### empty -``` -bool empty() const noexcept; -``` +1. ``` + bool empty() const noexcept; + ``` -**Effects:** -Returns `true` if the container has no elements, i.e. whether `begin() == end()`. + **Effects:** + Returns `true` if the container has no elements, i.e. whether `begin() == end()`. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

### full -``` -bool full() const noexcept; -``` +1. ``` + bool full() const noexcept; + ``` -**Effects:** -Returns `true` if the container is full, i.e. whether `size() == capacity()`. + **Effects:** + Returns `true` if the container is full, i.e. whether `size() == capacity()`. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

### size -``` -size_type size() const noexcept; -``` +1. ``` + size_type size() const noexcept; + ``` -**Effects:** -Returns the number of elements in the container, i.e. `std::distance(begin(), end())`. + **Effects:** + Returns the number of elements in the container, i.e. `std::distance(begin(), end())`. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

### max_size -``` -static constexpr size_type max_size() const noexcept; -``` +1. ``` + static constexpr size_type max_size() const noexcept; + ``` -**Effects:** -Returns the maximum number of elements the container is able to hold, i.e. returns `N`. + **Effects:** + Returns the maximum number of elements the container is able to hold, i.e. `N`. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

### capacity -``` -static constexpr size_type capacity() const noexcept; -``` +1. ``` + static constexpr size_type capacity() const noexcept; + ``` -**Effects:** -Returns the maximum number of elements the container is able to hold, i.e. returns `N`. + **Effects:** + Returns the maximum number of elements the container is able to hold, i.e. `N`. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

### available -``` -size_type available() const noexcept; -``` +1. ``` + size_type available() const noexcept; + ``` -**Effects:** -Returns the number of elements that can be inserted into the container, i.e. returns `capacity() - size()`. + **Effects:** + Returns the number of elements that can be inserted into the container, i.e. `capacity() - size()`. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

### clear -``` -void clear() noexcept; -``` +1. ``` + void clear() noexcept; + ``` -**Effects:** -Erases all elements from the container. -After this call, `size()` returns zero and `capacity()` remains unchanged. + **Effects:** + Erases all elements from the container. + After this call, `size()` returns zero and `capacity()` remains unchanged. -**Complexity:** -Linear in `size()`. + **Complexity:** + Linear in `size()`. -

+

### emplace -``` -template -iterator emplace(Args&&... args); -``` - -**Preconditions:** -`!full()` +1. ``` + template + iterator emplace(Args&&... args); + ``` -**Effects:** -Inserts a new element into the container. + **Preconditions:** + `!full()` -New element is constructed as `value_type(std::forward(args)...)`. + **Effects:** + Inserts a new element into the container. -**Note:** -The behavior is undefined if preconditions are not satisfied. + New element is constructed as `value_type(std::forward(args)...)`. -**Returns:** -Iterator to the inserted element. + **Returns:** + Iterator to the inserted element. -

+

### emplace_hint -``` -template -iterator emplace_hint(const_iterator hint, Args&&... args); -``` - -**Preconditions:** -1. `!full()` -2. `cbegin() <= hint && hint <= cend()` +1. ``` + template + iterator emplace_hint(const_iterator hint, Args&&... args); + ``` -**Effects:** -Inserts a new element into the container. + **Preconditions:** + 1. `!full()` + 2. `cbegin() <= hint && hint <= cend()` -New element is constructed as `value_type(std::forward(args)...)`. + **Effects:** + Inserts a new element into the container. -Iterator `hint` is used as a suggestion where to start to search insert position. + New element is constructed as `value_type(std::forward(args)...)`. -**Note:** -The behavior is undefined if preconditions are not satisfied. + Iterator `hint` is used as a suggestion where to start to search insert position. -**Returns:** -Iterator to the inserted element. + **Returns:** + Iterator to the inserted element. -

+

### insert -``` -iterator insert(const value_type& value); -``` - -**Preconditions:** -`!full()` - -**Effects:** -Inserts copy of `value`. - -**Note:** -The behavior is undefined if preconditions are not satisfied. - -**Returns:** -Iterator to the inserted element. - -

+1. ``` + iterator insert(const value_type& value); + ``` + **Preconditions:** + `!full()` + **Effects:** + Inserts copy of `value`. -``` -iterator insert(value_type&& value); -``` - -**Preconditions:** -`!full()` + **Returns:** + Iterator to the inserted element. -**Effects:** -Inserts `value` using move semantics. +

-**Note:** -The behavior is undefined if preconditions are not satisfied. -**Returns:** -Iterator to the inserted element. -

+2. ``` + iterator insert(value_type&& value); + ``` + **Preconditions:** + `!full()` + **Effects:** + Inserts `value` using move semantics. -``` -template -iterator insert(P&& value); -``` + **Returns:** + Iterator to the inserted element. -**Preconditions:** -`!full()` +

-**Effects:** -Inserts a new element into the container. -New element is constructed as `value_type(std::forward

(value))`. -**Note:** -This overload participates in overload resolution only if `std::is_constructible::value` is `true`. +3. ``` + template + iterator insert(P&& value); + ``` -**Note:** -The behavior is undefined if preconditions are not satisfied. + **Preconditions:** + `!full()` -**Returns:** -Iterator to the inserted element. + **Effects:** + Inserts a new element into the container. -

+ New element is constructed as `value_type(std::forward

(value))`. + **Note:** + This overload participates in overload resolution only if `std::is_constructible::value` is `true`. + **Returns:** + Iterator to the inserted element. -``` -iterator insert(const_iterator hint, const value_type& value); -``` +

-**Preconditions:** -1. `!full()` -2. `cbegin() <= hint && hint <= cend()` -**Effects:** -Inserts copy of `value`. -Iterator `hint` is used as a suggestion where to start to search insert position. +4. ``` + iterator insert(const_iterator hint, const value_type& value); + ``` -**Note:** -The behavior is undefined if preconditions are not satisfied. + **Preconditions:** + 1. `!full()` + 2. `cbegin() <= hint && hint <= cend()` -**Returns:** -Iterator to the inserted element. + **Effects:** + Inserts copy of `value`. -

+ Iterator `hint` is used as a suggestion where to start to search insert position. + **Returns:** + Iterator to the inserted element. +

-``` -iterator insert(const_iterator hint, value_type&& value); -``` -**Preconditions:** -1. `!full()` -2. `cbegin() <= hint && hint <= cend()` -**Effects:** -Inserts `value` using move semantics. +5. ``` + iterator insert(const_iterator hint, value_type&& value); + ``` -Iterator `hint` is used as a suggestion where to start to search insert position. + **Preconditions:** + 1. `!full()` + 2. `cbegin() <= hint && hint <= cend()` -**Note:** -The behavior is undefined if preconditions are not satisfied. + **Effects:** + Inserts `value` using move semantics. -**Returns:** -Iterator to the inserted element. + Iterator `hint` is used as a suggestion where to start to search insert position. -

+ **Returns:** + Iterator to the inserted element. +

-``` -template -iterator insert(const_iterator hint, P&& value); -``` -**Preconditions:** -1. `!full()` -2. `cbegin() <= hint && hint <= cend()` +6. ``` + template + iterator insert(const_iterator hint, P&& value); + ``` -**Effects:** -Inserts a new element into the container. + **Preconditions:** + 1. `!full()` + 2. `cbegin() <= hint && hint <= cend()` -New element is constructed as `value_type(std::forward

(value))`. + **Effects:** + Inserts a new element into the container. -Iterator `hint` is used as a suggestion where to start to search insert position. + New element is constructed as `value_type(std::forward

(value))`. -**Note:** -This overload participates in overload resolution only if `std::is_constructible::value` is `true`. + Iterator `hint` is used as a suggestion where to start to search insert position. -**Note:** -The behavior is undefined if preconditions are not satisfied. + **Note:** + This overload participates in overload resolution only if `std::is_constructible::value` is `true`. -**Returns:** -Iterator to the inserted element. + **Returns:** + Iterator to the inserted element. -

+

-``` -template -void insert(InputIt first, InputIt last); -``` - -**Preconditions:** -`std::distance(first, last) <= available()` +7. ``` + template + void insert(InputIt first, InputIt last); + ``` -**Effects:** -Inserts elements from range `[first, last)`. + **Preconditions:** + `std::distance(first, last) <= available()` -The call to this function is equivalent to: -``` -while (first != last) -{ - insert(*first); - ++first; -} -``` + **Effects:** + Inserts elements from range `[first, last)`. -**Note:** -This overload participates in overload resolution only if `InputIt` satisfies requirements of [*LegacyInputIterator*](https://en.cppreference.com/w/cpp/named_req/InputIterator). + The call to this function is equivalent to: + ``` + while (first != last) + { + insert(*first); + ++first; + } + ``` -**Note:** -The behavior is undefined if preconditions are not satisfied. + **Note:** + This overload participates in overload resolution only if `InputIt` satisfies requirements of [*LegacyInputIterator*](https://en.cppreference.com/w/cpp/named_req/InputIterator). -

+

-``` -void insert(std::initializer_list ilist); -``` +8. ``` + void insert(std::initializer_list ilist); + ``` -**Preconditions:** -`ilist.size() <= available()` + **Preconditions:** + `ilist.size() <= available()` -**Effects:** -Inserts elements from initializer list `ilist`. + **Effects:** + Inserts elements from initializer list `ilist`. -The call to this function is equivalent to: -``` -insert(ilist.begin(), ilist.end()); -``` + The call to this function is equivalent to `insert(ilist.begin(), ilist.end())`. -**Note:** -The behavior is undefined if preconditions are not satisfied. + **Note:** + The behavior is undefined if preconditions are not satisfied. -

+

### erase -``` -iterator erase(iterator pos); -``` -``` -iterator erase(const_iterator pos); -``` - -**Preconditions:** -`cbegin() <= pos && pos < cend()` - -**Effects:** -Removes the element at `pos`. - -**Note:** -The behavior is undefined if preconditions are not satisfied. - -**Returns:** -Iterator following the last removed element. - -

- - - -``` -iterator erase(const_iterator first, const_iterator last); -``` +1. ``` + iterator erase(iterator pos); + ``` +2. ``` + iterator erase(const_iterator pos); + ``` -**Preconditions:** -`cbegin() <= first && first <= last && last <= cend()` + **Preconditions:** + `cbegin() <= pos && pos < cend()` -**Effects:** -Removes the elements in the range `[first, last)`. + **Effects:** + Removes the element at `pos`. -**Note:** -The behavior is undefined if preconditions are not satisfied. + **Returns:** + Iterator following the last removed element. -**Returns:** -Iterator following the last removed element. +

-

+3. ``` + iterator erase(const_iterator first, const_iterator last); + ``` -``` -size_type erase(const Key& key); -``` + **Preconditions:** + `cbegin() <= first && first <= last && last <= cend()` -**Effects:** -Removes all elements with the key equivalent to `key`. + **Effects:** + Removes the elements in the range `[first, last)`. -**Returns:** -Number of elements removed. + **Returns:** + Iterator following the last removed element. -

+

-``` -template -size_type erase(K&& x); -``` +4. ``` + size_type erase(const Key& key); + ``` +5. ``` + template + size_type erase(K&& x); + ``` -**Effects:** -Removes all elements with key that compares equivalent to the value `x`. + **Effects:** + Removes all elements with the key equivalent to `key` or `x`. -**Note:** -This overload participates in overload resolution only if `Compare::is_transparent` exists and is a valid type. It allows calling this function without constructing an instance of `Key`. + **Note:** + Overload (5) participates in overload resolution only if `Compare::is_transparent` exists and is a valid type. It allows calling this function without constructing an instance of `Key`. -**Returns:** -Number of elements removed. + **Returns:** + Number of elements removed. -

+

### swap -``` -void swap(static_flat_multimap& other); -``` +1. ``` + void swap(static_flat_multimap& other); + ``` -**Effects:** -Exchanges the contents of the container with those of `other`. + **Effects:** + Exchanges the contents of the container with those of `other`. -**Complexity:** -Linear in size. + **Complexity:** + Linear in size. -

+

### lower_bound -``` -iterator lower_bound(const Key& key); -``` -``` -const_iterator lower_bound(const Key& key) const; -``` - -**Effects:** -Returns an iterator pointing to the first element with key that is not less than `key`, or `end()` if such an element is not found. - -**Complexity:** -Logarithmic in `size()`. - -

- - - -``` -template -iterator lower_bound(const K& x); -``` -``` -template -const_iterator lower_bound(const K& x) const; -``` +1. ``` + iterator lower_bound(const Key& key); + ``` +2. ``` + const_iterator lower_bound(const Key& key) const; + ``` +3. ``` + template + iterator lower_bound(const K& x); + ``` +4. ``` + template + const_iterator lower_bound(const K& x) const; + ``` -**Effects:** -Returns an iterator pointing to the first element with key that compares not less to the value `x`, or `end()` if such an element is not found. + **Effects:** + Returns an iterator pointing to the first element with key that compares **not less than** `key` or `x`. Returns `end()` if no such element is found. -**Note:** -This overload participates in overload resolution only if `Compare::is_transparent` exists and is a valid type. It allows calling this function without constructing an instance of `Key`. + **Note:** + Overloads (3) and (4) participate in overload resolution only if `Compare::is_transparent` exists and is a valid type. It allows calling these functions without constructing an instance of `Key`. -**Complexity:** -Logarithmic in `size()`. + **Complexity:** + Logarithmic in `size()`. -

+

### upper_bound -``` -iterator upper_bound(const Key& key); -``` -``` -const_iterator upper_bound(const Key& key) const; -``` - -**Effects:** -Returns an iterator pointing to the first element with key that is greater than `key`, or `end()` if such an element is not found. - -**Complexity:** -Logarithmic in `size()`. - -

- - - -``` -template -iterator upper_bound(const K& x); -``` -``` -template -const_iterator upper_bound(const K& x) const; -``` +1. ``` + iterator upper_bound(const Key& key); + ``` +2. ``` + const_iterator upper_bound(const Key& key) const; + ``` +3. ``` + template + iterator upper_bound(const K& x); + ``` +4. ``` + template + const_iterator upper_bound(const K& x) const; + ``` -**Effects:** -Returns an iterator pointing to the first element with key that compares greater to the value `x`, or `end()` if such an element is not found. + **Effects:** + Returns an iterator pointing to the first element with key that compares **greater than** `key` or `x`. Returns `end()` if no such element is found. -**Note:** -This overload participates in overload resolution only if `Compare::is_transparent` exists and is a valid type. It allows calling this function without constructing an instance of `Key`. + **Note:** + Overloads (3) and (4) participate in overload resolution only if `Compare::is_transparent` exists and is a valid type. It allows calling these functions without constructing an instance of `Key`. -**Complexity:** -Logarithmic in `size()`. + **Complexity:** + Logarithmic in `size()`. -

+

### equal_range -``` -std::pair equal_range(const Key& key); -``` -``` -std::pair equal_range(const Key& key) const; -``` - -**Effects:** -Returns a range containing all elements with the key that is equal to `key`: -* The first iterator in pair points to the first element that is not less than `key`, or `end()` if such an element does not exist. -* The second iterator in pair points to the first element that is greater that `key`, or `end()` is such an element does not exist. - -**Complexity:** -Logarithmic in `size()`. - -

- - - -``` -template -std::pair equal_range(const K& x); -``` -``` -template -std::pair equal_range(const K& x) const; -``` +1. ``` + std::pair equal_range(const Key& key); + ``` +2. ``` + std::pair equal_range(const Key& key) const; + ``` +3. ``` + template + std::pair equal_range(const K& x); + ``` +4. ``` + template + std::pair equal_range(const K& x) const; + ``` -**Effects:** -Returns a range containing all elements with the key that compares equal to the value `x`: -* The first iterator in pair points to the first element that compares not less to the value `x`, or `end()` if such an element does not exist. -* The second iterator in pair points to the first element that compares greater to the value `x`, or `end()` is such an element does not exist. + **Effects:** + Returns a range containing all elements with key that compares equivalent to `key` or `x`. + * The first iterator in pair points to the first element that compares **not less than** `key` or `x`. It is equal to `end()` if no such element is found. + * The second iterator in pair points to the first element that compares **greater than** `key` or `x`. It is equal to `end()` is no such element is found. -**Note:** -This overload participates in overload resolution only if `Compare::is_transparent` exists and is a valid type. It allows calling this function without constructing an instance of `Key`. + **Note:** + Overloads (3) and (4) participate in overload resolution only if `Compare::is_transparent` exists and is a valid type. It allows calling these functions without constructing an instance of `Key`. -**Complexity:** -Logarithmic in `size()`. + **Complexity:** + Logarithmic in `size()`. -

+

### find -``` -iterator find(const Key& key); -``` -``` -const_iterator find(const Key& key) const; -``` - -**Effects:** -Returns an iterator to an element with key equivalent to `key`, or `end()` if such an element is not found. If there are several elements with key in the container, any of them may be returned. - -**Complexity:** -Logarithmic in `size()`. - -

- - - -``` -template -iterator find(const K& x); -``` -``` -template -const_iterator find(const K& x) const; -``` +1. ``` + iterator find(const Key& key); + ``` +2. ``` + const_iterator find(const Key& key) const; + ``` +3. ``` + template + iterator find(const K& x); + ``` +4. ``` + template + const_iterator find(const K& x) const; + ``` -**Effects:** -Returns an iterator to an element with key that compares equivalent to `x`, or `end()` if such an element is not found. If there are several elements with key in the container, any of them may be returned. + **Effects:** + Returns an iterator pointing to the element with key equivalent to `key` or `x`. Returns `end()` if no such element is found. If there are several elements with key in the container, any of them may be returned. -**Note:** -This overload participates in overload resolution only if `Compare::is_transparent` exists and is a valid type. It allows calling this function without constructing an instance of `Key`. + **Note:** + Overloads (3) and (4) participate in overload resolution only if `Compare::is_transparent` exists and is a valid type. It allows calling these functions without constructing an instance of `Key`. -**Complexity:** -Logarithmic in `size()`. + **Complexity:** + Logarithmic in `size()`. -

+

### count -``` -size_type count(const Key& key) const; -``` - -**Effects:** -Returns the number of elements with key equivalent to `key`. - -**Complexity:** -Logarithmic in `size()`. - -

- - - -``` -template -size_type count(const K& x) const; -``` +1. ``` + size_type count(const Key& key) const; + ``` +2. ``` + template + size_type count(const K& x) const; + ``` -**Effects:** -Returns the number of elements with key that compares equivalent to the value `x`. + **Effects:** + Returns the number of elements with key equivalent to `key` or `x`. -**Note:** -This overload participates in overload resolution only if `Compare::is_transparent` exists and is a valid type. It allows calling this function without constructing an instance of `Key`. + **Note:** + Overload (2) participates in overload resolution only if `Compare::is_transparent` exists and is a valid type. It allows calling this function without constructing an instance of `Key`. -**Complexity:** -Logarithmic in `size()`. + **Complexity:** + Logarithmic in `size()`. -

+

### contains -``` -bool contains(const Key& key) const; -``` - -**Effects:** -Returns `true` if the container contains an element with key equivalent to `key`, otherwise returns `false`. - -**Complexity:** -Logarithmic in `size()`. - -

- - - -``` -template -bool contains(const K& x) const; -``` +1. ``` + bool contains(const Key& key) const; + ``` +2. ``` + template + bool contains(const K& x) const; + ``` -**Effects:** -Returns `true` if the container contains an element with the key that compares equivalent to `x`, otherwise returns `false`. + **Effects:** + Returns `true` if the container contains an element with key equivalent to `key` or `x`, otherwise returns `false`. -**Note:** -This overload participates in overload resolution only if `Compare::is_transparent` exists and is a valid type. It allows calling this function without constructing an instance of `Key`. + **Note:** + Overload (2) participates in overload resolution only if `Compare::is_transparent` exists and is a valid type. It allows calling this function without constructing an instance of `Key`. -**Complexity:** -Logarithmic in `size()`. + **Complexity:** + Logarithmic in `size()`. -

+

### data -``` -value_type* data() noexcept; -``` -``` -const value_type* data() const noexcept; -``` +1. ``` + value_type* data() noexcept; + ``` +2. ``` + const value_type* data() const noexcept; + ``` -**Effects:** -Returns pointer to the underlying array serving as element storage. The pointer is such that range `[data(), data() + size())` is always a valid range, even if the container is empty. `data()` is not dereferenceable if the container is empty. + **Effects:** + Returns pointer to the underlying array serving as element storage. The pointer is such that range `[data(), data() + size())` is always a valid range, even if the container is empty. `data()` is not dereferenceable if the container is empty. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

@@ -1238,186 +1113,186 @@ Constant. ### operator== -``` -template -bool operator== -( - const static_flat_multimap& x, - const static_flat_multimap& y -); -``` +1. ``` + template + bool operator== + ( + const static_flat_multimap& x, + const static_flat_multimap& y + ); + ``` -**Effects:** -Checks if the contents of `x` and `y` are equal. + **Effects:** + Checks if the contents of `x` and `y` are equal. -The contents of `x` and `y` are equal if the following conditions hold: -* `x.size() == y.size()` -* Each element in `x` compares equal with the element in `y` at the same position. + The contents of `x` and `y` are equal if the following conditions hold: + * `x.size() == y.size()` + * Each element in `x` compares equal with the element in `y` at the same position. -The comparison is performed by `std::equal`. -This comparison ignores the container's ordering `Compare`. + The comparison is performed by `std::equal`. + This comparison ignores the container's ordering `Compare`. -**Returns:** -Returns `true` if the contents of the `x` and `y` are equal, `false` otherwise. + **Returns:** + Returns `true` if the contents of the `x` and `y` are equal, `false` otherwise. -

+

### operator!= -``` -template -bool operator!= -( - const static_flat_multimap& x, - const static_flat_multimap& y -); -``` +1. ``` + template + bool operator!= + ( + const static_flat_multimap& x, + const static_flat_multimap& y + ); + ``` -**Effects:** -Checks if the contents of `x` and `y` are equal. + **Effects:** + Checks if the contents of `x` and `y` are equal. -For details see `operator==`. + For details see `operator==`. -**Returns:** -Returns `true` if the contents of the `x` and `y` are not equal, `false` otherwise. + **Returns:** + Returns `true` if the contents of the `x` and `y` are not equal, `false` otherwise. -

+

### operator< -``` -template -bool operator< -( - const static_flat_multimap& x, - const static_flat_multimap& y -); -``` +1. ``` + template + bool operator< + ( + const static_flat_multimap& x, + const static_flat_multimap& y + ); + ``` -**Effects:** -Compares the contents of `x` and `y` lexicographically. -The comparison is performed by a function `std::lexicographical_compare`. -This comparison ignores the container's ordering `Compare`. + **Effects:** + Compares the contents of `x` and `y` lexicographically. + The comparison is performed by a function `std::lexicographical_compare`. + This comparison ignores the container's ordering `Compare`. -**Returns:** -`true` if the contents of the `x` are lexicographically less than the contents of `y`, `false` otherwise. + **Returns:** + `true` if the contents of the `x` are lexicographically less than the contents of `y`, `false` otherwise. -

+

### operator> -``` -template -bool operator> -( - const static_flat_multimap& x, - const static_flat_multimap& y -); -``` +1. ``` + template + bool operator> + ( + const static_flat_multimap& x, + const static_flat_multimap& y + ); + ``` -**Effects:** -Compares the contents of lhs and rhs lexicographically. + **Effects:** + Compares the contents of lhs and rhs lexicographically. -The comparison is performed by a function `std::lexicographical_compare`. -This comparison ignores the container's ordering `Compare`. + The comparison is performed by a function `std::lexicographical_compare`. + This comparison ignores the container's ordering `Compare`. -**Returns:** -`true` if the contents of the `x` are lexicographically greater than the contents of `y`, `false` otherwise. + **Returns:** + `true` if the contents of the `x` are lexicographically greater than the contents of `y`, `false` otherwise. -

+

### operator<= -``` -template -bool operator<= -( - const static_flat_multimap& x, - const static_flat_multimap& y -); -``` +1. ``` + template + bool operator<= + ( + const static_flat_multimap& x, + const static_flat_multimap& y + ); + ``` -**Effects:** -Compares the contents of `x` and `y` lexicographically. -The comparison is performed by a function `std::lexicographical_compare`. -This comparison ignores the container's ordering `Compare`. + **Effects:** + Compares the contents of `x` and `y` lexicographically. + The comparison is performed by a function `std::lexicographical_compare`. + This comparison ignores the container's ordering `Compare`. -**Returns:** -`true` if the contents of the `x` are lexicographically less than or equal to the contents of `y`, `false` otherwise. + **Returns:** + `true` if the contents of the `x` are lexicographically less than or equal to the contents of `y`, `false` otherwise. -

+

### operator>= -``` -template -bool operator>= -( - const static_flat_multimap& x, - const static_flat_multimap& y -); -``` +1. ``` + template + bool operator>= + ( + const static_flat_multimap& x, + const static_flat_multimap& y + ); + ``` -**Effects:** -Compares the contents of `x` and `y` lexicographically. -The comparison is performed by a function `std::lexicographical_compare`. -This comparison ignores the container's ordering `Compare`. + **Effects:** + Compares the contents of `x` and `y` lexicographically. + The comparison is performed by a function `std::lexicographical_compare`. + This comparison ignores the container's ordering `Compare`. -**Returns:** -`true` if the contents of the `x` are lexicographically greater than or equal to the contents of `y`, `false` otherwise. + **Returns:** + `true` if the contents of the `x` are lexicographically greater than or equal to the contents of `y`, `false` otherwise. -

+

### swap -``` -template -void swap -( - static_flat_multimap& x, - static_flat_multimap& y -); -``` +1. ``` + template + void swap + ( + static_flat_multimap& x, + static_flat_multimap& y + ); + ``` -**Effects:** -Swaps the contents of `x` and `y`. Calls `x.swap(y)`. + **Effects:** + Swaps the contents of `x` and `y`. Calls `x.swap(y)`. -

+

### erase_if -``` -template -typename static_flat_multimap::size_type - erase_if(static_flat_multimap& c, Predicate pred); -``` +1. ``` + template + typename static_flat_multimap::size_type + erase_if(static_flat_multimap& c, Predicate pred); + ``` -**Effects:** -Erases all elements that satisfy the predicate `pred` from the container. + **Effects:** + Erases all elements that satisfy the predicate `pred` from the container. -`pred` is unary predicate which returns `true` if the element should be removed. + `pred` is unary predicate which returns `true` if the element should be removed. -**Returns:** -The number of erased elements. + **Returns:** + The number of erased elements. -**Complexity:** -Linear. + **Complexity:** + Linear. -

+

diff --git a/doc/static_flat_multiset.md b/doc/static_flat_multiset.md index 5d81a29..47a043c 100644 --- a/doc/static_flat_multiset.md +++ b/doc/static_flat_multiset.md @@ -148,1012 +148,891 @@ static constexpr size_type static_capacity = N; ### (constructor) -``` -static_flat_multiset() noexcept(std::is_nothrow_default_constructible::value) -``` -``` -explicit static_flat_multiset(const Compare& comp) noexcept(std::is_nothrow_copy_constructible::value) -``` - -**Effects:** -Constructs an empty container. +1. ``` + static_flat_multiset() noexcept(std::is_nothrow_default_constructible::value) + ``` +2. ``` + explicit static_flat_multiset(const Compare& comp) noexcept(std::is_nothrow_copy_constructible::value) + ``` -**Complexity:** -Constant. + **Effects:** + Constructs an empty container. -

+ **Complexity:** + Constant. +

-``` -template -static_flat_multiset(InputIt first, InputIt last); -``` -``` -template -static_flat_multiset(InputIt first, InputIt last, const Compare& comp); -``` -**Preconditions:** -`std::distance(first, last) <= capacity()` +3. ``` + template + static_flat_multiset(InputIt first, InputIt last); + ``` +4. ``` + template + static_flat_multiset(InputIt first, InputIt last, const Compare& comp); + ``` -**Effects:** -Constructs an empty container and inserts elements from the range `[first, last)`. + **Preconditions:** + `std::distance(first, last) <= capacity()` -**Note:** -This overload participates in overload resolution only if `InputIt` satisfies requirements of [*LegacyInputIterator*](https://en.cppreference.com/w/cpp/named_req/InputIterator). + **Effects:** + Constructs an empty container and inserts elements from the range `[first, last)`. -**Note:** -The behavior is undefined if preconditions are not satisfied. + **Note:** + These overloads participate in overload resolution only if `InputIt` satisfies requirements of [*LegacyInputIterator*](https://en.cppreference.com/w/cpp/named_req/InputIterator). -**Complexity:** -Linear in `std::distance(first, last)`. + **Complexity:** + Linear in `std::distance(first, last)`. -

+

-``` -static_flat_multiset(std::initializer_list ilist); -``` -``` -static_flat_multiset(std::initializer_list ilist, const Compare& comp); -``` - -**Preconditions:** -`ilist.size() <= capacity()` +5. ``` + static_flat_multiset(std::initializer_list ilist); + ``` +6. ``` + static_flat_multiset(std::initializer_list ilist, const Compare& comp); + ``` -**Effects:** -Constructs an empty container and inserts elements from the initializer list `ilist`. + **Preconditions:** + `ilist.size() <= capacity()` -**Note:** -The behavior is undefined if preconditions are not satisfied. + **Effects:** + Constructs an empty container and inserts elements from the initializer list `ilist`. -**Complexity:** -Linear in `ilist.size()`. + **Complexity:** + Linear in `ilist.size()`. -

+

-``` -static_flat_multiset(const static_flat_multiset& other); -``` +7. ``` + static_flat_multiset(const static_flat_multiset& other); + ``` -**Effects:** -Copy constructor. -Constructs the container with the copy of the contents of `other`. + **Effects:** + Copy constructor. + Constructs the container with the copy of the contents of `other`. -**Complexity:** -Linear in `other.size()`. + **Complexity:** + Linear in `other.size()`. -

+

-``` -static_flat_multiset(static_flat_multiset&& other); -``` +8. ``` + static_flat_multiset(static_flat_multiset&& other); + ``` -**Effects:** -Move constructor. -Constructs the container with the contents of `other` using move semantics. + **Effects:** + Move constructor. + Constructs the container with the contents of `other` using move semantics. -`other` is not guaranteed to be empty after the move. + `other` is not guaranteed to be empty after the move. -`other` is in a valid but unspecified state after the move. + `other` is in a valid but unspecified state after the move. -**Complexity:** -Linear in size. + **Complexity:** + Linear in size. -

+

### (destructor) -``` -~static_flat_multiset(); -``` +1. ``` + ~static_flat_multiset(); + ``` -**Effects:** -Destructs the container. The destructors of the elements are called and the used storage is deallocated. + **Effects:** + Destructs the container. The destructors of the elements are called and the used storage is deallocated. -**Complexity:** -Linear in size. + **Complexity:** + Linear in size. -

+

### operator= -``` -static_flat_multiset& operator=(const static_flat_multiset& other); -``` +1. ``` + static_flat_multiset& operator=(const static_flat_multiset& other); + ``` -**Effects:** -Copy assignment operator. -Replaces the contents with a copy of the contents of `other`. + **Effects:** + Copy assignment operator. + Replaces the contents with a copy of the contents of `other`. -**Returns:** -`*this()`. + **Returns:** + `*this()`. -**Complexity:** -Linear in size. + **Complexity:** + Linear in size. -

+

-``` -static_flat_multiset& operator=(static_flat_multiset&& other); -``` - -**Effects:** -Move assignment operator. -Replaces the contents with those of `other` using move semantics. +2. ``` + static_flat_multiset& operator=(static_flat_multiset&& other); + ``` -`other` is not guaranteed to be empty after the move. + **Effects:** + Move assignment operator. + Replaces the contents with those of `other` using move semantics. -`other` is in a valid but unspecified state after the move. + `other` is not guaranteed to be empty after the move. -**Returns:** -`*this()`. + `other` is in a valid but unspecified state after the move. -**Complexity:** -Linear in size. + **Returns:** + `*this()`. -

+ **Complexity:** + Linear in size. +

-``` -static_flat_multiset& operator=(std::initializer_list ilist); -``` -**Preconditions:** -`ilist.size() <= capacity()` +3. ``` + static_flat_multiset& operator=(std::initializer_list ilist); + ``` -**Effects:** -Replaces the contents with those identified by initializer list `ilist`. + **Preconditions:** + `ilist.size() <= capacity()` -**Note:** -The behavior is undefined if preconditions are not satisfied. + **Effects:** + Replaces the contents with those identified by initializer list `ilist`. -**Returns:** -`*this()`. + **Returns:** + `*this()`. -**Complexity:** -Linear in size. + **Complexity:** + Linear in size. -

+

### key_comp -``` -key_compare key_comp() const; -``` +1. ``` + key_compare key_comp() const; + ``` -**Effects:** -Returns the function object that compares the keys, which is a copy of this container's constructor argument `comp`. + **Effects:** + Returns the function object that compares the keys, which is a copy of this container's constructor argument `comp`. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

### value_comp -``` -value_compare value_comp() const; -``` +1. ``` + value_compare value_comp() const; + ``` -**Effects:** -Returns a function object that compares objects of type `value_type`. + **Effects:** + Returns a function object that compares objects of type `value_type`. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

### begin, cbegin -``` -iterator begin() noexcept; -``` -``` -const_iterator begin() const noexcept; -``` -``` -const_iterator cbegin() const noexcept; -``` - -**Effects:** -Returns an iterator to the first element of the container. +1. ``` + iterator begin() noexcept; + ``` +2. ``` + const_iterator begin() const noexcept; + ``` +3. ``` + const_iterator cbegin() const noexcept; + ``` -If the container is empty, the returned iterator will be equal to `end()`. + **Effects:** + Returns an iterator to the first element of the container. + If the container is empty, the returned iterator will be equal to `end()`. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

### end, cend -``` -iterator end() noexcept; -``` -``` -const_iterator end() const noexcept; -``` -``` -const_iterator cend() const noexcept; -``` - -**Effects:** -Returns an iterator to the element following the last element of the container. +1. ``` + iterator end() noexcept; + ``` +2. ``` + const_iterator end() const noexcept; + ``` +3. ``` + const_iterator cend() const noexcept; + ``` -This element acts as a placeholder; attempting to access it results in undefined behavior. + **Effects:** + Returns an iterator to the element following the last element of the container. + This element acts as a placeholder; attempting to access it results in undefined behavior. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

### rbegin, crbegin -``` -reverse_iterator rbegin() noexcept; -``` -``` -const_reverse_iterator rbegin() const noexcept; -``` -``` -const_reverse_iterator crbegin() const noexcept; -``` +1. ``` + reverse_iterator rbegin() noexcept; + ``` +2. ``` + const_reverse_iterator rbegin() const noexcept; + ``` +3. ``` + const_reverse_iterator crbegin() const noexcept; + ``` -**Effects:** -Returns a reverse iterator to the first element of the reversed container. -It corresponds to the last element of the non-reversed container. -If the container is empty, the returned iterator is equal to `rend()`. + **Effects:** + Returns a reverse iterator to the first element of the reversed container. + It corresponds to the last element of the non-reversed container. + If the container is empty, the returned iterator is equal to `rend()`. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

### rend, crend -``` -reverse_iterator rend() noexcept; -``` -``` -const_reverse_iterator rend() const noexcept; -``` -``` -const_reverse_iterator crend() const noexcept; -``` +1. ``` + reverse_iterator rend() noexcept; + ``` +2. ``` + const_reverse_iterator rend() const noexcept; + ``` +3. ``` + const_reverse_iterator crend() const noexcept; + ``` -**Effects:** -Returns a reverse iterator to the element following the last element of the reversed container. -It corresponds to the element preceding the first element of the non-reversed container. -This element acts as a placeholder, attempting to access it results in undefined behavior. + **Effects:** + Returns a reverse iterator to the element following the last element of the reversed container. + It corresponds to the element preceding the first element of the non-reversed container. + This element acts as a placeholder, attempting to access it results in undefined behavior. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

### nth -``` -iterator nth(size_type pos) noexcept; -``` -``` -const_iterator nth(size_type pos) const noexcept; -``` +1. ``` + iterator nth(size_type pos) noexcept; + ``` +2. ``` + const_iterator nth(size_type pos) const noexcept; + ``` -**Preconditions:** -`pos <= size()` + **Preconditions:** + `pos <= size()` -**Effects:** -Returns an iterator to the element at position `pos`. -If `pos == size()`, the returned iterator is equal to `end()`. + **Effects:** + Returns an iterator to the element at position `pos`. -**Complexity:** -Constant. + If `pos == size()`, the returned iterator is equal to `end()`. -

+ **Complexity:** + Constant. + +

### index_of -``` -size_type index_of(const_iterator pos) const noexcept; -``` +1. ``` + size_type index_of(const_iterator pos) const noexcept; + ``` -**Preconditions:** -`cbegin() <= pos && pos <= cend()` + **Preconditions:** + `cbegin() <= pos && pos <= cend()` -**Effects:** -Returns position of the element pointed by iterator `pos`, i.e. `std::distance(begin(), pos)`. + **Effects:** + Returns position of the element pointed by iterator `pos`, i.e. `std::distance(begin(), pos)`. -If `pos == end()`, the returned value is equal to `size()`. + If `pos == end()`, the returned value is equal to `size()`. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

### empty -``` -bool empty() const noexcept; -``` +1. ``` + bool empty() const noexcept; + ``` -**Effects:** -Returns `true` if the container has no elements, i.e. whether `begin() == end()`. + **Effects:** + Returns `true` if the container has no elements, i.e. whether `begin() == end()`. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

### full -``` -bool full() const noexcept; -``` +1. ``` + bool full() const noexcept; + ``` -**Effects:** -Returns `true` if the container is full, i.e. whether `size() == capacity()`. + **Effects:** + Returns `true` if the container is full, i.e. whether `size() == capacity()`. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

### size -``` -size_type size() const noexcept; -``` +1. ``` + size_type size() const noexcept; + ``` -**Effects:** -Returns the number of elements in the container, i.e. `std::distance(begin(), end())`. + **Effects:** + Returns the number of elements in the container, i.e. `std::distance(begin(), end())`. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

### max_size -``` -static constexpr size_type max_size() const noexcept; -``` +1. ``` + static constexpr size_type max_size() const noexcept; + ``` -**Effects:** -Returns the maximum number of elements the container is able to hold, i.e. returns `N`. + **Effects:** + Returns the maximum number of elements the container is able to hold, i.e. `N`. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

### capacity -``` -static constexpr size_type capacity() const noexcept; -``` +1. ``` + static constexpr size_type capacity() const noexcept; + ``` -**Effects:** -Returns the maximum number of elements the container is able to hold, i.e. returns `N`. + **Effects:** + Returns the maximum number of elements the container is able to hold, i.e. `N`. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

### available -``` -size_type available() const noexcept; -``` +1. ``` + size_type available() const noexcept; + ``` -**Effects:** -Returns the number of elements that can be inserted into the container, i.e. returns `capacity() - size()`. + **Effects:** + Returns the number of elements that can be inserted into the container, i.e. `capacity() - size()`. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

### clear -``` -void clear() noexcept; -``` +1. ``` + void clear() noexcept; + ``` -**Effects:** -Erases all elements from the container. -After this call, `size()` returns zero and `capacity()` remains unchanged. + **Effects:** + Erases all elements from the container. + After this call, `size()` returns zero and `capacity()` remains unchanged. -**Complexity:** -Linear in `size()`. + **Complexity:** + Linear in `size()`. -

+

### emplace -``` -template -iterator emplace(Args&&... args); -``` - -**Preconditions:** -`!full()` +1. ``` + template + iterator emplace(Args&&... args); + ``` -**Effects:** -Inserts a new element into the container. + **Preconditions:** + `!full()` -New element is constructed as `value_type(std::forward(args)...)`. + **Effects:** + Inserts a new element into the container. -**Note:** -The behavior is undefined if preconditions are not satisfied. + New element is constructed as `value_type(std::forward(args)...)`. -**Returns:** -Iterator to the inserted element. + **Returns:** + Iterator to the inserted element. -

+

### emplace_hint -``` -template -iterator emplace_hint(const_iterator hint, Args&&... args); -``` +1. ``` + template + iterator emplace_hint(const_iterator hint, Args&&... args); + ``` -**Preconditions:** -1. `!full()` -2. `cbegin() <= hint && hint <= cend()` + **Preconditions:** + 1. `!full()` + 2. `cbegin() <= hint && hint <= cend()` -**Effects:** -Inserts a new element into the container. + **Effects:** + Inserts a new element into the container. -New element is constructed as `value_type(std::forward(args)...)`. + New element is constructed as `value_type(std::forward(args)...)`. -Iterator `hint` is used as a suggestion where to start to search insert position. + Iterator `hint` is used as a suggestion where to start to search insert position. -**Note:** -The behavior is undefined if preconditions are not satisfied. + **Returns:** + Iterator to the inserted element. -**Returns:** -Iterator to the inserted element. - -

+

### insert -``` -iterator insert(const value_type& value); -``` - -**Preconditions:** -`!full()` - -**Effects:** -Inserts copy of `value`. - -**Note:** -The behavior is undefined if preconditions are not satisfied. - -**Returns:** -Iterator to the inserted element. - -

+1. ``` + iterator insert(const value_type& value); + ``` + **Preconditions:** + `!full()` + **Effects:** + Inserts copy of `value`. -``` -iterator insert(value_type&& value); -``` + **Returns:** + Iterator to the inserted element. -**Preconditions:** -`!full()` +

-**Effects:** -Inserts `value` using move semantics. -**Note:** -The behavior is undefined if preconditions are not satisfied. -**Returns:** -Iterator to the inserted element. - -

+2. ``` + iterator insert(value_type&& value); + ``` + **Preconditions:** + `!full()` + **Effects:** + Inserts `value` using move semantics. -``` -iterator insert(const_iterator hint, const value_type& value); -``` + **Returns:** + Iterator to the inserted element. -**Preconditions:** -1. `!full()` -2. `cbegin() <= hint && hint <= cend()` +

-**Effects:** -Inserts copy of `value`. -Iterator `hint` is used as a suggestion where to start to search insert position. -**Note:** -The behavior is undefined if preconditions are not satisfied. +3. ``` + iterator insert(const_iterator hint, const value_type& value); + ``` -**Returns:** -Iterator to the inserted element. + **Preconditions:** + 1. `!full()` + 2. `cbegin() <= hint && hint <= cend()` -

+ **Effects:** + Inserts copy of `value`. + Iterator `hint` is used as a suggestion where to start to search insert position. + **Returns:** + Iterator to the inserted element. -``` -iterator insert(const_iterator hint, value_type&& value); -``` +

-**Preconditions:** -1. `!full()` -2. `cbegin() <= hint && hint <= cend()` -**Effects:** -Inserts `value` using move semantics. -Iterator `hint` is used as a suggestion where to start to search insert position. +4. ``` + iterator insert(const_iterator hint, value_type&& value); + ``` -**Note:** -The behavior is undefined if preconditions are not satisfied. + **Preconditions:** + 1. `!full()` + 2. `cbegin() <= hint && hint <= cend()` -**Returns:** -Iterator to the inserted element. + **Effects:** + Inserts `value` using move semantics. -

+ Iterator `hint` is used as a suggestion where to start to search insert position. + **Returns:** + Iterator to the inserted element. +

-``` -template -void insert(InputIt first, InputIt last); -``` -**Preconditions:** -`std::distance(first, last) <= available()` -**Effects:** -Inserts elements from range `[first, last)`. +5. ``` + template + void insert(InputIt first, InputIt last); + ``` -The call to this function is equivalent to: -``` -while (first != last) -{ - insert(*first); - ++first; -} -``` + **Preconditions:** + `std::distance(first, last) <= available()` -**Note:** -This overload participates in overload resolution only if `InputIt` satisfies requirements of [*LegacyInputIterator*](https://en.cppreference.com/w/cpp/named_req/InputIterator). + **Effects:** + Inserts elements from range `[first, last)`. -**Note:** -The behavior is undefined if preconditions are not satisfied. + The call to this function is equivalent to: + ``` + while (first != last) + { + insert(*first); + ++first; + } + ``` -

+ **Note:** + This overload participates in overload resolution only if `InputIt` satisfies requirements of [*LegacyInputIterator*](https://en.cppreference.com/w/cpp/named_req/InputIterator). +

-``` -void insert(std::initializer_list ilist); -``` -**Preconditions:** -`ilist.size() <= available()` +6. ``` + void insert(std::initializer_list ilist); + ``` -**Effects:** -Inserts elements from initializer list `ilist`. + **Preconditions:** + `ilist.size() <= available()` -The call to this function is equivalent to: -``` -insert(ilist.begin(), ilist.end()); -``` + **Effects:** + Inserts elements from initializer list `ilist`. -**Note:** -The behavior is undefined if preconditions are not satisfied. + The call to this function is equivalent to `insert(ilist.begin(), ilist.end())`. -

+

### erase -``` -iterator erase(iterator pos); -``` -``` -iterator erase(const_iterator pos); -``` - -**Preconditions:** -`cbegin() <= pos && pos < cend()` - -**Effects:** -Removes the element at `pos`. - -**Note:** -The behavior is undefined if preconditions are not satisfied. - -**Returns:** -Iterator following the last removed element. - -

- - - -``` -iterator erase(const_iterator first, const_iterator last); -``` +1. ``` + iterator erase(iterator pos); + ``` +2. ``` + iterator erase(const_iterator pos); + ``` -**Preconditions:** -`cbegin() <= first && first <= last && last <= cend()` + **Preconditions:** + `cbegin() <= pos && pos < cend()` -**Effects:** -Removes the elements in the range `[first, last)`. + **Effects:** + Removes the element at `pos`. -**Note:** -The behavior is undefined if preconditions are not satisfied. + **Returns:** + Iterator following the last removed element. -**Returns:** -Iterator following the last removed element. +

-

+3. ``` + iterator erase(const_iterator first, const_iterator last); + ``` -``` -size_type erase(const Key& key); -``` + **Preconditions:** + `cbegin() <= first && first <= last && last <= cend()` -**Effects:** -Removes all elements with the key equivalent to `key`. + **Effects:** + Removes the elements in the range `[first, last)`. -**Returns:** -Number of elements removed. + **Returns:** + Iterator following the last removed element. -

+

-``` -template -size_type erase(K&& x); -``` +4. ``` + size_type erase(const Key& key); + ``` +5. ``` + template + size_type erase(K&& x); + ``` -**Effects:** -Removes all elements with key that compares equivalent to the value `x`. + **Effects:** + Removes all elements with the key equivalent to `key` or `x`. -**Note:** -This overload participates in overload resolution only if `Compare::is_transparent` exists and is a valid type. It allows calling this function without constructing an instance of `Key`. + **Note:** + Overload (5) participates in overload resolution only if `Compare::is_transparent` exists and is a valid type. It allows calling this function without constructing an instance of `Key`. -**Returns:** -Number of elements removed. + **Returns:** + Number of elements removed. -

+

### swap -``` -void swap(static_flat_multiset& other); -``` +1. ``` + void swap(static_flat_multiset& other); + ``` -**Effects:** -Exchanges the contents of the container with those of `other`. + **Effects:** + Exchanges the contents of the container with those of `other`. -**Complexity:** -Linear in size. + **Complexity:** + Linear in size. -

+

### lower_bound -``` -iterator lower_bound(const Key& key); -``` -``` -const_iterator lower_bound(const Key& key) const; -``` - -**Effects:** -Returns an iterator pointing to the first element with key that is not less than `key`, or `end()` if such an element is not found. - -**Complexity:** -Logarithmic in `size()`. - -

- - - -``` -template -iterator lower_bound(const K& x); -``` -``` -template -const_iterator lower_bound(const K& x) const; -``` +1. ``` + iterator lower_bound(const Key& key); + ``` +2. ``` + const_iterator lower_bound(const Key& key) const; + ``` +3. ``` + template + iterator lower_bound(const K& x); + ``` +4. ``` + template + const_iterator lower_bound(const K& x) const; + ``` -**Effects:** -Returns an iterator pointing to the first element with key that compares not less to the value `x`, or `end()` if such an element is not found. + **Effects:** + Returns an iterator pointing to the first element with key that compares **not less than** `key` or `x`. Returns `end()` if no such element is found. -**Note:** -This overload participates in overload resolution only if `Compare::is_transparent` exists and is a valid type. It allows calling this function without constructing an instance of `Key`. + **Note:** + Overloads (3) and (4) participate in overload resolution only if `Compare::is_transparent` exists and is a valid type. It allows calling these functions without constructing an instance of `Key`. -**Complexity:** -Logarithmic in `size()`. + **Complexity:** + Logarithmic in `size()`. -

+

### upper_bound -``` -iterator upper_bound(const Key& key); -``` -``` -const_iterator upper_bound(const Key& key) const; -``` - -**Effects:** -Returns an iterator pointing to the first element with key that is greater than `key`, or `end()` if such an element is not found. - -**Complexity:** -Logarithmic in `size()`. - -

- - - -``` -template -iterator upper_bound(const K& x); -``` -``` -template -const_iterator upper_bound(const K& x) const; -``` +1. ``` + iterator upper_bound(const Key& key); + ``` +2. ``` + const_iterator upper_bound(const Key& key) const; + ``` +3. ``` + template + iterator upper_bound(const K& x); + ``` +4. ``` + template + const_iterator upper_bound(const K& x) const; + ``` -**Effects:** -Returns an iterator pointing to the first element with key that compares greater to the value `x`, or `end()` if such an element is not found. + **Effects:** + Returns an iterator pointing to the first element with key that compares **greater than** `key` or `x`. Returns `end()` if no such element is found. -**Note:** -This overload participates in overload resolution only if `Compare::is_transparent` exists and is a valid type. It allows calling this function without constructing an instance of `Key`. + **Note:** + Overloads (3) and (4) participate in overload resolution only if `Compare::is_transparent` exists and is a valid type. It allows calling these functions without constructing an instance of `Key`. -**Complexity:** -Logarithmic in `size()`. + **Complexity:** + Logarithmic in `size()`. -

+

### equal_range -``` -std::pair equal_range(const Key& key); -``` -``` -std::pair equal_range(const Key& key) const; -``` - -**Effects:** -Returns a range containing all elements with the key that is equal to `key`: -* The first iterator in pair points to the first element that is not less than `key`, or `end()` if such an element does not exist. -* The second iterator in pair points to the first element that is greater that `key`, or `end()` is such an element does not exist. - -**Complexity:** -Logarithmic in `size()`. - -

- - - -``` -template -std::pair equal_range(const K& x); -``` -``` -template -std::pair equal_range(const K& x) const; -``` +1. ``` + std::pair equal_range(const Key& key); + ``` +2. ``` + std::pair equal_range(const Key& key) const; + ``` +3. ``` + template + std::pair equal_range(const K& x); + ``` +4. ``` + template + std::pair equal_range(const K& x) const; + ``` -**Effects:** -Returns a range containing all elements with the key that compares equal to the value `x`: -* The first iterator in pair points to the first element that compares not less to the value `x`, or `end()` if such an element does not exist. -* The second iterator in pair points to the first element that compares greater to the value `x`, or `end()` is such an element does not exist. + **Effects:** + Returns a range containing all elements with key that compares equivalent to `key` or `x`. + * The first iterator in pair points to the first element that compares **not less than** `key` or `x`. It is equal to `end()` if no such element is found. + * The second iterator in pair points to the first element that compares **greater than** `key` or `x`. It is equal to `end()` is no such element is found. -**Note:** -This overload participates in overload resolution only if `Compare::is_transparent` exists and is a valid type. It allows calling this function without constructing an instance of `Key`. + **Note:** + Overloads (3) and (4) participate in overload resolution only if `Compare::is_transparent` exists and is a valid type. It allows calling these functions without constructing an instance of `Key`. -**Complexity:** -Logarithmic in `size()`. + **Complexity:** + Logarithmic in `size()`. -

+

### find -``` -iterator find(const Key& key); -``` -``` -const_iterator find(const Key& key) const; -``` - -**Effects:** -Returns an iterator to an element with key equivalent to `key`, or `end()` if such an element is not found. If there are several elements with key in the container, any of them may be returned. - -**Complexity:** -Logarithmic in `size()`. - -

- - - -``` -template -iterator find(const K& x); -``` -``` -template -const_iterator find(const K& x) const; -``` +1. ``` + iterator find(const Key& key); + ``` +2. ``` + const_iterator find(const Key& key) const; + ``` +3. ``` + template + iterator find(const K& x); + ``` +4. ``` + template + const_iterator find(const K& x) const; + ``` -**Effects:** -Returns an iterator to an element with key that compares equivalent to `x`, or `end()` if such an element is not found. If there are several elements with key in the container, any of them may be returned. + **Effects:** + Returns an iterator pointing to the element with key equivalent to `key` or `x`. Returns `end()` if no such element is found. + If there are several elements with key in the container, any of them may be returned. -**Note:** -This overload participates in overload resolution only if `Compare::is_transparent` exists and is a valid type. It allows calling this function without constructing an instance of `Key`. + **Note:** + Overloads (3) and (4) participate in overload resolution only if `Compare::is_transparent` exists and is a valid type. It allows calling these functions without constructing an instance of `Key`. -**Complexity:** -Logarithmic in `size()`. + **Complexity:** + Logarithmic in `size()`. -

+

### count -``` -size_type count(const Key& key) const; -``` - -**Effects:** -Returns the number of elements with key equivalent to `key`. - -**Complexity:** -Logarithmic in `size()`. - -

- - +1. ``` + size_type count(const Key& key) const; + ``` +2. ``` + template + size_type count(const K& x) const; + ``` -``` -template -size_type count(const K& x) const; -``` + **Effects:** + Returns the number of elements with key equivalent to `key` or `x`. -**Effects:** -Returns the number of elements with key that compares equivalent to the value `x`. + **Note:** + Overload (2) participates in overload resolution only if `Compare::is_transparent` exists and is a valid type. It allows calling this function without constructing an instance of `Key`. -**Note:** -This overload participates in overload resolution only if `Compare::is_transparent` exists and is a valid type. It allows calling this function without constructing an instance of `Key`. + **Complexity:** + Logarithmic in `size()`. -**Complexity:** -Logarithmic in `size()`. - -

+

### contains -``` -bool contains(const Key& key) const; -``` - -**Effects:** -Returns `true` if the container contains an element with key equivalent to `key`, otherwise returns `false`. - -**Complexity:** -Logarithmic in `size()`. - -

- - - -``` -template -bool contains(const K& x) const; -``` +1. ``` + bool contains(const Key& key) const; + ``` +2. ``` + template + bool contains(const K& x) const; + ``` -**Effects:** -Returns `true` if the container contains an element with the key that compares equivalent to `x`, otherwise returns `false`. + **Effects:** + Returns `true` if the container contains an element with key equivalent to `key` or `x`, otherwise returns `false`. -**Note:** -This overload participates in overload resolution only if `Compare::is_transparent` exists and is a valid type. It allows calling this function without constructing an instance of `Key`. + **Note:** + Overload (2) participates in overload resolution only if `Compare::is_transparent` exists and is a valid type. It allows calling this function without constructing an instance of `Key`. -**Complexity:** -Logarithmic in `size()`. + **Complexity:** + Logarithmic in `size()`. -

+

### data -``` -value_type* data() noexcept; -``` -``` -const value_type* data() const noexcept; -``` +1. ``` + value_type* data() noexcept; + ``` +2. ``` + const value_type* data() const noexcept; + ``` -**Effects:** -Returns pointer to the underlying array serving as element storage. The pointer is such that range `[data(), data() + size())` is always a valid range, even if the container is empty. `data()` is not dereferenceable if the container is empty. + **Effects:** + Returns pointer to the underlying array serving as element storage. The pointer is such that range `[data(), data() + size())` is always a valid range, even if the container is empty. `data()` is not dereferenceable if the container is empty. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

@@ -1161,186 +1040,186 @@ Constant. ### operator== -``` -template -bool operator== -( - const static_flat_multiset& x, - const static_flat_multiset& y -); -``` +1. ``` + template + bool operator== + ( + const static_flat_multiset& x, + const static_flat_multiset& y + ); + ``` -**Effects:** -Checks if the contents of `x` and `y` are equal. + **Effects:** + Checks if the contents of `x` and `y` are equal. -The contents of `x` and `y` are equal if the following conditions hold: -* `x.size() == y.size()` -* Each element in `x` compares equal with the element in `y` at the same position. + The contents of `x` and `y` are equal if the following conditions hold: + * `x.size() == y.size()` + * Each element in `x` compares equal with the element in `y` at the same position. -The comparison is performed by `std::equal`. -This comparison ignores the container's ordering `Compare`. + The comparison is performed by `std::equal`. + This comparison ignores the container's ordering `Compare`. -**Returns:** -Returns `true` if the contents of the `x` and `y` are equal, `false` otherwise. + **Returns:** + Returns `true` if the contents of the `x` and `y` are equal, `false` otherwise. -

+

### operator!= -``` -template -bool operator!= -( - const static_flat_multiset& x, - const static_flat_multiset& y -); -``` +1. ``` + template + bool operator!= + ( + const static_flat_multiset& x, + const static_flat_multiset& y + ); + ``` -**Effects:** -Checks if the contents of `x` and `y` are equal. + **Effects:** + Checks if the contents of `x` and `y` are equal. -For details see `operator==`. + For details see `operator==`. -**Returns:** -Returns `true` if the contents of the `x` and `y` are not equal, `false` otherwise. + **Returns:** + Returns `true` if the contents of the `x` and `y` are not equal, `false` otherwise. -

+

### operator< -``` -template -bool operator< -( - const static_flat_multiset& x, - const static_flat_multiset& y -); -``` +1. ``` + template + bool operator< + ( + const static_flat_multiset& x, + const static_flat_multiset& y + ); + ``` -**Effects:** -Compares the contents of `x` and `y` lexicographically. -The comparison is performed by a function `std::lexicographical_compare`. -This comparison ignores the container's ordering `Compare`. + **Effects:** + Compares the contents of `x` and `y` lexicographically. + The comparison is performed by a function `std::lexicographical_compare`. + This comparison ignores the container's ordering `Compare`. -**Returns:** -`true` if the contents of the `x` are lexicographically less than the contents of `y`, `false` otherwise. + **Returns:** + `true` if the contents of the `x` are lexicographically less than the contents of `y`, `false` otherwise. -

+

### operator> -``` -template -bool operator> -( - const static_flat_multiset& x, - const static_flat_multiset& y -); -``` +1. ``` + template + bool operator> + ( + const static_flat_multiset& x, + const static_flat_multiset& y + ); + ``` -**Effects:** -Compares the contents of lhs and rhs lexicographically. + **Effects:** + Compares the contents of lhs and rhs lexicographically. -The comparison is performed by a function `std::lexicographical_compare`. -This comparison ignores the container's ordering `Compare`. + The comparison is performed by a function `std::lexicographical_compare`. + This comparison ignores the container's ordering `Compare`. -**Returns:** -`true` if the contents of the `x` are lexicographically greater than the contents of `y`, `false` otherwise. + **Returns:** + `true` if the contents of the `x` are lexicographically greater than the contents of `y`, `false` otherwise. -

+

### operator<= -``` -template -bool operator<= -( - const static_flat_multiset& x, - const static_flat_multiset& y -); -``` +1. ``` + template + bool operator<= + ( + const static_flat_multiset& x, + const static_flat_multiset& y + ); + ``` -**Effects:** -Compares the contents of `x` and `y` lexicographically. -The comparison is performed by a function `std::lexicographical_compare`. -This comparison ignores the container's ordering `Compare`. + **Effects:** + Compares the contents of `x` and `y` lexicographically. + The comparison is performed by a function `std::lexicographical_compare`. + This comparison ignores the container's ordering `Compare`. -**Returns:** -`true` if the contents of the `x` are lexicographically less than or equal to the contents of `y`, `false` otherwise. + **Returns:** + `true` if the contents of the `x` are lexicographically less than or equal to the contents of `y`, `false` otherwise. -

+

### operator>= -``` -template -bool operator>= -( - const static_flat_multiset& x, - const static_flat_multiset& y -); -``` +1. ``` + template + bool operator>= + ( + const static_flat_multiset& x, + const static_flat_multiset& y + ); + ``` -**Effects:** -Compares the contents of `x` and `y` lexicographically. -The comparison is performed by a function `std::lexicographical_compare`. -This comparison ignores the container's ordering `Compare`. + **Effects:** + Compares the contents of `x` and `y` lexicographically. + The comparison is performed by a function `std::lexicographical_compare`. + This comparison ignores the container's ordering `Compare`. -**Returns:** -`true` if the contents of the `x` are lexicographically greater than or equal to the contents of `y`, `false` otherwise. + **Returns:** + `true` if the contents of the `x` are lexicographically greater than or equal to the contents of `y`, `false` otherwise. -

+

### swap -``` -template -void swap -( - static_flat_multiset& x, - static_flat_multiset& y -); -``` +1. ``` + template + void swap + ( + static_flat_multiset& x, + static_flat_multiset& y + ); + ``` -**Effects:** -Swaps the contents of `x` and `y`. Calls `x.swap(y)`. + **Effects:** + Swaps the contents of `x` and `y`. Calls `x.swap(y)`. -

+

### erase_if -``` -template -typename static_flat_multiset::size_type - erase_if(static_flat_multiset& c, Predicate pred); -``` +1. ``` + template + typename static_flat_multiset::size_type + erase_if(static_flat_multiset& c, Predicate pred); + ``` -**Effects:** -Erases all elements that satisfy the predicate `pred` from the container. + **Effects:** + Erases all elements that satisfy the predicate `pred` from the container. -`pred` is unary predicate which returns `true` if the element should be removed. + `pred` is unary predicate which returns `true` if the element should be removed. -**Returns:** -The number of erased elements. + **Returns:** + The number of erased elements. -**Complexity:** -Linear. + **Complexity:** + Linear. -

+

diff --git a/doc/static_flat_set.md b/doc/static_flat_set.md index 7e048eb..d5bba0c 100644 --- a/doc/static_flat_set.md +++ b/doc/static_flat_set.md @@ -148,1016 +148,944 @@ static constexpr size_type static_capacity = N; ### (constructor) -``` -static_flat_set() noexcept(std::is_nothrow_default_constructible::value) -``` -``` -explicit static_flat_set(const Compare& comp) noexcept(std::is_nothrow_copy_constructible::value) -``` - -**Effects:** -Constructs an empty container. +1. ``` + static_flat_set() noexcept(std::is_nothrow_default_constructible::value) + ``` +2. ``` + explicit static_flat_set(const Compare& comp) noexcept(std::is_nothrow_copy_constructible::value) + ``` -**Complexity:** -Constant. + **Effects:** + Constructs an empty container. -

+ **Complexity:** + Constant. +

-``` -template -static_flat_set(InputIt first, InputIt last); -``` -``` -template -static_flat_set(InputIt first, InputIt last, const Compare& comp); -``` -**Preconditions:** -`std::distance(first, last) <= capacity()` +3. ``` + template + static_flat_set(InputIt first, InputIt last); + ``` +4. ``` + template + static_flat_set(InputIt first, InputIt last, const Compare& comp); + ``` -**Effects:** -Constructs an empty container and inserts elements from the range `[first, last)`. + **Preconditions:** + `std::distance(first, last) <= capacity()` -**Note:** -This overload participates in overload resolution only if `InputIt` satisfies requirements of [*LegacyInputIterator*](https://en.cppreference.com/w/cpp/named_req/InputIterator). + **Effects:** + Constructs an empty container and inserts elements from the range `[first, last)`. -**Note:** -The behavior is undefined if preconditions are not satisfied. + **Note:** + These overloads participate in overload resolution only if `InputIt` satisfies requirements of [*LegacyInputIterator*](https://en.cppreference.com/w/cpp/named_req/InputIterator). -**Complexity:** -Linear in `std::distance(first, last)`. + **Complexity:** + Linear in `std::distance(first, last)`. -

+

-``` -static_flat_set(std::initializer_list ilist); -``` -``` -static_flat_set(std::initializer_list ilist, const Compare& comp); -``` - -**Preconditions:** -`ilist.size() <= capacity()` +5. ``` + static_flat_set(std::initializer_list ilist); + ``` +6. ``` + static_flat_set(std::initializer_list ilist, const Compare& comp); + ``` -**Effects:** -Constructs an empty container and inserts elements from the initializer list `ilist`. + **Preconditions:** + `ilist.size() <= capacity()` -**Note:** -The behavior is undefined if preconditions are not satisfied. + **Effects:** + Constructs an empty container and inserts elements from the initializer list `ilist`. -**Complexity:** -Linear in `ilist.size()`. + **Complexity:** + Linear in `ilist.size()`. -

+

-``` -static_flat_set(const static_flat_set& other); -``` +7. ``` + static_flat_set(const static_flat_set& other); + ``` -**Effects:** -Copy constructor. -Constructs the container with the copy of the contents of `other`. + **Effects:** + Copy constructor. + Constructs the container with the copy of the contents of `other`. -**Complexity:** -Linear in `other.size()`. + **Complexity:** + Linear in `other.size()`. -

+

-``` -static_flat_set(static_flat_set&& other); -``` +8. ``` + static_flat_set(static_flat_set&& other); + ``` -**Effects:** -Move constructor. -Constructs the container with the contents of `other` using move semantics. + **Effects:** + Move constructor. + Constructs the container with the contents of `other` using move semantics. -`other` is not guaranteed to be empty after the move. + `other` is not guaranteed to be empty after the move. -`other` is in a valid but unspecified state after the move. + `other` is in a valid but unspecified state after the move. -**Complexity:** -Linear in size. + **Complexity:** + Linear in size. -

+

### (destructor) -``` -~static_flat_set(); -``` +1. ``` + ~static_flat_set(); + ``` -**Effects:** -Destructs the container. The destructors of the elements are called and the used storage is deallocated. + **Effects:** + Destructs the container. The destructors of the elements are called and the used storage is deallocated. -**Complexity:** -Linear in size. + **Complexity:** + Linear in size. -

+

### operator= -``` -static_flat_set& operator=(const static_flat_set& other); -``` - -**Effects:** -Copy assignment operator. -Replaces the contents with a copy of the contents of `other`. +1. ``` + static_flat_set& operator=(const static_flat_set& other); + ``` -**Returns:** -`*this()`. + **Effects:** + Copy assignment operator. + Replaces the contents with a copy of the contents of `other`. -**Complexity:** -Linear in size. + **Returns:** + `*this()`. -

+ **Complexity:** + Linear in size. +

-``` -static_flat_set& operator=(static_flat_set&& other); -``` -**Effects:** -Move assignment operator. -Replaces the contents with those of `other` using move semantics. +2. ``` + static_flat_set& operator=(static_flat_set&& other); + ``` -`other` is not guaranteed to be empty after the move. + **Effects:** + Move assignment operator. + Replaces the contents with those of `other` using move semantics. -`other` is in a valid but unspecified state after the move. + `other` is not guaranteed to be empty after the move. -**Returns:** -`*this()`. + `other` is in a valid but unspecified state after the move. -**Complexity:** -Linear in size. + **Returns:** + `*this()`. -

+ **Complexity:** + Linear in size. +

-``` -static_flat_set& operator=(std::initializer_list ilist); -``` -**Preconditions:** -`ilist.size() <= capacity()` +3. ``` + static_flat_set& operator=(std::initializer_list ilist); + ``` -**Effects:** -Replaces the contents with those identified by initializer list `ilist`. + **Preconditions:** + `ilist.size() <= capacity()` -**Note:** -The behavior is undefined if preconditions are not satisfied. + **Effects:** + Replaces the contents with those identified by initializer list `ilist`. -**Returns:** -`*this()`. + **Returns:** + `*this()`. -**Complexity:** -Linear in size. + **Complexity:** + Linear in size. -

+

### key_comp -``` -key_compare key_comp() const; -``` +1. ``` + key_compare key_comp() const; + ``` -**Effects:** -Returns the function object that compares the keys, which is a copy of this container's constructor argument `comp`. + **Effects:** + Returns the function object that compares the keys, which is a copy of this container's constructor argument `comp`. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

### value_comp -``` -value_compare value_comp() const; -``` +1. ``` + value_compare value_comp() const; + ``` -**Effects:** -Returns a function object that compares objects of type `value_type`. + **Effects:** + Returns a function object that compares objects of type `value_type`. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

### begin, cbegin -``` -iterator begin() noexcept; -``` -``` -const_iterator begin() const noexcept; -``` -``` -const_iterator cbegin() const noexcept; -``` - -**Effects:** -Returns an iterator to the first element of the container. +1. ``` + iterator begin() noexcept; + ``` +2. ``` + const_iterator begin() const noexcept; + ``` +3. ``` + const_iterator cbegin() const noexcept; + ``` -If the container is empty, the returned iterator will be equal to `end()`. + **Effects:** + Returns an iterator to the first element of the container. + If the container is empty, the returned iterator will be equal to `end()`. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

### end, cend -``` -iterator end() noexcept; -``` -``` -const_iterator end() const noexcept; -``` -``` -const_iterator cend() const noexcept; -``` - -**Effects:** -Returns an iterator to the element following the last element of the container. +1. ``` + iterator end() noexcept; + ``` +2. ``` + const_iterator end() const noexcept; + ``` +3. ``` + const_iterator cend() const noexcept; + ``` -This element acts as a placeholder; attempting to access it results in undefined behavior. + **Effects:** + Returns an iterator to the element following the last element of the container. + This element acts as a placeholder; attempting to access it results in undefined behavior. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

### rbegin, crbegin -``` -reverse_iterator rbegin() noexcept; -``` -``` -const_reverse_iterator rbegin() const noexcept; -``` -``` -const_reverse_iterator crbegin() const noexcept; -``` +1. ``` + reverse_iterator rbegin() noexcept; + ``` +2. ``` + const_reverse_iterator rbegin() const noexcept; + ``` +3. ``` + const_reverse_iterator crbegin() const noexcept; + ``` -**Effects:** -Returns a reverse iterator to the first element of the reversed container. -It corresponds to the last element of the non-reversed container. -If the container is empty, the returned iterator is equal to `rend()`. + **Effects:** + Returns a reverse iterator to the first element of the reversed container. + It corresponds to the last element of the non-reversed container. + If the container is empty, the returned iterator is equal to `rend()`. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

### rend, crend -``` -reverse_iterator rend() noexcept; -``` -``` -const_reverse_iterator rend() const noexcept; -``` -``` -const_reverse_iterator crend() const noexcept; -``` +1. ``` + reverse_iterator rend() noexcept; + ``` +2. ``` + const_reverse_iterator rend() const noexcept; + ``` +3. ``` + const_reverse_iterator crend() const noexcept; + ``` -**Effects:** -Returns a reverse iterator to the element following the last element of the reversed container. -It corresponds to the element preceding the first element of the non-reversed container. -This element acts as a placeholder, attempting to access it results in undefined behavior. + **Effects:** + Returns a reverse iterator to the element following the last element of the reversed container. + It corresponds to the element preceding the first element of the non-reversed container. + This element acts as a placeholder, attempting to access it results in undefined behavior. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

### nth -``` -iterator nth(size_type pos) noexcept; -``` -``` -const_iterator nth(size_type pos) const noexcept; -``` +1. ``` + iterator nth(size_type pos) noexcept; + ``` +2. ``` + const_iterator nth(size_type pos) const noexcept; + ``` -**Preconditions:** -`pos <= size()` + **Preconditions:** + `pos <= size()` -**Effects:** -Returns an iterator to the element at position `pos`. -If `pos == size()`, the returned iterator is equal to `end()`. + **Effects:** + Returns an iterator to the element at position `pos`. -**Complexity:** -Constant. + If `pos == size()`, the returned iterator is equal to `end()`. -

+ **Complexity:** + Constant. + +

### index_of -``` -size_type index_of(const_iterator pos) const noexcept; -``` +1. ``` + size_type index_of(const_iterator pos) const noexcept; + ``` -**Preconditions:** -`cbegin() <= pos && pos <= cend()` + **Preconditions:** + `cbegin() <= pos && pos <= cend()` -**Effects:** -Returns position of the element pointed by iterator `pos`, i.e. `std::distance(begin(), pos)`. + **Effects:** + Returns position of the element pointed by iterator `pos`, i.e. `std::distance(begin(), pos)`. -If `pos == end()`, the returned value is equal to `size()`. + If `pos == end()`, the returned value is equal to `size()`. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

### empty -``` -bool empty() const noexcept; -``` +1. ``` + bool empty() const noexcept; + ``` -**Effects:** -Returns `true` if the container has no elements, i.e. whether `begin() == end()`. + **Effects:** + Returns `true` if the container has no elements, i.e. whether `begin() == end()`. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

### full -``` -bool full() const noexcept; -``` +1. ``` + bool full() const noexcept; + ``` -**Effects:** -Returns `true` if the container is full, i.e. whether `size() == capacity()`. + **Effects:** + Returns `true` if the container is full, i.e. whether `size() == capacity()`. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

### size -``` -size_type size() const noexcept; -``` +1. ``` + size_type size() const noexcept; + ``` -**Effects:** -Returns the number of elements in the container, i.e. `std::distance(begin(), end())`. + **Effects:** + Returns the number of elements in the container, i.e. `std::distance(begin(), end())`. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

### max_size -``` -static constexpr size_type max_size() const noexcept; -``` +1. ``` + static constexpr size_type max_size() const noexcept; + ``` -**Effects:** -Returns the maximum number of elements the container is able to hold, i.e. returns `N`. + **Effects:** + Returns the maximum number of elements the container is able to hold, i.e. `N`. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

### capacity -``` -static constexpr size_type capacity() const noexcept; -``` +1. ``` + static constexpr size_type capacity() const noexcept; + ``` -**Effects:** -Returns the maximum number of elements the container is able to hold, i.e. returns `N`. + **Effects:** + Returns the maximum number of elements the container is able to hold, i.e. `N`. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

### available -``` -size_type available() const noexcept; -``` +1. ``` + size_type available() const noexcept; + ``` -**Effects:** -Returns the number of elements that can be inserted into the container, i.e. returns `capacity() - size()`. + **Effects:** + Returns the number of elements that can be inserted into the container, i.e. `capacity() - size()`. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

### clear -``` -void clear() noexcept; -``` +1. ``` + void clear() noexcept; + ``` -**Effects:** -Erases all elements from the container. -After this call, `size()` returns zero and `capacity()` remains unchanged. + **Effects:** + Erases all elements from the container. + After this call, `size()` returns zero and `capacity()` remains unchanged. -**Complexity:** -Linear in `size()`. + **Complexity:** + Linear in `size()`. -

+

### emplace -``` -template -std::pair emplace(Args&&... args); -``` - -**Preconditions:** -`!full()` +1. ``` + template + std::pair emplace(Args&&... args); + ``` -**Effects:** -Inserts a new element into the container only if the container does not already contain an element with an equivalent key. + **Preconditions:** + `!full()` -New element is constructed as `value_type(std::forward(args)...)`. + **Effects:** + Inserts new element into the container if the container doesn't already contain an element with an equivalent key. -The element may be constructed even if there already is an element with the key in the container, in which case the newly constructed element will be destroyed immediately. + New element is constructed as `value_type(std::forward(args)...)`. -**Note:** -The behavior is undefined if preconditions are not satisfied. + The element may be constructed even if there already is an element with the key in the container, in which case the newly constructed element will be destroyed immediately. -**Returns:** -Pair consisting of an iterator to the inserted element, or the already-existing element if no insertion happened, and a `bool` denoting whether the insertion took place (`true` if insertion happened, `false` if it did not). + **Returns:** + The iterator component points to the inserted element or to the already existing element. The `bool` component is `true` if insertion happened and `false` if it did not. -

+

### emplace_hint -``` -template -iterator emplace_hint(const_iterator hint, Args&&... args); -``` - -**Preconditions:** -1. `!full()` -2. `cbegin() <= hint && hint <= cend()` +1. ``` + template + iterator emplace_hint(const_iterator hint, Args&&... args); + ``` -**Effects:** -Inserts a new element into the container only if the container does not already contain an element with an equivalent key. + **Preconditions:** + 1. `!full()` + 2. `cbegin() <= hint && hint <= cend()` -New element is constructed as `value_type(std::forward(args)...)`. + **Effects:** + Inserts new element into the container if the container doesn't already contain an element with an equivalent key. -The element may be constructed even if there already is an element with the key in the container, in which case the newly constructed element will be destroyed immediately. + New element is constructed as `value_type(std::forward(args)...)`. -Iterator `hint` is used as a suggestion where to start to search insert position. + The element may be constructed even if there already is an element with the key in the container, in which case the newly constructed element will be destroyed immediately. -**Note:** -The behavior is undefined if preconditions are not satisfied. + Iterator `hint` is used as a suggestion where to start to search insert position. -**Returns:** -Iterator to the inserted element or to the already existing element. + **Returns:** + Iterator to the inserted element or to the already existing element. -

+

### insert -``` -std::pair insert(const value_type& value); -``` +1. ``` + std::pair insert(const value_type& value); + ``` -**Preconditions:** -`!full()` + **Preconditions:** + `!full()` -**Effects:** -Inserts copy of `value` only if the container does not already contain an element with an key equivalent to the key of `value`. + **Effects:** + Inserts copy of `value` if the container doesn't already contain an element with an equivalent key. -**Note:** -The behavior is undefined if preconditions are not satisfied. + **Returns:** + The iterator component points to the inserted element or to the already existing element. The `bool` component is `true` if insertion happened and `false` if it did not. -**Returns:** -Pair consisting of an iterator to the inserted element, or the already-existing element if no insertion happened, and a `bool` denoting whether the insertion took place (`true` if insertion happened, `false` if it did not). +

-

+2. ``` + std::pair insert(value_type&& value); + ``` -``` -std::pair insert(value_type&& value); -``` + **Preconditions:** + `!full()` -**Preconditions:** -`!full()` + **Effects:** + Inserts `value` using move semantics if the container doesn't already contain an element with an equivalent key. -**Effects:** -Inserts `value` using move semantics only if the container does not already contain an element with an key equivalent to the key of `value`. + **Returns:** + The iterator component points to the inserted element or to the already existing element. The `bool` component is `true` if insertion happened and `false` if it did not. -**Note:** -The behavior is undefined if preconditions are not satisfied. +

-**Returns:** -Pair consisting of an iterator to the inserted element, or the already-existing element if no insertion happened, and a `bool` denoting whether the insertion took place (`true` if insertion happened, `false` if it did not). -

+3. ``` + template + std::pair insert(K&& x); + ``` + **Preconditions:** + `!full()` -``` -iterator insert(const_iterator hint, const value_type& value); -``` + **Effects:** + Inserts new element if the container doesn't already contain an element with a key equivalent to `x`. -**Preconditions:** -1. `!full()` -2. `cbegin() <= hint && hint <= cend()` + New element is constructed as `value_type(std::forward(x))`. -**Effects:** -Inserts copy of `value` only if the container does not already contain an element with an key equivalent to the key of `value`. + **Note:** This overload participates in overload resolution only if `Compare::is_transparent` exists and is a valid type. It allows calling this function without constructing an instance of `Key`. -Iterator `hint` is used as a suggestion where to start to search insert position. + **Returns:** + The iterator component points to the inserted element or to the already existing element. The `bool` component is `true` if insertion happened and `false` if it did not. -**Note:** -The behavior is undefined if preconditions are not satisfied. +

-**Returns:** -Iterator to the inserted element or to the already existing element. -

+4. ``` + iterator insert(const_iterator hint, const value_type& value); + ``` + **Preconditions:** + 1. `!full()` + 2. `cbegin() <= hint && hint <= cend()` -``` -iterator insert(const_iterator hint, value_type&& value); -``` + **Effects:** + Inserts copy of `value` if the container doesn't already contain an element with an equivalent key. -**Preconditions:** -1. `!full()` -2. `cbegin() <= hint && hint <= cend()` + Iterator `hint` is used as a suggestion where to start to search insert position. -**Effects:** -Inserts `value` using move semantics only if the container does not already contain an element with an key equivalent to the key of `value`. + **Returns:** + Iterator to the inserted element or to the already existing element. -Iterator `hint` is used as a suggestion where to start to search insert position. +

-**Note:** -The behavior is undefined if preconditions are not satisfied. -**Returns:** -Iterator to the inserted element or to the already existing element. -

+5. ``` + iterator insert(const_iterator hint, value_type&& value); + ``` + **Preconditions:** + 1. `!full()` + 2. `cbegin() <= hint && hint <= cend()` + **Effects:** + Inserts `value` using move semantics if the container doesn't already contain an element with an equivalent key. -``` -template -void insert(InputIt first, InputIt last); -``` + Iterator `hint` is used as a suggestion where to start to search insert position. -**Preconditions:** -`std::distance(first, last) <= available()` + **Returns:** + Iterator to the inserted element or to the already existing element. -**Effects:** -Inserts elements from range `[first, last)`. +

-The call to this function is equivalent to: -``` -while (first != last) -{ - insert(*first); - ++first; -} -``` -**Note:** -This overload participates in overload resolution only if `InputIt` satisfies requirements of [*LegacyInputIterator*](https://en.cppreference.com/w/cpp/named_req/InputIterator). -**Note:** -The behavior is undefined if preconditions are not satisfied. +6. ``` + template + iterator insert(const_iterator hint, K&& x); + ``` -

+ **Preconditions:** + 1. `!full()` + 2. `cbegin() <= hint && hint <= cend()` + **Effects:** + Inserts new element if the container doesn't already contain an element with a key equivalent to `x`. + New element is constructed as `value_type(std::forward(x))`. -``` -void insert(std::initializer_list ilist); -``` + Iterator `hint` is used as a suggestion where to start to search insert position. -**Preconditions:** -`ilist.size() <= available()` + **Note:** This overload participates in overload resolution only if all following conditions are satisfied: + 1. `Compare::is_transparent` exists and is a valid type. It allows calling this function without constructing an instance of `Key`. + 2. `std::is_convertible_v` is `false`. + 3. `std::is_convertible_v` is `false`. -**Effects:** -Inserts elements from initializer list `ilist`. + **Returns:** + Iterator to the inserted element or to the already existing element. -The call to this function is equivalent to: -``` -insert(ilist.begin(), ilist.end()); -``` +

-**Note:** -The behavior is undefined if preconditions are not satisfied. - -

+7. ``` + template + void insert(InputIt first, InputIt last); + ``` -### erase + **Preconditions:** + `std::distance(first, last) <= available()` -``` -iterator erase(iterator pos); -``` -``` -iterator erase(const_iterator pos); -``` + **Effects:** + Inserts elements from range `[first, last)`. -**Preconditions:** -`cbegin() <= pos && pos < cend()` + The call to this function is equivalent to: + ``` + while (first != last) + { + insert(*first); + ++first; + } + ``` -**Effects:** -Removes the element at `pos`. + **Note:** + This overload participates in overload resolution only if `InputIt` satisfies requirements of [*LegacyInputIterator*](https://en.cppreference.com/w/cpp/named_req/InputIterator). -**Note:** -The behavior is undefined if preconditions are not satisfied. +

-**Returns:** -Iterator following the last removed element. -

+8. ``` + void insert(std::initializer_list ilist); + ``` + **Preconditions:** + `ilist.size() <= available()` -``` -iterator erase(const_iterator first, const_iterator last); -``` + **Effects:** + Inserts elements from initializer list `ilist`. -**Preconditions:** -`cbegin() <= first && first <= last && last <= cend()` + The call to this function is equivalent to `insert(ilist.begin(), ilist.end())`. -**Effects:** -Removes the elements in the range `[first, last)`. +

-**Note:** -The behavior is undefined if preconditions are not satisfied. -**Returns:** -Iterator following the last removed element. -

+### erase +1. ``` + iterator erase(iterator pos); + ``` +2. ``` + iterator erase(const_iterator pos); + ``` + **Preconditions:** + `cbegin() <= pos && pos < cend()` -``` -size_type erase(const Key& key); -``` + **Effects:** + Removes the element at `pos`. -**Effects:** -Removes the element (if one exists) with the key equivalent to `key`. + **Returns:** + Iterator following the last removed element. -**Returns:** -Number of elements removed (0 or 1). +

-

+3. ``` + iterator erase(const_iterator first, const_iterator last); + ``` -``` -template -size_type erase(K&& x); -``` + **Preconditions:** + `cbegin() <= first && first <= last && last <= cend()` -**Effects:** -Removes the element (if one exists) with key that compares equivalent to the value `x`. + **Effects:** + Removes the elements in the range `[first, last)`. -**Note:** -This overload participates in overload resolution only if `Compare::is_transparent` exists and is a valid type. It allows calling this function without constructing an instance of `Key`. + **Returns:** + Iterator following the last removed element. -**Returns:** -Number of elements removed (0 or 1). +

-

+4. ``` + size_type erase(const Key& key); + ``` +5. ``` + template + size_type erase(K&& x); + ``` -### swap + **Effects:** + Removes the element (if one exists) with the key equivalent to `key` or `x`. -``` -void swap(static_flat_set& other); -``` + **Note:** + Overload (5) participates in overload resolution only if `Compare::is_transparent` exists and is a valid type. It allows calling this function without constructing an instance of `Key`. -**Effects:** -Exchanges the contents of the container with those of `other`. + **Returns:** + Number of elements removed (0 or 1). -**Complexity:** -Linear in size. +

-

+### swap -### lower_bound +1. ``` + void swap(static_flat_set& other); + ``` -``` -iterator lower_bound(const Key& key); -``` -``` -const_iterator lower_bound(const Key& key) const; -``` + **Effects:** + Exchanges the contents of the container with those of `other`. -**Effects:** -Returns an iterator pointing to the first element with key that is not less than `key`, or `end()` if such an element is not found. + **Complexity:** + Linear in size. -**Complexity:** -Logarithmic in `size()`. +

-

+### lower_bound -``` -template -iterator lower_bound(const K& x); -``` -``` -template -const_iterator lower_bound(const K& x) const; -``` +1. ``` + iterator lower_bound(const Key& key); + ``` +2. ``` + const_iterator lower_bound(const Key& key) const; + ``` +3. ``` + template + iterator lower_bound(const K& x); + ``` +4. ``` + template + const_iterator lower_bound(const K& x) const; + ``` -**Effects:** -Returns an iterator pointing to the first element with key that compares not less to the value `x`, or `end()` if such an element is not found. + **Effects:** + Returns an iterator pointing to the first element with key that compares **not less than** `key` or `x`. Returns `end()` if no such element is found. -**Note:** -This overload participates in overload resolution only if `Compare::is_transparent` exists and is a valid type. It allows calling this function without constructing an instance of `Key`. + **Note:** + Overloads (3) and (4) participate in overload resolution only if `Compare::is_transparent` exists and is a valid type. It allows calling these functions without constructing an instance of `Key`. -**Complexity:** -Logarithmic in `size()`. + **Complexity:** + Logarithmic in `size()`. -

+

### upper_bound -``` -iterator upper_bound(const Key& key); -``` -``` -const_iterator upper_bound(const Key& key) const; -``` - -**Effects:** -Returns an iterator pointing to the first element with key that is greater than `key`, or `end()` if such an element is not found. - -**Complexity:** -Logarithmic in `size()`. - -

- - - -``` -template -iterator upper_bound(const K& x); -``` -``` -template -const_iterator upper_bound(const K& x) const; -``` +1. ``` + iterator upper_bound(const Key& key); + ``` +2. ``` + const_iterator upper_bound(const Key& key) const; + ``` +3. ``` + template + iterator upper_bound(const K& x); + ``` +4. ``` + template + const_iterator upper_bound(const K& x) const; + ``` -**Effects:** -Returns an iterator pointing to the first element with key that compares greater to the value `x`, or `end()` if such an element is not found. + **Effects:** + Returns an iterator pointing to the first element with key that compares **greater than** `key` or `x`. Returns `end()` if no such element is found. -**Note:** -This overload participates in overload resolution only if `Compare::is_transparent` exists and is a valid type. It allows calling this function without constructing an instance of `Key`. + **Note:** + Overloads (3) and (4) participate in overload resolution only if `Compare::is_transparent` exists and is a valid type. It allows calling these functions without constructing an instance of `Key`. -**Complexity:** -Logarithmic in `size()`. + **Complexity:** + Logarithmic in `size()`. -

+

### equal_range -``` -std::pair equal_range(const Key& key); -``` -``` -std::pair equal_range(const Key& key) const; -``` - -**Effects:** -Returns a range containing all elements with the key that is equal to `key`: -* The first iterator in pair points to the first element that is not less than `key`, or `end()` if such an element does not exist. -* The second iterator in pair points to the first element that is greater that `key`, or `end()` is such an element does not exist. - -**Complexity:** -Logarithmic in `size()`. - -

- - - -``` -template -std::pair equal_range(const K& x); -``` -``` -template -std::pair equal_range(const K& x) const; -``` +1. ``` + std::pair equal_range(const Key& key); + ``` +2. ``` + std::pair equal_range(const Key& key) const; + ``` +3. ``` + template + std::pair equal_range(const K& x); + ``` +4. ``` + template + std::pair equal_range(const K& x) const; + ``` -**Effects:** -Returns a range containing all elements with the key that compares equal to the value `x`: -* The first iterator in pair points to the first element that compares not less to the value `x`, or `end()` if such an element does not exist. -* The second iterator in pair points to the first element that compares greater to the value `x`, or `end()` is such an element does not exist. + **Effects:** + Returns a range containing all elements with key that compares equivalent to `key` or `x`. + * The first iterator in pair points to the first element that compares **not less than** `key` or `x`. It is equal to `end()` if no such element is found. + * The second iterator in pair points to the first element that compares **greater than** `key` or `x`. It is equal to `end()` is no such element is found. -**Note:** -This overload participates in overload resolution only if `Compare::is_transparent` exists and is a valid type. It allows calling this function without constructing an instance of `Key`. + **Note:** + Overloads (3) and (4) participate in overload resolution only if `Compare::is_transparent` exists and is a valid type. It allows calling these functions without constructing an instance of `Key`. -**Complexity:** -Logarithmic in `size()`. + **Complexity:** + Logarithmic in `size()`. -

+

### find -``` -iterator find(const Key& key); -``` -``` -const_iterator find(const Key& key) const; -``` - -**Effects:** -Returns an iterator to an element with key equivalent to `key`, or `end()` if such an element is not found. - -**Complexity:** -Logarithmic in `size()`. - -

- - - -``` -template -iterator find(const K& x); -``` -``` -template -const_iterator find(const K& x) const; -``` +1. ``` + iterator find(const Key& key); + ``` +2. ``` + const_iterator find(const Key& key) const; + ``` +3. ``` + template + iterator find(const K& x); + ``` +4. ``` + template + const_iterator find(const K& x) const; + ``` -**Effects:** -Returns an iterator to an element with key that compares equivalent to `x`, or `end()` if such an element is not found. + **Effects:** + Returns an iterator pointing to the element with key equivalent to `key` or `x`. Returns `end()` if no such element is found. -**Note:** -This overload participates in overload resolution only if `Compare::is_transparent` exists and is a valid type. It allows calling this function without constructing an instance of `Key`. + **Note:** + Overloads (3) and (4) participate in overload resolution only if `Compare::is_transparent` exists and is a valid type. It allows calling these functions without constructing an instance of `Key`. -**Complexity:** -Logarithmic in `size()`. + **Complexity:** + Logarithmic in `size()`. -

+

### count -``` -size_type count(const Key& key) const; -``` - -**Effects:** -Returns the number of elements with key equivalent to `key`, which is either 1 or 0 since this container does not allow duplicates. - -**Complexity:** -Logarithmic in `size()`. - -

- - - -``` -template -size_type count(const K& x) const; -``` +1. ``` + size_type count(const Key& key) const; + ``` +2. ``` + template + size_type count(const K& x) const; + ``` -**Effects:** -Returns the number of elements with key that compares equivalent to `x`, which is either 1 or 0 since this container does not allow duplicates. + **Effects:** + Returns the number of elements with key equivalent to `key` or `x`, which is either 1 or 0 since this container does not allow duplicates. -**Note:** -This overload participates in overload resolution only if `Compare::is_transparent` exists and is a valid type. It allows calling this function without constructing an instance of `Key`. + **Note:** + Overload (2) participates in overload resolution only if `Compare::is_transparent` exists and is a valid type. It allows calling this function without constructing an instance of `Key`. -**Complexity:** -Logarithmic in `size()`. + **Complexity:** + Logarithmic in `size()`. -

+

### contains -``` -bool contains(const Key& key) const; -``` - -**Effects:** -Returns `true` if the container contains an element with key equivalent to `key`, otherwise returns `false`. - -**Complexity:** -Logarithmic in `size()`. - -

- - - -``` -template -bool contains(const K& x) const; -``` +1. ``` + bool contains(const Key& key) const; + ``` +2. ``` + template + bool contains(const K& x) const; + ``` -**Effects:** -Returns `true` if the container contains an element with the key that compares equivalent to `x`, otherwise returns `false`. + **Effects:** + Returns `true` if the container contains an element with key equivalent to `key` or `x`, otherwise returns `false`. -**Note:** -This overload participates in overload resolution only if `Compare::is_transparent` exists and is a valid type. It allows calling this function without constructing an instance of `Key`. + **Note:** + Overload (2) participates in overload resolution only if `Compare::is_transparent` exists and is a valid type. It allows calling this function without constructing an instance of `Key`. -**Complexity:** -Logarithmic in `size()`. + **Complexity:** + Logarithmic in `size()`. -

+

### data -``` -value_type* data() noexcept; -``` -``` -const value_type* data() const noexcept; -``` +1. ``` + value_type* data() noexcept; + ``` +2. ``` + const value_type* data() const noexcept; + ``` -**Effects:** -Returns pointer to the underlying array serving as element storage. The pointer is such that range `[data(), data() + size())` is always a valid range, even if the container is empty. `data()` is not dereferenceable if the container is empty. + **Effects:** + Returns pointer to the underlying array serving as element storage. The pointer is such that range `[data(), data() + size())` is always a valid range, even if the container is empty. `data()` is not dereferenceable if the container is empty. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

@@ -1165,186 +1093,186 @@ Constant. ### operator== -``` -template -bool operator== -( - const static_flat_set& x, - const static_flat_set& y -); -``` +1. ``` + template + bool operator== + ( + const static_flat_set& x, + const static_flat_set& y + ); + ``` -**Effects:** -Checks if the contents of `x` and `y` are equal. + **Effects:** + Checks if the contents of `x` and `y` are equal. -The contents of `x` and `y` are equal if the following conditions hold: -* `x.size() == y.size()` -* Each element in `x` compares equal with the element in `y` at the same position. + The contents of `x` and `y` are equal if the following conditions hold: + * `x.size() == y.size()` + * Each element in `x` compares equal with the element in `y` at the same position. -The comparison is performed by `std::equal`. -This comparison ignores the container's ordering `Compare`. + The comparison is performed by `std::equal`. + This comparison ignores the container's ordering `Compare`. -**Returns:** -Returns `true` if the contents of the `x` and `y` are equal, `false` otherwise. + **Returns:** + Returns `true` if the contents of the `x` and `y` are equal, `false` otherwise. -

+

### operator!= -``` -template -bool operator!= -( - const static_flat_set& x, - const static_flat_set& y -); -``` +1. ``` + template + bool operator!= + ( + const static_flat_set& x, + const static_flat_set& y + ); + ``` -**Effects:** -Checks if the contents of `x` and `y` are equal. + **Effects:** + Checks if the contents of `x` and `y` are equal. -For details see `operator==`. + For details see `operator==`. -**Returns:** -Returns `true` if the contents of the `x` and `y` are not equal, `false` otherwise. + **Returns:** + Returns `true` if the contents of the `x` and `y` are not equal, `false` otherwise. -

+

### operator< -``` -template -bool operator< -( - const static_flat_set& x, - const static_flat_set& y -); -``` +1. ``` + template + bool operator< + ( + const static_flat_set& x, + const static_flat_set& y + ); + ``` -**Effects:** -Compares the contents of `x` and `y` lexicographically. -The comparison is performed by a function `std::lexicographical_compare`. -This comparison ignores the container's ordering `Compare`. + **Effects:** + Compares the contents of `x` and `y` lexicographically. + The comparison is performed by a function `std::lexicographical_compare`. + This comparison ignores the container's ordering `Compare`. -**Returns:** -`true` if the contents of the `x` are lexicographically less than the contents of `y`, `false` otherwise. + **Returns:** + `true` if the contents of the `x` are lexicographically less than the contents of `y`, `false` otherwise. -

+

### operator> -``` -template -bool operator> -( - const static_flat_set& x, - const static_flat_set& y -); -``` +1. ``` + template + bool operator> + ( + const static_flat_set& x, + const static_flat_set& y + ); + ``` -**Effects:** -Compares the contents of lhs and rhs lexicographically. + **Effects:** + Compares the contents of lhs and rhs lexicographically. -The comparison is performed by a function `std::lexicographical_compare`. -This comparison ignores the container's ordering `Compare`. + The comparison is performed by a function `std::lexicographical_compare`. + This comparison ignores the container's ordering `Compare`. -**Returns:** -`true` if the contents of the `x` are lexicographically greater than the contents of `y`, `false` otherwise. + **Returns:** + `true` if the contents of the `x` are lexicographically greater than the contents of `y`, `false` otherwise. -

+

### operator<= -``` -template -bool operator<= -( - const static_flat_set& x, - const static_flat_set& y -); -``` +1. ``` + template + bool operator<= + ( + const static_flat_set& x, + const static_flat_set& y + ); + ``` -**Effects:** -Compares the contents of `x` and `y` lexicographically. -The comparison is performed by a function `std::lexicographical_compare`. -This comparison ignores the container's ordering `Compare`. + **Effects:** + Compares the contents of `x` and `y` lexicographically. + The comparison is performed by a function `std::lexicographical_compare`. + This comparison ignores the container's ordering `Compare`. -**Returns:** -`true` if the contents of the `x` are lexicographically less than or equal to the contents of `y`, `false` otherwise. + **Returns:** + `true` if the contents of the `x` are lexicographically less than or equal to the contents of `y`, `false` otherwise. -

+

### operator>= -``` -template -bool operator>= -( - const static_flat_set& x, - const static_flat_set& y -); -``` +1. ``` + template + bool operator>= + ( + const static_flat_set& x, + const static_flat_set& y + ); + ``` -**Effects:** -Compares the contents of `x` and `y` lexicographically. -The comparison is performed by a function `std::lexicographical_compare`. -This comparison ignores the container's ordering `Compare`. + **Effects:** + Compares the contents of `x` and `y` lexicographically. + The comparison is performed by a function `std::lexicographical_compare`. + This comparison ignores the container's ordering `Compare`. -**Returns:** -`true` if the contents of the `x` are lexicographically greater than or equal to the contents of `y`, `false` otherwise. + **Returns:** + `true` if the contents of the `x` are lexicographically greater than or equal to the contents of `y`, `false` otherwise. -

+

### swap -``` -template -void swap -( - static_flat_set& x, - static_flat_set& y -); -``` +1. ``` + template + void swap + ( + static_flat_set& x, + static_flat_set& y + ); + ``` -**Effects:** -Swaps the contents of `x` and `y`. Calls `x.swap(y)`. + **Effects:** + Swaps the contents of `x` and `y`. Calls `x.swap(y)`. -

+

### erase_if -``` -template -typename static_flat_set::size_type - erase_if(static_flat_set& c, Predicate pred); -``` +1. ``` + template + typename static_flat_set::size_type + erase_if(static_flat_set& c, Predicate pred); + ``` -**Effects:** -Erases all elements that satisfy the predicate `pred` from the container. + **Effects:** + Erases all elements that satisfy the predicate `pred` from the container. -`pred` is unary predicate which returns `true` if the element should be removed. + `pred` is unary predicate which returns `true` if the element should be removed. -**Returns:** -The number of erased elements. + **Returns:** + The number of erased elements. -**Complexity:** -Linear. + **Complexity:** + Linear. -

+

diff --git a/doc/static_unordered_flat_map.md b/doc/static_unordered_flat_map.md index e0e7b31..c326b50 100644 --- a/doc/static_unordered_flat_map.md +++ b/doc/static_unordered_flat_map.md @@ -163,1095 +163,1121 @@ static constexpr size_type static_capacity = N; ### (constructor) -``` -static_unordered_flat_map() noexcept(std::is_nothrow_default_constructible::value) -``` -``` -explicit static_unordered_flat_map(const KeyEqual& equal) noexcept(std::is_nothrow_copy_constructible::value) -``` - -**Effects:** -Constructs an empty container. - -

+1. ``` + static_unordered_flat_map() noexcept(std::is_nothrow_default_constructible::value) + ``` +2. ``` + explicit static_unordered_flat_map(const KeyEqual& equal) noexcept(std::is_nothrow_copy_constructible::value) + ``` + **Effects:** + Constructs an empty container. +

-``` -template -static_unordered_flat_map(InputIt first, InputIt last); -``` -``` -template -static_unordered_flat_map(InputIt first, InputIt last, const KeyEqual& equal); -``` -**Preconditions:** -`std::distance(first, last) <= capacity()` -**Effects:** -Constructs an empty container and inserts elements from the range `[first, last)`. +3. ``` + template + static_unordered_flat_map(InputIt first, InputIt last); + ``` +4. ``` + template + static_unordered_flat_map(InputIt first, InputIt last, const KeyEqual& equal); + ``` -**Note:** -This overload participates in overload resolution only if `InputIt` satisfies requirements of [*LegacyInputIterator*](https://en.cppreference.com/w/cpp/named_req/InputIterator). + **Preconditions:** + `std::distance(first, last) <= capacity()` -**Note:** -The behavior is undefined if preconditions are not satisfied. + **Effects:** + Constructs an empty container and inserts elements from the range `[first, last)`. -**Complexity:** -Linear in `std::distance(first, last)`. + **Note:** + These overloads participate in overload resolution only if `InputIt` satisfies requirements of [*LegacyInputIterator*](https://en.cppreference.com/w/cpp/named_req/InputIterator). -

+ **Complexity:** + Linear in `std::distance(first, last)`. +

-``` -static_unordered_flat_map(std::initializer_list ilist); -``` -``` -static_unordered_flat_map(std::initializer_list ilist, const KeyEqual& equal); -``` -**Preconditions:** -`ilist.size() <= capacity()` +5. ``` + static_unordered_flat_map(std::initializer_list ilist); + ``` +6. ``` + static_unordered_flat_map(std::initializer_list ilist, const KeyEqual& equal); + ``` -**Effects:** -Constructs an empty container and inserts elements from the initializer list `ilist`. + **Preconditions:** + `ilist.size() <= capacity()` -**Note:** -The behavior is undefined if preconditions are not satisfied. + **Effects:** + Constructs an empty container and inserts elements from the initializer list `ilist`. -**Complexity:** -Linear in `ilist.size()`. + **Complexity:** + Linear in `ilist.size()`. -

+

-``` -static_unordered_flat_map(const static_unordered_flat_map& other); -``` +7. ``` + static_unordered_flat_map(const static_unordered_flat_map& other); + ``` -**Effects:** -Copy constructor. -Constructs the container with the copy of the contents of `other`. + **Effects:** + Copy constructor. + Constructs the container with the copy of the contents of `other`. -**Complexity:** -Linear in size. + **Complexity:** + Linear in size. -

+

-``` -static_unordered_flat_map(static_unordered_flat_map&& other); -``` +8. ``` + static_unordered_flat_map(static_unordered_flat_map&& other); + ``` -**Effects:** -Move constructor. -Constructs the container with the contents of `other` using move semantics. + **Effects:** + Move constructor. + Constructs the container with the contents of `other` using move semantics. -`other` is not guaranteed to be empty after the move. + `other` is not guaranteed to be empty after the move. -`other` is in a valid but unspecified state after the move. + `other` is in a valid but unspecified state after the move. -**Complexity:** -Linear in size. + **Complexity:** + Linear in size. -

+

### (destructor) -``` -~static_unordered_flat_map(); -``` +1. ``` + ~static_unordered_flat_map(); + ``` -**Effects:** -Destructs the container. The destructors of the elements are called and the used storage is deallocated. + **Effects:** + Destructs the container. The destructors of the elements are called and the used storage is deallocated. -**Complexity:** -Linear in size. + **Complexity:** + Linear in size. -

+

### operator= -``` -static_unordered_flat_map& operator=(const static_unordered_flat_map& other); -``` - -**Effects:** -Copy assignment operator. -Replaces the contents with a copy of the contents of `other`. +1. ``` + static_unordered_flat_map& operator=(const static_unordered_flat_map& other); + ``` -**Returns:** -`*this()`. + **Effects:** + Copy assignment operator. + Replaces the contents with a copy of the contents of `other`. -**Complexity:** -Linear in size. + **Returns:** + `*this()`. -

+ **Complexity:** + Linear in size. +

-``` -static_unordered_flat_map& operator=(static_unordered_flat_map&& other); -``` -**Effects:** -Move assignment operator. -Replaces the contents with those of `other` using move semantics. +2. ``` + static_unordered_flat_map& operator=(static_unordered_flat_map&& other); + ``` -`other` is not guaranteed to be empty after the move. + **Effects:** + Move assignment operator. + Replaces the contents with those of `other` using move semantics. -`other` is in a valid but unspecified state after the move. + `other` is not guaranteed to be empty after the move. -**Returns:** -`*this()`. + `other` is in a valid but unspecified state after the move. -**Complexity:** -Linear in size. + **Returns:** + `*this()`. -

+ **Complexity:** + Linear in size. +

-``` -static_unordered_flat_map& operator=(std::initializer_list ilist); -``` -**Preconditions:** -`ilist.size() <= capacity()` +3. ``` + static_unordered_flat_map& operator=(std::initializer_list ilist); + ``` -**Effects:** -Replaces the contents with those identified by initializer list `ilist`. + **Preconditions:** + `ilist.size() <= capacity()` -**Note:** -The behavior is undefined if preconditions are not satisfied. + **Effects:** + Replaces the contents with those identified by initializer list `ilist`. -**Returns:** -`*this()`. + **Returns:** + `*this()`. -**Complexity:** -Linear in size. + **Complexity:** + Linear in size. -

+

### key_eq -``` -key_equal key_eq() const; -``` +1. ``` + key_equal key_eq() const; + ``` -**Effects:** -Returns the function object that compares keys for equality, which is a copy of this container's constructor argument `equal`. + **Effects:** + Returns the function object that compares keys for equality, which is a copy of this container's constructor argument `equal`. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

### value_eq -``` -value_equal value_eq() const; -``` +1. ``` + value_equal value_eq() const; + ``` -**Effects:** -Returns a function object that compares objects of type `value_type`. + **Effects:** + Returns a function object that compares objects of type `value_type`. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

### begin, cbegin -``` -iterator begin() noexcept; -``` -``` -const_iterator begin() const noexcept; -``` -``` -const_iterator cbegin() const noexcept; -``` - -**Effects:** -Returns an iterator to the first element of the container. +1. ``` + iterator begin() noexcept; + ``` +2. ``` + const_iterator begin() const noexcept; + ``` +3. ``` + const_iterator cbegin() const noexcept; + ``` -If the container is empty, the returned iterator will be equal to `end()`. + **Effects:** + Returns an iterator to the first element of the container. + If the container is empty, the returned iterator will be equal to `end()`. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

### end, cend -``` -iterator end() noexcept; -``` -``` -const_iterator end() const noexcept; -``` -``` -const_iterator cend() const noexcept; -``` - -**Effects:** -Returns an iterator to the element following the last element of the container. +1. ``` + iterator end() noexcept; + ``` +2. ``` + const_iterator end() const noexcept; + ``` +3. ``` + const_iterator cend() const noexcept; + ``` -This element acts as a placeholder; attempting to access it results in undefined behavior. + **Effects:** + Returns an iterator to the element following the last element of the container. + This element acts as a placeholder; attempting to access it results in undefined behavior. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

### nth -``` -iterator nth(size_type pos) noexcept; -``` -``` -const_iterator nth(size_type pos) const noexcept; -``` +1. ``` + iterator nth(size_type pos) noexcept; + ``` +2. ``` + const_iterator nth(size_type pos) const noexcept; + ``` -**Preconditions:** -`pos <= size()` + **Preconditions:** + `pos <= size()` -**Effects:** -Returns an iterator to the element at position `pos`. -If `pos == size()`, the returned iterator is equal to `end()`. + **Effects:** + Returns an iterator to the element at position `pos`. -**Complexity:** -Constant. + If `pos == size()`, the returned iterator is equal to `end()`. -

+ **Complexity:** + Constant. + +

### index_of -``` -size_type index_of(const_iterator pos) const noexcept; -``` +1. ``` + size_type index_of(const_iterator pos) const noexcept; + ``` -**Preconditions:** -`cbegin() <= pos && pos <= cend()` + **Preconditions:** + `cbegin() <= pos && pos <= cend()` -**Effects:** -Returns position of the element pointed by iterator `pos`, i.e. `std::distance(begin(), pos)`. + **Effects:** + Returns position of the element pointed by iterator `pos`, i.e. `std::distance(begin(), pos)`. -If `pos == end()`, the returned value is equal to `size()`. + If `pos == end()`, the returned value is equal to `size()`. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

### empty -``` -bool empty() const noexcept; -``` +1. ``` + bool empty() const noexcept; + ``` -**Effects:** -Returns `true` if the container has no elements, i.e. whether `begin() == end()`. + **Effects:** + Returns `true` if the container has no elements, i.e. whether `begin() == end()`. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

### full -``` -bool full() const noexcept; -``` +1. ``` + bool full() const noexcept; + ``` -**Effects:** -Returns `true` if the container is full, i.e. whether `size() == capacity()`. + **Effects:** + Returns `true` if the container is full, i.e. whether `size() == capacity()`. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

### size -``` -size_type size() const noexcept; -``` +1. ``` + size_type size() const noexcept; + ``` -**Effects:** -Returns the number of elements in the container, i.e. `std::distance(begin(), end())`. + **Effects:** + Returns the number of elements in the container, i.e. `std::distance(begin(), end())`. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

### max_size -``` -static constexpr size_type max_size() const noexcept; -``` +1. ``` + static constexpr size_type max_size() const noexcept; + ``` -**Effects:** -Returns the maximum number of elements the container is able to hold, i.e. returns `N`. + **Effects:** + Returns the maximum number of elements the container is able to hold, i.e. `N`. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

### capacity -``` -static constexpr size_type capacity() const noexcept; -``` +1. ``` + static constexpr size_type capacity() const noexcept; + ``` -**Effects:** -Returns the maximum number of elements the container is able to hold, i.e. returns `N`. + **Effects:** + Returns the maximum number of elements the container is able to hold, i.e. `N`. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

### available -``` -size_type available() const noexcept; -``` +1. ``` + size_type available() const noexcept; + ``` -**Effects:** -Returns the number of elements that can be inserted into the container, i.e. returns `capacity() - size()`. + **Effects:** + Returns the number of elements that can be inserted into the container, i.e. `capacity() - size()`. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

### clear -``` -void clear() noexcept; -``` +1. ``` + void clear() noexcept; + ``` -**Effects:** -Erases all elements from the container. -After this call, `size()` returns zero and `capacity()` remains unchanged. + **Effects:** + Erases all elements from the container. + After this call, `size()` returns zero and `capacity()` remains unchanged. -**Complexity:** -Linear in `size()`. + **Complexity:** + Linear in `size()`. -

+

### emplace -``` -template -std::pair emplace(Args&&... args); -``` - -**Preconditions:** -`!full()` +1. ``` + template + std::pair emplace(Args&&... args); + ``` -**Effects:** -Inserts a new element into the container only if the container does not already contain an element with an equivalent key. + **Preconditions:** + `!full()` -New element is constructed as `value_type(std::forward(args)...)`. + **Effects:** + Inserts new element into the container if the container doesn't already contain an element with an equivalent key. -The element may be constructed even if there already is an element with the key in the container, in which case the newly constructed element will be destroyed immediately. + New element is constructed as `value_type(std::forward(args)...)`. -**Note:** -The behavior is undefined if preconditions are not satisfied. + The element may be constructed even if there already is an element with the key in the container, in which case the newly constructed element will be destroyed immediately. -**Returns:** -Pair consisting of an iterator to the inserted element, or the already-existing element if no insertion happened, and a `bool` denoting whether the insertion took place (`true` if insertion happened, `false` if it did not). + **Returns:** + The iterator component points to the inserted element or to the already existing element. The `bool` component is `true` if insertion happened and `false` if it did not. -

+

### emplace_hint -``` -template -iterator emplace_hint(const_iterator hint, Args&&... args); -``` +1. ``` + template + iterator emplace_hint(const_iterator hint, Args&&... args); + ``` -**Preconditions:** -1. `!full()` -2. `cbegin() <= hint && hint <= cend()` + **Preconditions:** + 1. `!full()` + 2. `cbegin() <= hint && hint <= cend()` -**Effects:** -Inserts a new element into the container only if the container does not already contain an element with an equivalent key. + **Effects:** + Inserts new element into the container if the container doesn't already contain an element with an equivalent key. -New element is constructed as `value_type(std::forward(args)...)`. + New element is constructed as `value_type(std::forward(args)...)`. -The element may be constructed even if there already is an element with the key in the container, in which case the newly constructed element will be destroyed immediately. + The element may be constructed even if there already is an element with the key in the container, in which case the newly constructed element will be destroyed immediately. -Iterator `hint` is used as a suggestion where to start to search insert position. + Iterator `hint` is used as a suggestion where to start to search insert position. -**Note:** -The behavior is undefined if preconditions are not satisfied. + Iterator `hint` is ignored due to container's underlying storage implementation. This overload exists just to have this container compatible with standard C++ containers as much as possible. -**Returns:** -Iterator to the inserted element or to the already existing element. + **Returns:** + Iterator to the inserted element or to the already existing element. -

+

### insert -``` -std::pair insert(const value_type& value); -``` +1. ``` + std::pair insert(const value_type& value); + ``` -**Preconditions:** -`!full()` + **Preconditions:** + `!full()` -**Effects:** -Inserts copy of `value` only if the container does not already contain an element with an key equivalent to the key of `value`. + **Effects:** + Inserts copy of `value` if the container doesn't already contain an element with an equivalent key. -**Note:** -The behavior is undefined if preconditions are not satisfied. + **Returns:** + The iterator component points to the inserted element or to the already existing element. The `bool` component is `true` if insertion happened and `false` if it did not. -**Returns:** -Pair consisting of an iterator to the inserted element, or the already-existing element if no insertion happened, and a `bool` denoting whether the insertion took place (`true` if insertion happened, `false` if it did not). +

-

+2. ``` + std::pair insert(value_type&& value); + ``` -``` -std::pair insert(value_type&& value); -``` + **Preconditions:** + `!full()` -**Preconditions:** -`!full()` + **Effects:** + Inserts `value` using move semantics if the container doesn't already contain an element with an equivalent key. -**Effects:** -Inserts `value` using move semantics only if the container does not already contain an element with an key equivalent to the key of `value`. + **Returns:** + The iterator component points to the inserted element or to the already existing element. The `bool` component is `true` if insertion happened and `false` if it did not. -**Note:** -The behavior is undefined if preconditions are not satisfied. +

-**Returns:** -Pair consisting of an iterator to the inserted element, or the already-existing element if no insertion happened, and a `bool` denoting whether the insertion took place (`true` if insertion happened, `false` if it did not). -

+3. ``` + template + std::pair insert(P&& value); + ``` + **Preconditions:** + `!full()` -``` -template -std::pair insert(P&& value); -``` + **Effects:** + Inserts new element into the container if the container doesn't already contain an element with an equivalent key. -**Preconditions:** -`!full()` + New element is constructed as `value_type(std::forward

(value))`. -**Effects:** -Inserts a new element into the container only if the container does not already contain an element with an equivalent key. + **Note:** + This overload participates in overload resolution only if `std::is_constructible::value` is `true`. -New element is constructed as `value_type(std::forward

(value))`. + **Returns:** + The iterator component points to the inserted element or to the already existing element. The `bool` component is `true` if insertion happened and `false` if it did not. -**Note:** -This overload participates in overload resolution only if `std::is_constructible::value` is `true`. +

-**Note:** -The behavior is undefined if preconditions are not satisfied. -**Returns:** -Pair consisting of an iterator to the inserted element, or the already-existing element if no insertion happened, and a `bool` denoting whether the insertion took place (`true` if insertion happened, `false` if it did not). -

+4. ``` + iterator insert(const_iterator hint, const value_type& value); + ``` + **Preconditions:** + 1. `!full()` + 2. `cbegin() <= hint && hint <= cend()` + **Effects:** + Inserts copy of `value` if the container doesn't already contain an element with an equivalent key. -``` -iterator insert(const_iterator hint, const value_type& value); -``` + Iterator `hint` is used as a suggestion where to start to search insert position. -**Preconditions:** -1. `!full()` -2. `cbegin() <= hint && hint <= cend()` + Iterator `hint` is ignored due to container's underlying storage implementation. This overload exists just to have this container compatible with standard C++ containers as much as possible. -**Effects:** -Inserts copy of `value` only if the container does not already contain an element with an key equivalent to the key of `value`. + **Returns:** + Iterator to the inserted element or to the already existing element. -Iterator `hint` is used as a suggestion where to start to search insert position. +

-**Note:** -The behavior is undefined if preconditions are not satisfied. -**Returns:** -Iterator to the inserted element or to the already existing element. -

+5. ``` + iterator insert(const_iterator hint, value_type&& value); + ``` + **Preconditions:** + 1. `!full()` + 2. `cbegin() <= hint && hint <= cend()` + **Effects:** + Inserts `value` using move semantics if the container doesn't already contain an element with an equivalent key. -``` -iterator insert(const_iterator hint, value_type&& value); -``` + Iterator `hint` is used as a suggestion where to start to search insert position. -**Preconditions:** -1. `!full()` -2. `cbegin() <= hint && hint <= cend()` + Iterator `hint` is ignored due to container's underlying storage implementation. This overload exists just to have this container compatible with standard C++ containers as much as possible. -**Effects:** -Inserts `value` using move semantics only if the container does not already contain an element with an key equivalent to the key of `value`. + **Returns:** + Iterator to the inserted element or to the already existing element. -Iterator `hint` is used as a suggestion where to start to search insert position. +

-**Note:** -The behavior is undefined if preconditions are not satisfied. -**Returns:** -Iterator to the inserted element or to the already existing element. -

+6. ``` + template + iterator insert(const_iterator hint, P&& value); + ``` + **Preconditions:** + 1. `!full()` + 2. `cbegin() <= hint && hint <= cend()` + **Effects:** + Inserts new element into the container if the container doesn't already contain an element with an equivalent key. -``` -template -iterator insert(const_iterator hint, P&& value); -``` + New element is constructed as `value_type(std::forward

(value))`. -**Preconditions:** -1. `!full()` -2. `cbegin() <= hint && hint <= cend()` + Iterator `hint` is used as a suggestion where to start to search insert position. -**Effects:** -Inserts a new element into the container only if the container does not already contain an element with an equivalent key. + Iterator `hint` is ignored due to container's underlying storage implementation. This overload exists just to have this container compatible with standard C++ containers as much as possible. -New element is constructed as `value_type(std::forward

(value))`. + **Note:** + This overload participates in overload resolution only if `std::is_constructible::value` is `true`. -Iterator `hint` is used as a suggestion where to start to search insert position. + **Returns:** + Iterator to the inserted element or to the already existing element. -**Note:** -This overload participates in overload resolution only if `std::is_constructible::value` is `true`. +

-**Note:** -The behavior is undefined if preconditions are not satisfied. -**Returns:** -Iterator to the inserted element or to the already existing element. -

+7. ``` + template + void insert(InputIt first, InputIt last); + ``` + **Preconditions:** + `std::distance(first, last) <= available()` + **Effects:** + Inserts elements from range `[first, last)`. -``` -template -void insert(InputIt first, InputIt last); -``` + The call to this function is equivalent to: + ``` + while (first != last) + { + insert(*first); + ++first; + } + ``` -**Preconditions:** -`std::distance(first, last) <= available()` + **Note:** + This overload participates in overload resolution only if `InputIt` satisfies requirements of [*LegacyInputIterator*](https://en.cppreference.com/w/cpp/named_req/InputIterator). -**Effects:** -Inserts elements from range `[first, last)`. +

-The call to this function is equivalent to: -``` -while (first != last) -{ - insert(*first); - ++first; -} -``` -**Note:** -This overload participates in overload resolution only if `InputIt` satisfies requirements of [*LegacyInputIterator*](https://en.cppreference.com/w/cpp/named_req/InputIterator). -**Note:** -The behavior is undefined if preconditions are not satisfied. +8. ``` + void insert(std::initializer_list ilist); + ``` -

+ **Preconditions:** + `ilist.size() <= available()` + **Effects:** + Inserts elements from initializer list `ilist`. + The call to this function is equivalent to `insert(ilist.begin(), ilist.end())`. -``` -void insert(std::initializer_list ilist); -``` +

-**Preconditions:** -`ilist.size() <= available()` -**Effects:** -Inserts elements from initializer list `ilist`. -The call to this function is equivalent to: -``` -insert(ilist.begin(), ilist.end()); -``` +### insert_or_assign -**Note:** -The behavior is undefined if preconditions are not satisfied. +1. ``` + template + std::pair insert_or_assign(const Key& key, M&& obj); + ``` +2. ``` + template + std::pair insert_or_assign(Key&& key, M&& obj); + ``` +3. ``` + template + std::pair insert_or_assign(K&& key, M&& obj); + ``` -

+ **Preconditions:** + `!full()` + **Effects:** + If a key equivalent to `key` already exists in the container, assigns `std::forward(obj)` to the mapped type corresponding to the key `key`. If the key does not exist, inserts the new element. + * **Overload (1):** New element is constructed as -### insert_or_assign + ``` + value_type( std::piecewise_construct, + std::forward_as_tuple(key), + std::forward_as_tuple(std::forward(obj)) ) + ``` -``` -template -std::pair insert_or_assign(const Key& key, M&& obj); -``` -``` -template -std::pair insert_or_assign(Key&& key, M&& obj); -``` + **Note:** This overload participates in overload resolution only if `std::is_assignable_v` is `true`. -**Preconditions:** -`!full()` + * **Overload (2):** New element is constructed as -**Effects:** -If a key equivalent to `key` already exists in the container, assigns `std::forward(obj)` to the mapped type corresponding to the key `key`. If the key does not exist, inserts the new element. + ``` + value_type( std::piecewise_construct, + std::forward_as_tuple(std::move(key)), + std::forward_as_tuple(std::forward(obj)) ) + ``` -* If the first overload is used, the new element is constructed as - ``` - value_type( std::piecewise_construct, - std::forward_as_tuple(key), - std::forward_as_tuple(std::forward(obj)) ) - ``` -* If the second overload is used, the new element is constructed as - ``` - value_type( std::piecewise_construct, - std::forward_as_tuple(std::move(key)), - std::forward_as_tuple(std::forward(obj)) ) - ``` + **Note:** This overload participates in overload resolution only if `std::is_assignable_v` is `true`. -**Note:** -This overload participates in overload resolution only if `std::is_assignable_v` is `true`. + * **Overload (3):** New element is constructed as -**Note:** -The behavior is undefined if preconditions are not satisfied. + ``` + value_type( std::piecewise_construct, + std::forward_as_tuple(std::forward(key)), + std::forward_as_tuple(std::forward(obj)) ) + ``` -**Returns:** -A pair of iterator and `bool`: -* The iterator component points at the element that was inserted or updated. -* The `bool` component is `true` if the insertion took place and `false` if the assignment took place. + **Note:** This overload participates in overload resolution only if all following conditions are satisfied: + 1. `KeyEqual::is_transparent` exists and is a valid type. It allows calling this function without constructing an instance of `Key`. + 2. `std::is_assignable_v` is `true`. -

+ **Returns:** + The iterator component points to the inserted element or to the updated element. The `bool` component is `true` if insertion took place and `false` if assignment took place. +

-``` -template -iterator insert_or_assign(const_iterator hint, const Key& key, M&& obj); -``` -``` -template -iterator insert_or_assign(const_iterator hint, Key&& key, M&& obj); -``` -**Preconditions:** -1. `!full()` -2. `cbegin() <= hint && hint <= cend()` +4. ``` + template + iterator insert_or_assign(const_iterator hint, const Key& key, M&& obj); + ``` +5. ``` + template + iterator insert_or_assign(const_iterator hint, Key&& key, M&& obj); + ``` +6. ``` + template + iterator insert_or_assign(const_iterator hint, K&& key, M&& obj); + ``` -**Effects:** -Same as `insert_or_assign` overloads that do not take `hint`. + **Preconditions:** + 1. `!full()` + 2. `cbegin() <= hint && hint <= cend()` -Iterator `hint` is used as a suggestion where to start to search insert position. + **Effects:** + If a key equivalent to `key` already exists in the container, assigns `std::forward(obj)` to the mapped type corresponding to the key `key`. If the key does not exist, inserts the new element. -**Note:** -This overload participates in overload resolution only if `std::is_assignable_v` is `true`. + Iterator `hint` is used as a suggestion where to start to search insert position. -**Note:** -The behavior is undefined if preconditions are not satisfied. + Iterator `hint` is ignored due to container's underlying storage implementation. These overloads exist just to have this container compatible with standard C++ containers as much as possible. -**Returns:** -Iterator to the element that was inserted or updated. + * **Overload (4):** New element is constructed as -

+ ``` + value_type( std::piecewise_construct, + std::forward_as_tuple(key), + std::forward_as_tuple(std::forward(obj)) ) + ``` + **Note:** This overload participates in overload resolution only if `std::is_assignable_v` is `true`. + * **Overload (5):** New element is constructed as -### try_emplace + ``` + value_type( std::piecewise_construct, + std::forward_as_tuple(std::move(key)), + std::forward_as_tuple(std::forward(obj)) ) + ``` -``` -template -std::pair try_emplace(const Key& key, Args&&... args); -``` -``` -template -std::pair try_emplace(Key&& key, Args&&... args); -``` + **Note:** This overload participates in overload resolution only if `std::is_assignable_v` is `true`. -**Preconditions:** -`!full()` - -**Effects:** -If a key equivalent to `key` already exists in the container, does nothing. Otherwise, behaves like `emplace`. - -* If the first overload is used, the new element is constructed as - ``` - value_type( std::piecewise_construct, - std::forward_as_tuple(key), - std::forward_as_tuple(std::forward(args)...) ) - ``` -* If the second overload is used, the new element is constructed as - ``` - value_type( std::piecewise_construct, - std::forward_as_tuple(std::move(key)), - std::forward_as_tuple(std::forward(args)...) ) - ``` - -**Note:** -The behavior is undefined if preconditions are not satisfied. - -**Returns:** -A pair of iterator and `bool`: -* The iterator component points at the inserted element or to the already existing element. -* The `bool` component is `true` if insertion happened and `false` if it did not. + * **Overload (6):** New element is constructed as -

+ ``` + value_type( std::piecewise_construct, + std::forward_as_tuple(std::forward(key)), + std::forward_as_tuple(std::forward(obj)) ) + ``` + **Note:** This overload participates in overload resolution only if all following conditions are satisfied: + 1. `KeyEqual::is_transparent` exists and is a valid type. It allows calling this function without constructing an instance of `Key`. + 2. `std::is_assignable_v` is `true`. + **Returns:** + Iterator to the element that was inserted or updated. -``` -template -iterator try_emplace(const_iterator hint, const Key& key, Args&&... args); -``` -``` -template -iterator try_emplace(const_iterator hint, Key&& key, Args&&... args); -``` +

-**Preconditions:** -1. `!full()` -2. `cbegin() <= hint && hint <= cend()` -**Effects:** -Same as `try_emplace` overloads that do not take `hint`. -Iterator `hint` is used as a suggestion where to start to search insert position. - -**Note:** -The behavior is undefined if preconditions are not satisfied. +### try_emplace -**Returns:** -Iterator to the inserted element or to the already existing element. +1. ``` + template + std::pair try_emplace(const Key& key, Args&&... args); + ``` +2. ``` + template + std::pair try_emplace(Key&& key, Args&&... args); + ``` +3. ``` + template + std::pair try_emplace(K&& key, Args&&... args); + ``` -

+ **Preconditions:** + `!full()` + **Effects:** + If a key equivalent to `key` already exists in the container, does nothing. + Otherwise, inserts a new element into the container. + * **Overload (1):** Behaves like `emplace` except that the element is constructed as -### erase + ``` + value_type( std::piecewise_construct, + std::forward_as_tuple(key), + std::forward_as_tuple(std::forward(args)...) ) + ``` -``` -iterator erase(iterator pos); -``` -``` -iterator erase(const_iterator pos); -``` + * **Overload (2):** Behaves like `emplace` except that the element is constructed as -**Preconditions:** -`cbegin() <= pos && pos < cend()` + ``` + value_type( std::piecewise_construct, + std::forward_as_tuple(std::move(key)), + std::forward_as_tuple(std::forward(args)...) ) + ``` -**Effects:** -Removes the element at `pos`. + * **Overload (3):** Behaves like `emplace` except that the element is constructed as -**Note:** -The behavior is undefined if preconditions are not satisfied. + ``` + value_type( std::piecewise_construct, + std::forward_as_tuple(std::forward(key)), + std::forward_as_tuple(std::forward(args)...) ) + ``` -**Returns:** -Iterator following the last removed element. + **Note:** This overload participates in overload resolution only if all following conditions are satisfied: + 1. `KeyEqual::is_transparent` exists and is a valid type. It allows calling this function without constructing an instance of `Key`. + 2. `std::is_convertible_v` is `false`. + 3. `std::is_convertible_v` is `false`. -

+ **Returns:** + The iterator component points to the inserted element or to the already existing element. The `bool` component is `true` if insertion happened and `false` if it did not. +

-``` -iterator erase(const_iterator first, const_iterator last); -``` -**Preconditions:** -`cbegin() <= first && first <= last && last <= cend()` +4. ``` + template + iterator try_emplace(const_iterator hint, const Key& key, Args&&... args); + ``` +5. ``` + template + iterator try_emplace(const_iterator hint, Key&& key, Args&&... args); + ``` +6. ``` + template + iterator try_emplace(const_iterator hint, K&& key, Args&&... args); + ``` -**Effects:** -Removes the elements in the range `[first, last)`. + **Preconditions:** + 1. `!full()` + 2. `cbegin() <= hint && hint <= cend()` -**Note:** -The behavior is undefined if preconditions are not satisfied. + **Effects:** + If a key equivalent to `key` already exists in the container, does nothing. + Otherwise, inserts a new element into the container. -**Returns:** -Iterator following the last removed element. + Iterator `hint` is used as a suggestion where to start to search insert position. -

+ Iterator `hint` is ignored due to container's underlying storage implementation. These overloads exist just to have this container compatible with standard C++ containers as much as possible. + * **Overload (4):** Behaves like `emplace_hint` except that the element is constructed as + ``` + value_type( std::piecewise_construct, + std::forward_as_tuple(key), + std::forward_as_tuple(std::forward(args)...) ) + ``` -``` -size_type erase(const Key& key); -``` + * **Overload (5):** Behaves like `emplace_hint` except that the element is constructed as -**Effects:** -Removes the element (if one exists) with the key equivalent to `key`. + ``` + value_type( std::piecewise_construct, + std::forward_as_tuple(std::move(key)), + std::forward_as_tuple(std::forward(args)...) ) + ``` -**Returns:** -Number of elements removed (0 or 1). + * **Overload (6):** Behaves like `emplace_hint` except that the element is constructed as -

+ ``` + value_type( std::piecewise_construct, + std::forward_as_tuple(std::forward(key)), + std::forward_as_tuple(std::forward(args)...) ) + ``` + **Note:** This overload participates in overload resolution only if `KeyEqual::is_transparent` exists and is a valid type. It allows calling this function without constructing an instance of `Key`. + **Returns:** + Iterator to the inserted element or to the already existing element. -``` -template -size_type erase(K&& x); -``` +

-**Effects:** -Removes the element (if one exists) with key that compares equivalent to the value `x`. -**Note:** -This overload participates in overload resolution only if `Compare::is_transparent` exists and is a valid type. It allows calling this function without constructing an instance of `Key`. -**Returns:** -Number of elements removed (0 or 1). +### erase -

+1. ``` + iterator erase(iterator pos); + ``` +2. ``` + iterator erase(const_iterator pos); + ``` + **Preconditions:** + `cbegin() <= pos && pos < cend()` + **Effects:** + Removes the element at `pos`. -### swap + **Returns:** + Iterator following the last removed element. -``` -void swap(small_flat_map& other); -``` +

-**Effects:** -Exchanges the contents of the container with those of `other`. -**Complexity:** -Linear in size. -

+3. ``` + iterator erase(const_iterator first, const_iterator last); + ``` + **Preconditions:** + `cbegin() <= first && first <= last && last <= cend()` + **Effects:** + Removes the elements in the range `[first, last)`. -### find + **Returns:** + Iterator following the last removed element. -``` -iterator find(const Key& key); -``` -``` -const_iterator find(const Key& key) const; -``` +

-**Effects:** -Returns an iterator to an element with key equivalent to `key`, or `end()` if such an element is not found. -**Complexity:** -Constant in the best case. Linear in `size()` in the worst case. -

+4. ``` + size_type erase(const Key& key); + ``` +5. ``` + template + size_type erase(K&& x); + ``` + **Effects:** + Removes the element (if one exists) with the key equivalent to `key` or `x`. + **Note:** + Overload (5) participates in overload resolution only if `KeyEqual::is_transparent` exists and is a valid type. It allows calling this function without constructing an instance of `Key`. -``` -template -iterator find(const K& x); -``` -``` -template -const_iterator find(const K& x) const; -``` + **Returns:** + Number of elements removed (0 or 1). -**Effects:** -Returns an iterator to an element with key that compares equivalent to `x`, or `end()` if such an element is not found. +

-**Note:** -This overload participates in overload resolution only if `KeyEqual::is_transparent` exists and is a valid type. It allows calling this function without constructing an instance of `Key`. -**Complexity:** -Constant in the best case. Linear in `size()` in the worst case. -

+### swap +1. ``` + void swap(small_flat_map& other); + ``` + **Effects:** + Exchanges the contents of the container with those of `other`. -### count + **Complexity:** + Linear in size. -``` -size_type count(const Key& key) const; -``` +

-**Effects:** -Returns the number of elements with key equivalent to `key`, which is either 1 or 0 since this container does not allow duplicates. -**Complexity:** -Constant in the best case. Linear in `size()` in the worst case. -

+### find +1. ``` + iterator find(const Key& key); + ``` +2. ``` + const_iterator find(const Key& key) const; + ``` +3. ``` + template + iterator find(const K& x); + ``` +4. ``` + template + const_iterator find(const K& x) const; + ``` + **Effects:** + Returns an iterator pointing to the element with key equivalent to `key` or `x`. Returns `end()` if no such element is found. -``` -template -size_type count(const K& x) const; -``` + **Note:** + Overloads (3) and (4) participate in overload resolution only if `KeyEqual::is_transparent` exists and is a valid type. It allows calling these functions without constructing an instance of `Key`. -**Effects:** -Returns the number of elements with key that compares equivalent to `x`, which is either 1 or 0 since this container does not allow duplicates. + **Complexity:** + Constant in the best case. Linear in `size()` in the worst case. -**Note:** -This overload participates in overload resolution only if `KeyEqual::is_transparent` exists and is a valid type. It allows calling this function without constructing an instance of `Key`. +

-**Complexity:** -Constant in the best case. Linear in `size()` in the worst case. -

+### count +1. ``` + size_type count(const Key& key) const; + ``` +2. ``` + template + size_type count(const K& x) const; + ``` -### contains + **Effects:** + Returns the number of elements with key equivalent to `key` or `x`, which is either 1 or 0 since this container does not allow duplicates. -``` -bool contains(const Key& key) const; -``` + **Note:** + Overload (2) participates in overload resolution only if `KeyEqual::is_transparent` exists and is a valid type. It allows calling this function without constructing an instance of `Key`. -**Effects:** -Returns `true` if the container contains an element with key equivalent to `key`, otherwise returns `false`. + **Complexity:** + Constant in the best case. Linear in `size()` in the worst case. -**Complexity:** -Constant in the best case. Linear in `size()` in the worst case. +

-

+### contains -``` -template -bool contains(const K& x) const; -``` +1. ``` + bool contains(const Key& key) const; + ``` +2. ``` + template + bool contains(const K& x) const; + ``` -**Effects:** -Returns `true` if the container contains an element with the key that compares equivalent to `x`, otherwise returns `false`. + **Effects:** + Returns `true` if the container contains an element with key equivalent to `key` or `x`, otherwise returns `false`. -**Note:** -This overload participates in overload resolution only if `KeyEqual::is_transparent` exists and is a valid type. It allows calling this function without constructing an instance of `Key`. + **Note:** + Overload (2) participates in overload resolution only if `KeyEqual::is_transparent` exists and is a valid type. It allows calling this function without constructing an instance of `Key`. -**Complexity:** -Constant in the best case. Linear in `size()` in the worst case. + **Complexity:** + Constant in the best case. Linear in `size()` in the worst case. -

+

### at -``` -T& at(const Key& key); -``` -``` -const T& at(const Key& key) const; -``` +1. ``` + T& at(const Key& key); + ``` +2. ``` + const T& at(const Key& key) const; + ``` +3. ``` + template + const T& at(const K& x) const; + ``` -**Effects:** -Returns a reference to the mapped value of the element with key equivalent to `key`. If no such element exists, an exception of type `std::out_of_range` is thrown. + **Effects:** + Returns a reference to the mapped value of the element with key equivalent to `key` or `x`. If no such element exists, an exception of type `std::out_of_range` is thrown. -**Complexity:** -Linear in `size()`. + **Note:** + Overload (3) participates in overload resolution only if `KeyEqual::is_transparent` exists and is a valid type. It allows calling this function without constructing an instance of `Key`. -**Exceptions:** -`std::out_of_range` if the container does not have an element with the specified key. + **Complexity:** + Linear in `size()`. -

+ **Exceptions:** + `std::out_of_range` if the container does not have an element with the specified key. + +

### operator[] -``` -T& operator[](const Key& key); -``` -``` -T& operator[](Key&& key); -``` +1. ``` + T& operator[](const Key& key); + ``` +2. ``` + T& operator[](Key&& key); + ``` +3. ``` + template + T& operator[](const K& x); + ``` +4. ``` + template + T& operator[](K&& x); + ``` -**Preconditions:** -`!full()` + **Preconditions:** + `!full()` -**Effects:** -Returns a reference to the value that is mapped to a key equivalent to `key`, performing an insertion if such key does not already exist. + **Effects:** + Returns a reference to the value that is mapped to a key equivalent to `key` or `x`, performing an insertion if such key does not already exist. -* The first overload is equivalent to: - ``` - return try_emplace(key).first->second; - ``` -* The second overload is equivalent to: - ``` - return try_emplace(std::move(key)).first->second; - ``` + * Overload (1) is equivalent to + `return try_emplace(key).first->second;` -**Note:** -The behavior is undefined if preconditions are not satisfied. + * Overload (2) is equivalent to + `return try_emplace(std::move(key)).first->second;` -**Complexity:** -Linear in `size()`. + * Overload (3) is equivalent to + `return try_emplace(x).first->second;` -

+ * Overload (4) is equivalent to + `return try_emplace(std::forward(x)).first->second;` + + **Note:** + Overloads (3) and (4) participate in overload resolution only if `KeyEqual::is_transparent` exists and is a valid type. It allows calling these functions without constructing an instance of `Key`. + + **Complexity:** + Linear in `size()`. + +

### data -``` -value_type* data() noexcept; -``` -``` -const value_type* data() const noexcept; -``` +1. ``` + value_type* data() noexcept; + ``` +2. ``` + const value_type* data() const noexcept; + ``` -**Effects:** -Returns pointer to the underlying array serving as element storage. The pointer is such that range `[data(), data() + size())` is always a valid range, even if the container is empty. `data()` is not dereferenceable if the container is empty. + **Effects:** + Returns pointer to the underlying array serving as element storage. The pointer is such that range `[data(), data() + size())` is always a valid range, even if the container is empty. `data()` is not dereferenceable if the container is empty. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

@@ -1259,93 +1285,93 @@ Constant. ### operator== -``` -template -bool operator== -( - const static_unordered_flat_map& x, - const static_unordered_flat_map& y -); -``` +1. ``` + template + bool operator== + ( + const static_unordered_flat_map& x, + const static_unordered_flat_map& y + ); + ``` -**Effects:** -Checks if the contents of `x` and `y` are equal. + **Effects:** + Checks if the contents of `x` and `y` are equal. -The contents of `x` and `y` are equal if the following conditions hold: -* `x.size() == y.size()` -* For each element in `x` there is equal element in `y`. + The contents of `x` and `y` are equal if the following conditions hold: + * `x.size() == y.size()` + * For each element in `x` there is equal element in `y`. -The comparison is performed by `std::is_permutation`. -This comparison ignores the container's `KeyEqual` function. + The comparison is performed by `std::is_permutation`. + This comparison ignores the container's `KeyEqual` function. -**Returns:** -`true` if the contents of the `x` and `y` are equal, `false` otherwise. + **Returns:** + `true` if the contents of the `x` and `y` are equal, `false` otherwise. -

+

### operator!= -``` -template -bool operator!= -( - const static_unordered_flat_map& x, - const static_unordered_flat_map& y -); -``` +1. ``` + template + bool operator!= + ( + const static_unordered_flat_map& x, + const static_unordered_flat_map& y + ); + ``` -**Effects:** -Checks if the contents of `x` and `y` are equal. + **Effects:** + Checks if the contents of `x` and `y` are equal. -For details see `operator==`. + For details see `operator==`. -**Returns:** -`true` if the contents of the `x` and `y` are not equal, `false` otherwise. + **Returns:** + `true` if the contents of the `x` and `y` are not equal, `false` otherwise. -

+

### swap -``` -template -void swap -( - static_unordered_flat_map& x, - static_unordered_flat_map& y -); -``` +1. ``` + template + void swap + ( + static_unordered_flat_map& x, + static_unordered_flat_map& y + ); + ``` -**Effects:** -Swaps the contents of `x` and `y`. Calls `x.swap(y)`. + **Effects:** + Swaps the contents of `x` and `y`. Calls `x.swap(y)`. -

+

### erase_if -``` -template -typename static_unordered_flat_map::size_type - erase_if(static_unordered_flat_map& c, Predicate pred); -``` +1. ``` + template + typename static_unordered_flat_map::size_type + erase_if(static_unordered_flat_map& c, Predicate pred); + ``` -**Effects:** -Erases all elements that satisfy the predicate `pred` from the container. + **Effects:** + Erases all elements that satisfy the predicate `pred` from the container. -`pred` is unary predicate which returns `true` if the element should be removed. + `pred` is unary predicate which returns `true` if the element should be removed. -**Returns:** -The number of erased elements. + **Returns:** + The number of erased elements. -**Complexity:** -Linear. + **Complexity:** + Linear. -

+

diff --git a/doc/static_unordered_flat_multimap.md b/doc/static_unordered_flat_multimap.md index b423a38..8664e33 100644 --- a/doc/static_unordered_flat_multimap.md +++ b/doc/static_unordered_flat_multimap.md @@ -159,889 +159,808 @@ static constexpr size_type static_capacity = N; ### (constructor) -``` -static_unordered_flat_multimap() noexcept(std::is_nothrow_default_constructible::value) -``` -``` -explicit static_unordered_flat_multimap(const KeyEqual& equal) noexcept(std::is_nothrow_copy_constructible::value) -``` +1. ``` + static_unordered_flat_multimap() noexcept(std::is_nothrow_default_constructible::value) + ``` +2. ``` + explicit static_unordered_flat_multimap(const KeyEqual& equal) noexcept(std::is_nothrow_copy_constructible::value) + ``` -**Effects:** -Constructs an empty container. + **Effects:** + Constructs an empty container. -

+

-``` -template -static_unordered_flat_multimap(InputIt first, InputIt last); -``` -``` -template -static_unordered_flat_multimap(InputIt first, InputIt last, const KeyEqual& equal); -``` - -**Preconditions:** -`std::distance(first, last) <= capacity()` +3. ``` + template + static_unordered_flat_multimap(InputIt first, InputIt last); + ``` +4. ``` + template + static_unordered_flat_multimap(InputIt first, InputIt last, const KeyEqual& equal); + ``` -**Effects:** -Constructs an empty container and inserts elements from the range `[first, last)`. + **Preconditions:** + `std::distance(first, last) <= capacity()` -**Note:** -This overload participates in overload resolution only if `InputIt` satisfies requirements of [*LegacyInputIterator*](https://en.cppreference.com/w/cpp/named_req/InputIterator). + **Effects:** + Constructs an empty container and inserts elements from the range `[first, last)`. -**Note:** -The behavior is undefined if preconditions are not satisfied. + **Note:** + This overload participates in overload resolution only if `InputIt` satisfies requirements of [*LegacyInputIterator*](https://en.cppreference.com/w/cpp/named_req/InputIterator). -**Complexity:** -Linear in `std::distance(first, last)`. + **Complexity:** + Linear in `std::distance(first, last)`. -

+

-``` -static_unordered_flat_multimap(std::initializer_list ilist); -``` -``` -static_unordered_flat_multimap(std::initializer_list ilist, const KeyEqual& equal); -``` - -**Preconditions:** -`ilist.size() <= capacity()` +5. ``` + static_unordered_flat_multimap(std::initializer_list ilist); + ``` +6. ``` + static_unordered_flat_multimap(std::initializer_list ilist, const KeyEqual& equal); + ``` -**Effects:** -Constructs an empty container and inserts elements from the initializer list `ilist`. + **Preconditions:** + `ilist.size() <= capacity()` -**Note:** -The behavior is undefined if preconditions are not satisfied. + **Effects:** + Constructs an empty container and inserts elements from the initializer list `ilist`. -**Complexity:** -Linear in `ilist.size()`. + **Complexity:** + Linear in `ilist.size()`. -

+

-``` -static_unordered_flat_multimap(const static_unordered_flat_multimap& other); -``` +7. ``` + static_unordered_flat_multimap(const static_unordered_flat_multimap& other); + ``` -**Effects:** -Copy constructor. -Constructs the container with the copy of the contents of `other`. + **Effects:** + Copy constructor. + Constructs the container with the copy of the contents of `other`. -**Complexity:** -Linear in size. + **Complexity:** + Linear in size. -

+

-``` -static_unordered_flat_multimap(static_unordered_flat_multimap&& other); -``` +8. ``` + static_unordered_flat_multimap(static_unordered_flat_multimap&& other); + ``` -**Effects:** -Move constructor. -Constructs the container with the contents of `other` using move semantics. + **Effects:** + Move constructor. + Constructs the container with the contents of `other` using move semantics. -`other` is not guaranteed to be empty after the move. + `other` is not guaranteed to be empty after the move. -`other` is in a valid but unspecified state after the move. + `other` is in a valid but unspecified state after the move. -**Complexity:** -Linear in size. + **Complexity:** + Linear in size. -

+

### (destructor) -``` -~static_unordered_flat_multimap(); -``` +1. ``` + ~static_unordered_flat_multimap(); + ``` -**Effects:** -Destructs the container. The destructors of the elements are called and the used storage is deallocated. + **Effects:** + Destructs the container. The destructors of the elements are called and the used storage is deallocated. -**Complexity:** -Linear in size. + **Complexity:** + Linear in size. -

+

### operator= -``` -static_unordered_flat_multimap& operator=(const static_unordered_flat_multimap& other); -``` - -**Effects:** -Copy assignment operator. -Replaces the contents with a copy of the contents of `other`. +1. ``` + static_unordered_flat_multimap& operator=(const static_unordered_flat_multimap& other); + ``` -**Returns:** -`*this()`. + **Effects:** + Copy assignment operator. + Replaces the contents with a copy of the contents of `other`. -**Complexity:** -Linear in size. + **Returns:** + `*this()`. -

+ **Complexity:** + Linear in size. +

-``` -static_unordered_flat_multimap& operator=(static_unordered_flat_multimap&& other); -``` -**Effects:** -Move assignment operator. -Replaces the contents with those of `other` using move semantics. +2. ``` + static_unordered_flat_multimap& operator=(static_unordered_flat_multimap&& other); + ``` -`other` is not guaranteed to be empty after the move. + **Effects:** + Move assignment operator. + Replaces the contents with those of `other` using move semantics. -`other` is in a valid but unspecified state after the move. + `other` is not guaranteed to be empty after the move. -**Returns:** -`*this()`. + `other` is in a valid but unspecified state after the move. -**Complexity:** -Linear in size. + **Returns:** + `*this()`. -

+ **Complexity:** + Linear in size. +

-``` -static_unordered_flat_multimap& operator=(std::initializer_list ilist); -``` -**Preconditions:** -`ilist.size() <= capacity()` +3. ``` + static_unordered_flat_multimap& operator=(std::initializer_list ilist); + ``` -**Effects:** -Replaces the contents with those identified by initializer list `ilist`. + **Preconditions:** + `ilist.size() <= capacity()` -**Note:** -The behavior is undefined if preconditions are not satisfied. + **Effects:** + Replaces the contents with those identified by initializer list `ilist`. -**Returns:** -`*this()`. + **Returns:** + `*this()`. -**Complexity:** -Linear in size. + **Complexity:** + Linear in size. -

+

### key_eq -``` -key_equal key_eq() const; -``` +1. ``` + key_equal key_eq() const; + ``` -**Effects:** -Returns the function object that compares keys for equality, which is a copy of this container's constructor argument `equal`. + **Effects:** + Returns the function object that compares keys for equality, which is a copy of this container's constructor argument `equal`. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

### value_eq -``` -value_equal value_eq() const; -``` +1. ``` + value_equal value_eq() const; + ``` -**Effects:** -Returns a function object that compares objects of type `value_type`. + **Effects:** + Returns a function object that compares objects of type `value_type`. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

### begin, cbegin -``` -iterator begin() noexcept; -``` -``` -const_iterator begin() const noexcept; -``` -``` -const_iterator cbegin() const noexcept; -``` - -**Effects:** -Returns an iterator to the first element of the container. +1. ``` + iterator begin() noexcept; + ``` +2. ``` + const_iterator begin() const noexcept; + ``` +3. ``` + const_iterator cbegin() const noexcept; + ``` -If the container is empty, the returned iterator will be equal to `end()`. + **Effects:** + Returns an iterator to the first element of the container. + If the container is empty, the returned iterator will be equal to `end()`. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

### end, cend -``` -iterator end() noexcept; -``` -``` -const_iterator end() const noexcept; -``` -``` -const_iterator cend() const noexcept; -``` - -**Effects:** -Returns an iterator to the element following the last element of the container. +1. ``` + iterator end() noexcept; + ``` +2. ``` + const_iterator end() const noexcept; + ``` +3. ``` + const_iterator cend() const noexcept; + ``` -This element acts as a placeholder; attempting to access it results in undefined behavior. + **Effects:** + Returns an iterator to the element following the last element of the container. + This element acts as a placeholder; attempting to access it results in undefined behavior. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

### nth -``` -iterator nth(size_type pos) noexcept; -``` -``` -const_iterator nth(size_type pos) const noexcept; -``` +1. ``` + iterator nth(size_type pos) noexcept; + ``` +2. ``` + const_iterator nth(size_type pos) const noexcept; + ``` -**Preconditions:** -`pos <= size()` + **Preconditions:** + `pos <= size()` -**Effects:** -Returns an iterator to the element at position `pos`. -If `pos == size()`, the returned iterator is equal to `end()`. + **Effects:** + Returns an iterator to the element at position `pos`. -**Complexity:** -Constant. + If `pos == size()`, the returned iterator is equal to `end()`. -

+ **Complexity:** + Constant. + +

### index_of -``` -size_type index_of(const_iterator pos) const noexcept; -``` +1. ``` + size_type index_of(const_iterator pos) const noexcept; + ``` -**Preconditions:** -`cbegin() <= pos && pos <= cend()` + **Preconditions:** + `cbegin() <= pos && pos <= cend()` -**Effects:** -Returns position of the element pointed by iterator `pos`, i.e. `std::distance(begin(), pos)`. + **Effects:** + Returns position of the element pointed by iterator `pos`, i.e. `std::distance(begin(), pos)`. -If `pos == end()`, the returned value is equal to `size()`. + If `pos == end()`, the returned value is equal to `size()`. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

### empty -``` -bool empty() const noexcept; -``` +1. ``` + bool empty() const noexcept; + ``` -**Effects:** -Returns `true` if the container has no elements, i.e. whether `begin() == end()`. + **Effects:** + Returns `true` if the container has no elements, i.e. whether `begin() == end()`. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

### full -``` -bool full() const noexcept; -``` +1. ``` + bool full() const noexcept; + ``` -**Effects:** -Returns `true` if the container is full, i.e. whether `size() == capacity()`. + **Effects:** + Returns `true` if the container is full, i.e. whether `size() == capacity()`. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

### size -``` -size_type size() const noexcept; -``` +1. ``` + size_type size() const noexcept; + ``` -**Effects:** -Returns the number of elements in the container, i.e. `std::distance(begin(), end())`. + **Effects:** + Returns the number of elements in the container, i.e. `std::distance(begin(), end())`. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

### max_size -``` -static constexpr size_type max_size() const noexcept; -``` +1. ``` + static constexpr size_type max_size() const noexcept; + ``` -**Effects:** -Returns the maximum number of elements the container is able to hold, i.e. returns `N`. + **Effects:** + Returns the maximum number of elements the container is able to hold, i.e. `N`. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

### capacity -``` -static constexpr size_type capacity() const noexcept; -``` +1. ``` + static constexpr size_type capacity() const noexcept; + ``` -**Effects:** -Returns the maximum number of elements the container is able to hold, i.e. returns `N`. + **Effects:** + Returns the maximum number of elements the container is able to hold, i.e. `N`. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

### available -``` -size_type available() const noexcept; -``` +1. ``` + size_type available() const noexcept; + ``` -**Effects:** -Returns the number of elements that can be inserted into the container, i.e. returns `capacity() - size()`. + **Effects:** + Returns the number of elements that can be inserted into the container, i.e. `capacity() - size()`. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

### clear -``` -void clear() noexcept; -``` +1. ``` + void clear() noexcept; + ``` -**Effects:** -Erases all elements from the container. -After this call, `size()` returns zero and `capacity()` remains unchanged. + **Effects:** + Erases all elements from the container. + After this call, `size()` returns zero and `capacity()` remains unchanged. -**Complexity:** -Linear in `size()`. + **Complexity:** + Linear in `size()`. -

+

### emplace -``` -template -iterator emplace(Args&&... args); -``` +1. ``` + template + iterator emplace(Args&&... args); + ``` -**Preconditions:** -`!full()` + **Preconditions:** + `!full()` -**Effects:** -Inserts a new element into the container. + **Effects:** + Inserts a new element into the container. -New element is constructed as `value_type(std::forward(args)...)`. + New element is constructed as `value_type(std::forward(args)...)`. -**Note:** -The behavior is undefined if preconditions are not satisfied. + **Note:** + The behavior is undefined if preconditions are not satisfied. -**Returns:** -Iterator to the inserted element. + **Returns:** + Iterator to the inserted element. -

+

### emplace_hint -``` -template -iterator emplace_hint(const_iterator hint, Args&&... args); -``` +1. ``` + template + iterator emplace_hint(const_iterator hint, Args&&... args); + ``` -**Preconditions:** -1. `!full()` -2. `cbegin() <= hint && hint <= cend()` + **Preconditions:** + 1. `!full()` + 2. `cbegin() <= hint && hint <= cend()` -**Effects:** -Inserts a new element into the container. + **Effects:** + Inserts a new element into the container. -New element is constructed as `value_type(std::forward(args)...)`. + New element is constructed as `value_type(std::forward(args)...)`. -Iterator `hint` is used as a suggestion where to start to search insert position. + Iterator `hint` is used as a suggestion where to start to search insert position. -**Note:** -The behavior is undefined if preconditions are not satisfied. + Iterator `hint` is ignored due to container's underlying storage implementation. This overload exists just to have this container compatible with standard C++ containers as much as possible. -**Returns:** -Iterator to the inserted element. + **Returns:** + Iterator to the inserted element. -

+

### insert -``` -iterator insert(const value_type& value); -``` - -**Preconditions:** -`!full()` - -**Effects:** -Inserts copy of `value`. - -**Note:** -The behavior is undefined if preconditions are not satisfied. - -**Returns:** -Iterator to the inserted element. - -

+1. ``` + iterator insert(const value_type& value); + ``` + **Preconditions:** + `!full()` + **Effects:** + Inserts copy of `value`. -``` -iterator insert(value_type&& value); -``` + **Returns:** + Iterator to the inserted element. -**Preconditions:** -`!full()` +

-**Effects:** -Inserts `value` using move semantics. -**Note:** -The behavior is undefined if preconditions are not satisfied. -**Returns:** -Iterator to the inserted element. +2. ``` + iterator insert(value_type&& value); + ``` -

+ **Preconditions:** + `!full()` + **Effects:** + Inserts `value` using move semantics. + **Returns:** + Iterator to the inserted element. -``` -template -iterator insert(P&& value); -``` +

-**Preconditions:** -`!full()` -**Effects:** -Inserts a new element into the container. -New element is constructed as `value_type(std::forward

(value))`. +3. ``` + template + iterator insert(P&& value); + ``` -**Note:** -This overload participates in overload resolution only if `std::is_constructible::value` is `true`. + **Preconditions:** + `!full()` -**Note:** -The behavior is undefined if preconditions are not satisfied. + **Effects:** + Inserts a new element into the container. -**Returns:** -Iterator to the inserted element. + New element is constructed as `value_type(std::forward

(value))`. -

+ **Note:** + This overload participates in overload resolution only if `std::is_constructible::value` is `true`. + **Returns:** + Iterator to the inserted element. +

-``` -iterator insert(const_iterator hint, const value_type& value); -``` -**Preconditions:** -1. `!full()` -2. `cbegin() <= hint && hint <= cend()` -**Effects:** -Inserts copy of `value`. +4. ``` + iterator insert(const_iterator hint, const value_type& value); + ``` -Iterator `hint` is used as a suggestion where to start to search insert position. + **Preconditions:** + 1. `!full()` + 2. `cbegin() <= hint && hint <= cend()` -**Note:** -The behavior is undefined if preconditions are not satisfied. + **Effects:** + Inserts copy of `value`. -**Returns:** -Iterator to the inserted element. + Iterator `hint` is used as a suggestion where to start to search insert position. -

+ Iterator `hint` is ignored due to container's underlying storage implementation. This overload exists just to have this container compatible with standard C++ containers as much as possible. + **Returns:** + Iterator to the inserted element. +

-``` -iterator insert(const_iterator hint, value_type&& value); -``` -**Preconditions:** -1. `!full()` -2. `cbegin() <= hint && hint <= cend()` -**Effects:** -Inserts `value` using move semantics. +5. ``` + iterator insert(const_iterator hint, value_type&& value); + ``` -Iterator `hint` is used as a suggestion where to start to search insert position. + **Preconditions:** + 1. `!full()` + 2. `cbegin() <= hint && hint <= cend()` -**Note:** -The behavior is undefined if preconditions are not satisfied. + **Effects:** + Inserts `value` using move semantics. -**Returns:** -Iterator to the inserted element. + Iterator `hint` is used as a suggestion where to start to search insert position. -

+ Iterator `hint` is ignored due to container's underlying storage implementation. This overload exists just to have this container compatible with standard C++ containers as much as possible. + **Returns:** + Iterator to the inserted element. +

-``` -template -iterator insert(const_iterator hint, P&& value); -``` -**Preconditions:** -1. `!full()` -2. `cbegin() <= hint && hint <= cend()` -**Effects:** -Inserts a new element into the container. +6. ``` + template + iterator insert(const_iterator hint, P&& value); + ``` -New element is constructed as `value_type(std::forward

(value))`. + **Preconditions:** + 1. `!full()` + 2. `cbegin() <= hint && hint <= cend()` -Iterator `hint` is used as a suggestion where to start to search insert position. + **Effects:** + Inserts a new element into the container. -**Note:** -This overload participates in overload resolution only if `std::is_constructible::value` is `true`. + New element is constructed as `value_type(std::forward

(value))`. -**Note:** -The behavior is undefined if preconditions are not satisfied. + Iterator `hint` is used as a suggestion where to start to search insert position. -**Returns:** -Iterator to the inserted element. + Iterator `hint` is ignored due to container's underlying storage implementation. This overload exists just to have this container compatible with standard C++ containers as much as possible. -

+ **Note:** + This overload participates in overload resolution only if `std::is_constructible::value` is `true`. + **Returns:** + Iterator to the inserted element. +

-``` -template -void insert(InputIt first, InputIt last); -``` -**Preconditions:** -`std::distance(first, last) <= available()` -**Effects:** -Inserts elements from range `[first, last)`. +7. ``` + template + void insert(InputIt first, InputIt last); + ``` -The call to this function is equivalent to: -``` -while (first != last) -{ - insert(*first); - ++first; -} -``` + **Preconditions:** + `std::distance(first, last) <= available()` -**Note:** -This overload participates in overload resolution only if `InputIt` satisfies requirements of [*LegacyInputIterator*](https://en.cppreference.com/w/cpp/named_req/InputIterator). + **Effects:** + Inserts elements from range `[first, last)`. -**Note:** -The behavior is undefined if preconditions are not satisfied. + The call to this function is equivalent to: + ``` + while (first != last) + { + insert(*first); + ++first; + } + ``` -

+ **Note:** + This overload participates in overload resolution only if `InputIt` satisfies requirements of [*LegacyInputIterator*](https://en.cppreference.com/w/cpp/named_req/InputIterator). +

-``` -void insert(std::initializer_list ilist); -``` -**Preconditions:** -`ilist.size() <= available()` +8. ``` + void insert(std::initializer_list ilist); + ``` -**Effects:** -Inserts elements from initializer list `ilist`. + **Preconditions:** + `ilist.size() <= available()` -The call to this function is equivalent to: -``` -insert(ilist.begin(), ilist.end()); -``` + **Effects:** + Inserts elements from initializer list `ilist`. -**Note:** -The behavior is undefined if preconditions are not satisfied. + The call to this function is equivalent to `insert(ilist.begin(), ilist.end())`. -

+

### erase -``` -iterator erase(iterator pos); -``` -``` -iterator erase(const_iterator pos); -``` - -**Preconditions:** -`cbegin() <= pos && pos < cend()` - -**Effects:** -Removes the element at `pos`. - -**Note:** -The behavior is undefined if preconditions are not satisfied. - -**Returns:** -Iterator following the last removed element. - -

- - - -``` -iterator erase(const_iterator first, const_iterator last); -``` +1. ``` + iterator erase(iterator pos); + ``` +2. ``` + iterator erase(const_iterator pos); + ``` -**Preconditions:** -`cbegin() <= first && first <= last && last <= cend()` + **Preconditions:** + `cbegin() <= pos && pos < cend()` -**Effects:** -Removes the elements in the range `[first, last)`. + **Effects:** + Removes the element at `pos`. -**Note:** -The behavior is undefined if preconditions are not satisfied. + **Returns:** + Iterator following the last removed element. -**Returns:** -Iterator following the last removed element. +

-

+3. ``` + iterator erase(const_iterator first, const_iterator last); + ``` -``` -size_type erase(const Key& key); -``` + **Preconditions:** + `cbegin() <= first && first <= last && last <= cend()` -**Effects:** -Removes all elements with the key equivalent to `key`. + **Effects:** + Removes the elements in the range `[first, last)`. -**Returns:** -Number of elements removed. + **Returns:** + Iterator following the last removed element. -

+

-``` -template -size_type erase(K&& x); -``` +4. ``` + size_type erase(const Key& key); + ``` +5. ``` + template + size_type erase(K&& x); + ``` -**Effects:** -Removes all elements with key that compares equivalent to the value `x`. + **Effects:** + Removes all elements with the key equivalent to `key` or `x`. -**Note:** -This overload participates in overload resolution only if `KeyEqual::is_transparent` exists and is a valid type. It allows calling this function without constructing an instance of `Key`. + **Note:** + Overload (5) participates in overload resolution only if `KeyEqual::is_transparent` exists and is a valid type. It allows calling this function without constructing an instance of `Key`. -**Returns:** -Number of elements removed. + **Returns:** + Number of elements removed. -

+

### swap -``` -void swap(static_unordered_flat_multimap& other); -``` +1. ``` + void swap(static_unordered_flat_multimap& other); + ``` -**Effects:** -Exchanges the contents of the container with those of `other`. + **Effects:** + Exchanges the contents of the container with those of `other`. -**Complexity:** -Linear in size. + **Complexity:** + Linear in size. -

+

### find -``` -iterator find(const Key& key); -``` -``` -const_iterator find(const Key& key) const; -``` - -**Effects:** -Returns an iterator to an element with key equivalent to `key`, or `end()` if such an element is not found. If there are several elements with key in the container, any of them may be returned. - -**Complexity:** -Constant in the best case. Linear in `size()` in the worst case. - -

- - - -``` -template -iterator find(const K& x); -``` -``` -template -const_iterator find(const K& x) const; -``` +1. ``` + iterator find(const Key& key); + ``` +2. ``` + const_iterator find(const Key& key) const; + ``` +3. ``` + template + iterator find(const K& x); + ``` +4. ``` + template + const_iterator find(const K& x) const; + ``` -**Effects:** -Returns an iterator to an element with key that compares equivalent to `x`, or `end()` if such an element is not found. If there are several elements with key in the container, any of them may be returned. + **Effects:** + Returns an iterator pointing to the element with key equivalent to `key` or `x`. Returns `end()` if no such element is found. + If there are several elements with key in the container, any of them may be returned. -**Note:** -This overload participates in overload resolution only if `KeyEqual::is_transparent` exists and is a valid type. It allows calling this function without constructing an instance of `Key`. + **Note:** + Overloads (3) and (4) participate in overload resolution only if `KeyEqual::is_transparent` exists and is a valid type. It allows calling these functions without constructing an instance of `Key`. -**Complexity:** -Constant in the best case. Linear in `size()` in the worst case. + **Complexity:** + Constant in the best case. Linear in `size()` in the worst case. -

+

### count -``` -size_type count(const Key& key) const; -``` - -**Effects:** -Returns the number of elements with key equivalent to `key`. - -**Complexity:** -Linear in `size()`. - -

- - - -``` -template -size_type count(const K& x) const; -``` +1. ``` + size_type count(const Key& key) const; + ``` +2. ``` + template + size_type count(const K& x) const; + ``` -**Effects:** -Returns the number of elements with key that compares equivalent to the value `x`. + **Effects:** + Returns the number of elements with key equivalent to `key` or `x`. -**Note:** -This overload participates in overload resolution only if `KeyEqual::is_transparent` exists and is a valid type. It allows calling this function without constructing an instance of `Key`. + **Note:** + Overload (2) participates in overload resolution only if `KeyEqual::is_transparent` exists and is a valid type. It allows calling this function without constructing an instance of `Key`. -**Complexity:** -Linear in `size()`. + **Complexity:** + Linear in `size()`. -

+

### contains -``` -bool contains(const Key& key) const; -``` - -**Effects:** -Returns `true` if the container contains an element with key equivalent to `key`, otherwise returns `false`. - -**Complexity:** -Constant in the best case. Linear in `size()` in the worst case. - -

- - - -``` -template -bool contains(const K& x) const; -``` +1. ``` + bool contains(const Key& key) const; + ``` +2. ``` + template + bool contains(const K& x) const; + ``` -**Effects:** -Returns `true` if the container contains an element with the key that compares equivalent to `x`, otherwise returns `false`. + **Effects:** + Returns `true` if the container contains an element with key equivalent to `key` or `x`, otherwise returns `false`. -**Note:** -This overload participates in overload resolution only if `KeyEqual::is_transparent` exists and is a valid type. It allows calling this function without constructing an instance of `Key`. + **Note:** + Overload (2) participates in overload resolution only if `KeyEqual::is_transparent` exists and is a valid type. It allows calling this function without constructing an instance of `Key`. -**Complexity:** -Constant in the best case. Linear in `size()` in the worst case. + **Complexity:** + Constant in the best case. Linear in `size()` in the worst case. -

+

### data -``` -value_type* data() noexcept; -``` -``` -const value_type* data() const noexcept; -``` +1. ``` + value_type* data() noexcept; + ``` +2. ``` + const value_type* data() const noexcept; + ``` -**Effects:** -Returns pointer to the underlying array serving as element storage. The pointer is such that range `[data(), data() + size())` is always a valid range, even if the container is empty. `data()` is not dereferenceable if the container is empty. + **Effects:** + Returns pointer to the underlying array serving as element storage. The pointer is such that range `[data(), data() + size())` is always a valid range, even if the container is empty. `data()` is not dereferenceable if the container is empty. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

@@ -1049,93 +968,93 @@ Constant. ### operator== -``` -template -bool operator== -( - const static_unordered_flat_multimap& x, - const static_unordered_flat_multimap& y -); -``` +1. ``` + template + bool operator== + ( + const static_unordered_flat_multimap& x, + const static_unordered_flat_multimap& y + ); + ``` -**Effects:** -Checks if the contents of `x` and `y` are equal. + **Effects:** + Checks if the contents of `x` and `y` are equal. -The contents of `x` and `y` are equal if the following conditions hold: -* `x.size() == y.size()` -* For each element in `x` there is equal element in `y`. + The contents of `x` and `y` are equal if the following conditions hold: + * `x.size() == y.size()` + * For each element in `x` there is equal element in `y`. -The comparison is performed by `std::is_permutation`. -This comparison ignores the container's `KeyEqual` function. + The comparison is performed by `std::is_permutation`. + This comparison ignores the container's `KeyEqual` function. -**Returns:** -`true` if the contents of the `x` and `y` are equal, `false` otherwise. + **Returns:** + `true` if the contents of the `x` and `y` are equal, `false` otherwise. -

+

### operator!= -``` -template -bool operator!= -( - const static_unordered_flat_multimap& x, - const static_unordered_flat_multimap& y -); -``` +1. ``` + template + bool operator!= + ( + const static_unordered_flat_multimap& x, + const static_unordered_flat_multimap& y + ); + ``` -**Effects:** -Checks if the contents of `x` and `y` are equal. + **Effects:** + Checks if the contents of `x` and `y` are equal. -For details see `operator==`. + For details see `operator==`. -**Returns:** -`true` if the contents of the `x` and `y` are not equal, `false` otherwise. + **Returns:** + `true` if the contents of the `x` and `y` are not equal, `false` otherwise. -

+

### swap -``` -template -void swap -( - static_unordered_flat_multimap& x, - static_unordered_flat_multimap& y -); -``` +1. ``` + template + void swap + ( + static_unordered_flat_multimap& x, + static_unordered_flat_multimap& y + ); + ``` -**Effects:** -Swaps the contents of `x` and `y`. Calls `x.swap(y)`. + **Effects:** + Swaps the contents of `x` and `y`. Calls `x.swap(y)`. -

+

### erase_if -``` -template -typename static_unordered_flat_multimap::size_type - erase_if(static_unordered_flat_multimap& c, Predicate pred); -``` +1. ``` + template + typename static_unordered_flat_multimap::size_type + erase_if(static_unordered_flat_multimap& c, Predicate pred); + ``` -**Effects:** -Erases all elements that satisfy the predicate `pred` from the container. + **Effects:** + Erases all elements that satisfy the predicate `pred` from the container. -`pred` is unary predicate which returns `true` if the element should be removed. + `pred` is unary predicate which returns `true` if the element should be removed. -**Returns:** -The number of erased elements. + **Returns:** + The number of erased elements. -**Complexity:** -Linear. + **Complexity:** + Linear. -

+

diff --git a/doc/static_unordered_flat_multiset.md b/doc/static_unordered_flat_multiset.md index c112e7b..db6327c 100644 --- a/doc/static_unordered_flat_multiset.md +++ b/doc/static_unordered_flat_multiset.md @@ -135,876 +135,795 @@ static constexpr size_type static_capacity = N; ### (constructor) -``` -static_unordered_flat_multiset() noexcept(std::is_nothrow_default_constructible::value) -``` -``` -explicit static_unordered_flat_multiset(const KeyEqual& equal) noexcept(std::is_nothrow_copy_constructible::value) -``` - -**Effects:** -Constructs an empty container. - -

+1. ``` + static_unordered_flat_multiset() noexcept(std::is_nothrow_default_constructible::value) + ``` +2. ``` + explicit static_unordered_flat_multiset(const KeyEqual& equal) noexcept(std::is_nothrow_copy_constructible::value) + ``` + **Effects:** + Constructs an empty container. +

-``` -template -static_unordered_flat_multiset(InputIt first, InputIt last); -``` -``` -template -static_unordered_flat_multiset(InputIt first, InputIt last, const KeyEqual& equal); -``` -**Preconditions:** -`std::distance(first, last) <= capacity()` -**Effects:** -Constructs an empty container and inserts elements from the range `[first, last)`. +3. ``` + template + static_unordered_flat_multiset(InputIt first, InputIt last); + ``` +4. ``` + template + static_unordered_flat_multiset(InputIt first, InputIt last, const KeyEqual& equal); + ``` -**Note:** -This overload participates in overload resolution only if `InputIt` satisfies requirements of [*LegacyInputIterator*](https://en.cppreference.com/w/cpp/named_req/InputIterator). + **Preconditions:** + `std::distance(first, last) <= capacity()` -**Note:** -The behavior is undefined if preconditions are not satisfied. + **Effects:** + Constructs an empty container and inserts elements from the range `[first, last)`. -**Complexity:** -Linear in `std::distance(first, last)`. + **Note:** + These overloads participate in overload resolution only if `InputIt` satisfies requirements of [*LegacyInputIterator*](https://en.cppreference.com/w/cpp/named_req/InputIterator). -

+ **Complexity:** + Linear in `std::distance(first, last)`. +

-``` -static_unordered_flat_multiset(std::initializer_list ilist); -``` -``` -static_unordered_flat_multiset(std::initializer_list ilist, const KeyEqual& equal); -``` -**Preconditions:** -`ilist.size() <= capacity()` +5. ``` + static_unordered_flat_multiset(std::initializer_list ilist); + ``` +6. ``` + static_unordered_flat_multiset(std::initializer_list ilist, const KeyEqual& equal); + ``` -**Effects:** -Constructs an empty container and inserts elements from the initializer list `ilist`. + **Preconditions:** + `ilist.size() <= capacity()` -**Note:** -The behavior is undefined if preconditions are not satisfied. + **Effects:** + Constructs an empty container and inserts elements from the initializer list `ilist`. -**Complexity:** -Linear in `ilist.size()`. + **Complexity:** + Linear in `ilist.size()`. -

+

-``` -static_unordered_flat_multiset(const static_unordered_flat_multiset& other); -``` +7. ``` + static_unordered_flat_multiset(const static_unordered_flat_multiset& other); + ``` -**Effects:** -Copy constructor. -Constructs the container with the copy of the contents of `other`. + **Effects:** + Copy constructor. + Constructs the container with the copy of the contents of `other`. -**Complexity:** -Linear in size. + **Complexity:** + Linear in size. -

+

-``` -static_unordered_flat_multiset(static_unordered_flat_multiset&& other); -``` -``` -static_unordered_flat_multiset(static_unordered_flat_multiset&& other, const Allocator& alloc); -``` +8. ``` + static_unordered_flat_multiset(static_unordered_flat_multiset&& other); + ``` +9. ``` + static_unordered_flat_multiset(static_unordered_flat_multiset&& other, const Allocator& alloc); + ``` -**Effects:** -Move constructor. -Constructs the container with the contents of `other` using move semantics. + **Effects:** + Move constructor. + Constructs the container with the contents of `other` using move semantics. -`other` is not guaranteed to be empty after the move. + `other` is not guaranteed to be empty after the move. -`other` is in a valid but unspecified state after the move. + `other` is in a valid but unspecified state after the move. -**Complexity:** -Linear in size. + **Complexity:** + Linear in size. -

+

### (destructor) -``` -~static_unordered_flat_multiset(); -``` +1. ``` + ~static_unordered_flat_multiset(); + ``` -**Effects:** -Destructs the container. The destructors of the elements are called and the used storage is deallocated. + **Effects:** + Destructs the container. The destructors of the elements are called and the used storage is deallocated. -**Complexity:** -Linear in size. + **Complexity:** + Linear in size. -

+

### operator= -``` -static_unordered_flat_multiset& operator=(const static_unordered_flat_multiset& other); -``` - -**Effects:** -Copy assignment operator. -Replaces the contents with a copy of the contents of `other`. +1. ``` + static_unordered_flat_multiset& operator=(const static_unordered_flat_multiset& other); + ``` -**Returns:** -`*this()`. + **Effects:** + Copy assignment operator. + Replaces the contents with a copy of the contents of `other`. -**Complexity:** -Linear in size. + **Returns:** + `*this()`. -

+ **Complexity:** + Linear in size. +

-``` -static_unordered_flat_multiset& operator=(static_unordered_flat_multiset&& other); -``` -**Effects:** -Move assignment operator. -Replaces the contents with those of `other` using move semantics. +2. ``` + static_unordered_flat_multiset& operator=(static_unordered_flat_multiset&& other); + ``` -`other` is not guaranteed to be empty after the move. + **Effects:** + Move assignment operator. + Replaces the contents with those of `other` using move semantics. -`other` is in a valid but unspecified state after the move. + `other` is not guaranteed to be empty after the move. -**Returns:** -`*this()`. + `other` is in a valid but unspecified state after the move. -**Complexity:** -Linear in size. + **Returns:** + `*this()`. -

+ **Complexity:** + Linear in size. +

-``` -static_unordered_flat_multiset& operator=(std::initializer_list ilist); -``` -**Preconditions:** -`ilist.size() <= capacity()` +3. ``` + static_unordered_flat_multiset& operator=(std::initializer_list ilist); + ``` -**Effects:** -Replaces the contents with those identified by initializer list `ilist`. + **Preconditions:** + `ilist.size() <= capacity()` -**Note:** -The behavior is undefined if preconditions are not satisfied. + **Effects:** + Replaces the contents with those identified by initializer list `ilist`. -**Returns:** -`*this()`. + **Returns:** + `*this()`. -**Complexity:** -Linear in size. + **Complexity:** + Linear in size. -

+

### key_eq -``` -key_equal key_eq() const; -``` +1. ``` + key_equal key_eq() const; + ``` -**Effects:** -Returns the function object that compares keys for equality, which is a copy of this container's constructor argument `equal`. + **Effects:** + Returns the function object that compares keys for equality, which is a copy of this container's constructor argument `equal`. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

### begin, cbegin -``` -iterator begin() noexcept; -``` -``` -const_iterator begin() const noexcept; -``` -``` -const_iterator cbegin() const noexcept; -``` - -**Effects:** -Returns an iterator to the first element of the container. +1. ``` + iterator begin() noexcept; + ``` +2. ``` + const_iterator begin() const noexcept; + ``` +3. ``` + const_iterator cbegin() const noexcept; + ``` -If the container is empty, the returned iterator will be equal to `end()`. + **Effects:** + Returns an iterator to the first element of the container. + If the container is empty, the returned iterator will be equal to `end()`. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

### end, cend -``` -iterator end() noexcept; -``` -``` -const_iterator end() const noexcept; -``` -``` -const_iterator cend() const noexcept; -``` - -**Effects:** -Returns an iterator to the element following the last element of the container. +1. ``` + iterator end() noexcept; + ``` +2. ``` + const_iterator end() const noexcept; + ``` +3. ``` + const_iterator cend() const noexcept; + ``` -This element acts as a placeholder; attempting to access it results in undefined behavior. + **Effects:** + Returns an iterator to the element following the last element of the container. + This element acts as a placeholder; attempting to access it results in undefined behavior. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

### nth -``` -iterator nth(size_type pos) noexcept; -``` -``` -const_iterator nth(size_type pos) const noexcept; -``` +1. ``` + iterator nth(size_type pos) noexcept; + ``` +2. ``` + const_iterator nth(size_type pos) const noexcept; + ``` -**Preconditions:** -`pos <= size()` + **Preconditions:** + `pos <= size()` -**Effects:** -Returns an iterator to the element at position `pos`. -If `pos == size()`, the returned iterator is equal to `end()`. + **Effects:** + Returns an iterator to the element at position `pos`. -**Complexity:** -Constant. + If `pos == size()`, the returned iterator is equal to `end()`. -

+ **Complexity:** + Constant. + +

### index_of -``` -size_type index_of(const_iterator pos) const noexcept; -``` +1. ``` + size_type index_of(const_iterator pos) const noexcept; + ``` -**Preconditions:** -`cbegin() <= pos && pos <= cend()` + **Preconditions:** + `cbegin() <= pos && pos <= cend()` -**Effects:** -Returns position of the element pointed by iterator `pos`, i.e. `std::distance(begin(), pos)`. + **Effects:** + Returns position of the element pointed by iterator `pos`, i.e. `std::distance(begin(), pos)`. -If `pos == end()`, the returned value is equal to `size()`. + If `pos == end()`, the returned value is equal to `size()`. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

### empty -``` -bool empty() const noexcept; -``` +1. ``` + bool empty() const noexcept; + ``` -**Effects:** -Returns `true` if the container has no elements, i.e. whether `begin() == end()`. + **Effects:** + Returns `true` if the container has no elements, i.e. whether `begin() == end()`. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

### full -``` -bool full() const noexcept; -``` +1. ``` + bool full() const noexcept; + ``` -**Effects:** -Returns `true` if the container is full, i.e. whether `size() == capacity()`. + **Effects:** + Returns `true` if the container is full, i.e. whether `size() == capacity()`. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

### size -``` -size_type size() const noexcept; -``` +1. ``` + size_type size() const noexcept; + ``` -**Effects:** -Returns the number of elements in the container, i.e. `std::distance(begin(), end())`. + **Effects:** + Returns the number of elements in the container, i.e. `std::distance(begin(), end())`. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

### max_size -``` -static constexpr size_type max_size() const noexcept; -``` +1. ``` + static constexpr size_type max_size() const noexcept; + ``` -**Effects:** -Returns the maximum number of elements the container is able to hold, i.e. returns `N`. + **Effects:** + Returns the maximum number of elements the container is able to hold, i.e. `N`. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

### capacity -``` -static constexpr size_type capacity() const noexcept; -``` +1. ``` + static constexpr size_type capacity() const noexcept; + ``` -**Effects:** -Returns the maximum number of elements the container is able to hold, i.e. returns `N`. + **Effects:** + Returns the maximum number of elements the container is able to hold, i.e. `N`. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

### available -``` -size_type available() const noexcept; -``` +1. ``` + size_type available() const noexcept; + ``` -**Effects:** -Returns the number of elements that can be inserted into the container, i.e. returns `capacity() - size()`. + **Effects:** + Returns the number of elements that can be inserted into the container, i.e. `capacity() - size()`. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

### clear -``` -void clear() noexcept; -``` +1. ``` + void clear() noexcept; + ``` -**Effects:** -Erases all elements from the container. -After this call, `size()` returns zero and `capacity()` remains unchanged. + **Effects:** + Erases all elements from the container. + After this call, `size()` returns zero and `capacity()` remains unchanged. -**Complexity:** -Linear in `size()`. + **Complexity:** + Linear in `size()`. -

+

### emplace -``` -template -iterator emplace(Args&&... args); -``` - -**Preconditions:** -`!full()` +1. ``` + template + iterator emplace(Args&&... args); + ``` -**Effects:** -Inserts a new element into the container. + **Preconditions:** + `!full()` -New element is constructed as `value_type(std::forward(args)...)`. + **Effects:** + Inserts a new element into the container. -**Note:** -The behavior is undefined if preconditions are not satisfied. + New element is constructed as `value_type(std::forward(args)...)`. -**Returns:** -Iterator to the inserted element. + **Returns:** + Iterator to the inserted element. -

+

### emplace_hint -``` -template -iterator emplace_hint(const_iterator hint, Args&&... args); -``` +1. ``` + template + iterator emplace_hint(const_iterator hint, Args&&... args); + ``` -**Preconditions:** -1. `!full()` -2. `cbegin() <= hint && hint <= cend()` + **Preconditions:** + 1. `!full()` + 2. `cbegin() <= hint && hint <= cend()` -**Effects:** -Inserts a new element into the container. + **Effects:** + Inserts a new element into the container. -New element is constructed as `value_type(std::forward(args)...)`. + New element is constructed as `value_type(std::forward(args)...)`. -Iterator `hint` is used as a suggestion where to start to search insert position. + Iterator `hint` is used as a suggestion where to start to search insert position. -**Note:** -The behavior is undefined if preconditions are not satisfied. + Iterator `hint` is ignored due to container's underlying storage implementation. This overload exists just to have this container compatible with standard C++ containers as much as possible. -**Returns:** -Iterator to the inserted element. + **Returns:** + Iterator to the inserted element. -

+

### insert -``` -iterator insert(const value_type& value); -``` - -**Preconditions:** -`!full()` - -**Effects:** -Inserts copy of `value`. - -**Note:** -The behavior is undefined if preconditions are not satisfied. - -**Returns:** -Iterator to the inserted element. +1. ``` + iterator insert(const value_type& value); + ``` -

+ **Preconditions:** + `!full()` + **Effects:** + Inserts copy of `value`. + **Note:** + The behavior is undefined if preconditions are not satisfied. -``` -iterator insert(value_type&& value); -``` + **Returns:** + Iterator to the inserted element. -**Preconditions:** -`!full()` +

-**Effects:** -Inserts `value` using move semantics. -**Note:** -The behavior is undefined if preconditions are not satisfied. -**Returns:** -Iterator to the inserted element. +2. ``` + iterator insert(value_type&& value); + ``` -

+ **Preconditions:** + `!full()` + **Effects:** + Inserts `value` using move semantics. + **Returns:** + Iterator to the inserted element. -``` -template -iterator insert(P&& value); -``` +

-**Preconditions:** -`!full()` -**Effects:** -Inserts a new element into the container. -New element is constructed as `value_type(std::forward

(value))`. +3. ``` + template + iterator insert(P&& value); + ``` -**Note:** -This overload participates in overload resolution only if `std::is_constructible::value` is `true`. + **Preconditions:** + `!full()` -**Note:** -The behavior is undefined if preconditions are not satisfied. + **Effects:** + Inserts a new element into the container. -**Returns:** -Iterator to the inserted element. + New element is constructed as `value_type(std::forward

(value))`. -

+ **Note:** + This overload participates in overload resolution only if `std::is_constructible::value` is `true`. + **Returns:** + Iterator to the inserted element. +

-``` -iterator insert(const_iterator hint, const value_type& value); -``` -**Preconditions:** -1. `!full()` -2. `cbegin() <= hint && hint <= cend()` -**Effects:** -Inserts copy of `value`. +4. ``` + iterator insert(const_iterator hint, const value_type& value); + ``` -Iterator `hint` is used as a suggestion where to start to search insert position. + **Preconditions:** + 1. `!full()` + 2. `cbegin() <= hint && hint <= cend()` -**Note:** -The behavior is undefined if preconditions are not satisfied. + **Effects:** + Inserts copy of `value`. -**Returns:** -Iterator to the inserted element. + Iterator `hint` is used as a suggestion where to start to search insert position. -

+ Iterator `hint` is ignored due to container's underlying storage implementation. This overload exists just to have this container compatible with standard C++ containers as much as possible. + **Returns:** + Iterator to the inserted element. +

-``` -iterator insert(const_iterator hint, value_type&& value); -``` -**Preconditions:** -1. `!full()` -2. `cbegin() <= hint && hint <= cend()` -**Effects:** -Inserts `value` using move semantics. +5. ``` + iterator insert(const_iterator hint, value_type&& value); + ``` -Iterator `hint` is used as a suggestion where to start to search insert position. + **Preconditions:** + 1. `!full()` + 2. `cbegin() <= hint && hint <= cend()` -**Note:** -The behavior is undefined if preconditions are not satisfied. + **Effects:** + Inserts `value` using move semantics. -**Returns:** -Iterator to the inserted element. + Iterator `hint` is used as a suggestion where to start to search insert position. -

+ Iterator `hint` is ignored due to container's underlying storage implementation. This overload exists just to have this container compatible with standard C++ containers as much as possible. + **Returns:** + Iterator to the inserted element. +

-``` -template -iterator insert(const_iterator hint, P&& value); -``` -**Preconditions:** -1. `!full()` -2. `cbegin() <= hint && hint <= cend()` -**Effects:** -Inserts a new element into the container. +6. ``` + template + iterator insert(const_iterator hint, P&& value); + ``` -New element is constructed as `value_type(std::forward

(value))`. + **Preconditions:** + 1. `!full()` + 2. `cbegin() <= hint && hint <= cend()` -Iterator `hint` is used as a suggestion where to start to search insert position. + **Effects:** + Inserts a new element into the container. -**Note:** -This overload participates in overload resolution only if `std::is_constructible::value` is `true`. + New element is constructed as `value_type(std::forward

(value))`. -**Note:** -The behavior is undefined if preconditions are not satisfied. + Iterator `hint` is used as a suggestion where to start to search insert position. -**Returns:** -Iterator to the inserted element. + Iterator `hint` is ignored due to container's underlying storage implementation. This overload exists just to have this container compatible with standard C++ containers as much as possible. -

+ **Note:** + This overload participates in overload resolution only if `std::is_constructible::value` is `true`. + **Returns:** + Iterator to the inserted element. +

-``` -template -void insert(InputIt first, InputIt last); -``` -**Preconditions:** -`std::distance(first, last) <= available()` -**Effects:** -Inserts elements from range `[first, last)`. +7. ``` + template + void insert(InputIt first, InputIt last); + ``` -The call to this function is equivalent to: -``` -while (first != last) -{ - insert(*first); - ++first; -} -``` + **Preconditions:** + `std::distance(first, last) <= available()` -**Note:** -This overload participates in overload resolution only if `InputIt` satisfies requirements of [*LegacyInputIterator*](https://en.cppreference.com/w/cpp/named_req/InputIterator). + **Effects:** + Inserts elements from range `[first, last)`. -**Note:** -The behavior is undefined if preconditions are not satisfied. + The call to this function is equivalent to: + ``` + while (first != last) + { + insert(*first); + ++first; + } + ``` -

+ **Note:** + This overload participates in overload resolution only if `InputIt` satisfies requirements of [*LegacyInputIterator*](https://en.cppreference.com/w/cpp/named_req/InputIterator). +

-``` -void insert(std::initializer_list ilist); -``` -**Preconditions:** -`ilist.size() <= available()` +8. ``` + void insert(std::initializer_list ilist); + ``` -**Effects:** -Inserts elements from initializer list `ilist`. + **Preconditions:** + `ilist.size() <= available()` -The call to this function is equivalent to: -``` -insert(ilist.begin(), ilist.end()); -``` + **Effects:** + Inserts elements from initializer list `ilist`. -**Note:** -The behavior is undefined if preconditions are not satisfied. + The call to this function is equivalent to `insert(ilist.begin(), ilist.end())`. -

+

### erase -``` -iterator erase(iterator pos); -``` -``` -iterator erase(const_iterator pos); -``` - -**Preconditions:** -`cbegin() <= pos && pos < cend()` - -**Effects:** -Removes the element at `pos`. - -**Note:** -The behavior is undefined if preconditions are not satisfied. - -**Returns:** -Iterator following the last removed element. - -

- - - -``` -iterator erase(const_iterator first, const_iterator last); -``` +1. ``` + iterator erase(iterator pos); + ``` +2. ``` + iterator erase(const_iterator pos); + ``` -**Preconditions:** -`cbegin() <= first && first <= last && last <= cend()` + **Preconditions:** + `cbegin() <= pos && pos < cend()` -**Effects:** -Removes the elements in the range `[first, last)`. + **Effects:** + Removes the element at `pos`. -**Note:** -The behavior is undefined if preconditions are not satisfied. + **Returns:** + Iterator following the last removed element. -**Returns:** -Iterator following the last removed element. +

-

+3. ``` + iterator erase(const_iterator first, const_iterator last); + ``` -``` -size_type erase(const Key& key); -``` + **Preconditions:** + `cbegin() <= first && first <= last && last <= cend()` -**Effects:** -Removes all elements with the key equivalent to `key`. + **Effects:** + Removes the elements in the range `[first, last)`. -**Returns:** -Number of elements removed. + **Returns:** + Iterator following the last removed element. -

+

-``` -template -size_type erase(K&& x); -``` +4. ``` + size_type erase(const Key& key); + ``` +5. ``` + template + size_type erase(K&& x); + ``` -**Effects:** -Removes all elements with key that compares equivalent to the value `x`. + **Effects:** + Removes all elements with the key equivalent to `key` or `x`. -**Note:** -This overload participates in overload resolution only if `KeyEqual::is_transparent` exists and is a valid type. It allows calling this function without constructing an instance of `Key`. + **Note:** + Overload (5) participates in overload resolution only if `KeyEqual::is_transparent` exists and is a valid type. It allows calling this function without constructing an instance of `Key`. -**Returns:** -Number of elements removed. + **Returns:** + Number of elements removed. -

+

### swap -``` -void swap(static_unordered_flat_multiset& other); -``` +1. ``` + void swap(static_unordered_flat_multiset& other); + ``` -**Effects:** -Exchanges the contents of the container with those of `other`. + **Effects:** + Exchanges the contents of the container with those of `other`. -**Complexity:** -Linear in size. + **Complexity:** + Linear in size. -

+

### find -``` -iterator find(const Key& key); -``` -``` -const_iterator find(const Key& key) const; -``` - -**Effects:** -Returns an iterator to an element with key equivalent to `key`, or `end()` if such an element is not found. If there are several elements with key in the container, any of them may be returned. - -**Complexity:** -Constant in the best case. Linear in `size()` in the worst case. - -

- - - -``` -template -iterator find(const K& x); -``` -``` -template -const_iterator find(const K& x) const; -``` +1. ``` + iterator find(const Key& key); + ``` +2. ``` + const_iterator find(const Key& key) const; + ``` +3. ``` + template + iterator find(const K& x); + ``` +4. ``` + template + const_iterator find(const K& x) const; + ``` -**Effects:** -Returns an iterator to an element with key that compares equivalent to `x`, or `end()` if such an element is not found. If there are several elements with key in the container, any of them may be returned. + **Effects:** + Returns an iterator pointing to the element with key equivalent to `key` or `x`. Returns `end()` if no such element is found. + If there are several elements with key in the container, any of them may be returned. -**Note:** -This overload participates in overload resolution only if `KeyEqual::is_transparent` exists and is a valid type. It allows calling this function without constructing an instance of `Key`. + **Note:** + Overloads (3) and (4) participate in overload resolution only if `KeyEqual::is_transparent` exists and is a valid type. It allows calling these functions without constructing an instance of `Key`. -**Complexity:** -Constant in the best case. Linear in `size()` in the worst case. + **Complexity:** + Constant in the best case. Linear in `size()` in the worst case. -

+

### count -``` -size_type count(const Key& key) const; -``` - -**Effects:** -Returns the number of elements with key equivalent to `key`. - -**Complexity:** -Linear in `size()`. - -

- - - -``` -template -size_type count(const K& x) const; -``` +1. ``` + size_type count(const Key& key) const; + ``` +2. ``` + template + size_type count(const K& x) const; + ``` -**Effects:** -Returns the number of elements with key that compares equivalent to the value `x`. + **Effects:** + Returns the number of elements with key equivalent to `key` or `x`. -**Note:** -This overload participates in overload resolution only if `KeyEqual::is_transparent` exists and is a valid type. It allows calling this function without constructing an instance of `Key`. + **Note:** + Overload (2) participates in overload resolution only if `KeyEqual::is_transparent` exists and is a valid type. It allows calling this function without constructing an instance of `Key`. -**Complexity:** -Linear in `size()`. + **Complexity:** + Linear in `size()`. -

+

### contains -``` -bool contains(const Key& key) const; -``` - -**Effects:** -Returns `true` if the container contains an element with key equivalent to `key`, otherwise returns `false`. - -**Complexity:** -Constant in the best case. Linear in `size()` in the worst case. - -

- - - -``` -template -bool contains(const K& x) const; -``` +1. ``` + bool contains(const Key& key) const; + ``` +2. ``` + template + bool contains(const K& x) const; + ``` -**Effects:** -Returns `true` if the container contains an element with the key that compares equivalent to `x`, otherwise returns `false`. + **Effects:** + Returns `true` if the container contains an element with key equivalent to `key` or `x`, otherwise returns `false`. -**Note:** -This overload participates in overload resolution only if `KeyEqual::is_transparent` exists and is a valid type. It allows calling this function without constructing an instance of `Key`. + **Note:** + Overload (2) participates in overload resolution only if `KeyEqual::is_transparent` exists and is a valid type. It allows calling this function without constructing an instance of `Key`. -**Complexity:** -Constant in the best case. Linear in `size()` in the worst case. + **Complexity:** + Constant in the best case. Linear in `size()` in the worst case. -

+

### data -``` -value_type* data() noexcept; -``` -``` -const value_type* data() const noexcept; -``` +1. ``` + value_type* data() noexcept; + ``` +2. ``` + const value_type* data() const noexcept; + ``` -**Effects:** -Returns pointer to the underlying array serving as element storage. The pointer is such that range `[data(), data() + size())` is always a valid range, even if the container is empty. `data()` is not dereferenceable if the container is empty. + **Effects:** + Returns pointer to the underlying array serving as element storage. The pointer is such that range `[data(), data() + size())` is always a valid range, even if the container is empty. `data()` is not dereferenceable if the container is empty. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

@@ -1012,93 +931,93 @@ Constant. ### operator== -``` -template -bool operator== -( - const static_unordered_flat_multiset& x, - const static_unordered_flat_multiset& y -); -``` +1. ``` + template + bool operator== + ( + const static_unordered_flat_multiset& x, + const static_unordered_flat_multiset& y + ); + ``` -**Effects:** -Checks if the contents of `x` and `y` are equal. + **Effects:** + Checks if the contents of `x` and `y` are equal. -The contents of `x` and `y` are equal if the following conditions hold: -* `x.size() == y.size()` -* For each element in `x` there is equal element in `y`. + The contents of `x` and `y` are equal if the following conditions hold: + * `x.size() == y.size()` + * For each element in `x` there is equal element in `y`. -The comparison is performed by `std::is_permutation`. -This comparison ignores the container's `KeyEqual` function. + The comparison is performed by `std::is_permutation`. + This comparison ignores the container's `KeyEqual` function. -**Returns:** -`true` if the contents of the `x` and `y` are equal, `false` otherwise. + **Returns:** + `true` if the contents of the `x` and `y` are equal, `false` otherwise. -

+

### operator!= -``` -template -bool operator!= -( - const static_unordered_flat_multiset& x, - const static_unordered_flat_multiset& y -); -``` +1. ``` + template + bool operator!= + ( + const static_unordered_flat_multiset& x, + const static_unordered_flat_multiset& y + ); + ``` -**Effects:** -Checks if the contents of `x` and `y` are equal. + **Effects:** + Checks if the contents of `x` and `y` are equal. -For details see `operator==`. + For details see `operator==`. -**Returns:** -`true` if the contents of the `x` and `y` are not equal, `false` otherwise. + **Returns:** + `true` if the contents of the `x` and `y` are not equal, `false` otherwise. -

+

### swap -``` -template -void swap -( - static_unordered_flat_multiset& x, - static_unordered_flat_multiset& y -); -``` +1. ``` + template + void swap + ( + static_unordered_flat_multiset& x, + static_unordered_flat_multiset& y + ); + ``` -**Effects:** -Swaps the contents of `x` and `y`. Calls `x.swap(y)`. + **Effects:** + Swaps the contents of `x` and `y`. Calls `x.swap(y)`. -

+

### erase_if -``` -template -typename static_unordered_flat_multiset::size_type - erase_if(static_unordered_flat_multiset& c, Predicate pred); -``` +1. ``` + template + typename static_unordered_flat_multiset::size_type + erase_if(static_unordered_flat_multiset& c, Predicate pred); + ``` -**Effects:** -Erases all elements that satisfy the predicate `pred` from the container. + **Effects:** + Erases all elements that satisfy the predicate `pred` from the container. -`pred` is unary predicate which returns `true` if the element should be removed. + `pred` is unary predicate which returns `true` if the element should be removed. -**Returns:** -The number of erased elements. + **Returns:** + The number of erased elements. -**Complexity:** -Linear. + **Complexity:** + Linear. -

+

diff --git a/doc/static_unordered_flat_set.md b/doc/static_unordered_flat_set.md index 2ad3d36..6252840 100644 --- a/doc/static_unordered_flat_set.md +++ b/doc/static_unordered_flat_set.md @@ -135,822 +135,793 @@ static constexpr size_type static_capacity = N; ### (constructor) -``` -static_unordered_flat_set() noexcept(std::is_nothrow_default_constructible::value) -``` -``` -explicit static_unordered_flat_set(const KeyEqual& equal) noexcept(std::is_nothrow_copy_constructible::value) -``` - -**Effects:** -Constructs an empty container. - -

+1. ``` + static_unordered_flat_set() noexcept(std::is_nothrow_default_constructible::value) + ``` +2. ``` + explicit static_unordered_flat_set(const KeyEqual& equal) noexcept(std::is_nothrow_copy_constructible::value) + ``` + **Effects:** + Constructs an empty container. +

-``` -template -static_unordered_flat_set(InputIt first, InputIt last); -``` -``` -template -static_unordered_flat_set(InputIt first, InputIt last, const KeyEqual& equal); -``` -**Preconditions:** -`std::distance(first, last) <= capacity()` -**Effects:** -Constructs an empty container and inserts elements from the range `[first, last)`. +3. ``` + template + static_unordered_flat_set(InputIt first, InputIt last); + ``` +4. ``` + template + static_unordered_flat_set(InputIt first, InputIt last, const KeyEqual& equal); + ``` -**Note:** -This overload participates in overload resolution only if `InputIt` satisfies requirements of [*LegacyInputIterator*](https://en.cppreference.com/w/cpp/named_req/InputIterator). + **Preconditions:** + `std::distance(first, last) <= capacity()` -**Note:** -The behavior is undefined if preconditions are not satisfied. + **Effects:** + Constructs an empty container and inserts elements from the range `[first, last)`. -**Complexity:** -Linear in `std::distance(first, last)`. + **Note:** + This overload participates in overload resolution only if `InputIt` satisfies requirements of [*LegacyInputIterator*](https://en.cppreference.com/w/cpp/named_req/InputIterator). -

+ **Complexity:** + Linear in `std::distance(first, last)`. +

-``` -static_unordered_flat_set(std::initializer_list ilist); -``` -``` -static_unordered_flat_set(std::initializer_list ilist, const KeyEqual& equal); -``` -**Preconditions:** -`ilist.size() <= capacity()` +5. ``` + static_unordered_flat_set(std::initializer_list ilist); + ``` +6. ``` + static_unordered_flat_set(std::initializer_list ilist, const KeyEqual& equal); + ``` -**Effects:** -Constructs an empty container and inserts elements from the initializer list `ilist`. + **Preconditions:** + `ilist.size() <= capacity()` -**Note:** -The behavior is undefined if preconditions are not satisfied. + **Effects:** + Constructs an empty container and inserts elements from the initializer list `ilist`. -**Complexity:** -Linear in `ilist.size()`. + **Complexity:** + Linear in `ilist.size()`. -

+

-``` -static_unordered_flat_set(const static_unordered_flat_set& other); -``` +7. ``` + static_unordered_flat_set(const static_unordered_flat_set& other); + ``` -**Effects:** -Copy constructor. -Constructs the container with the copy of the contents of `other`. + **Effects:** + Copy constructor. + Constructs the container with the copy of the contents of `other`. -**Complexity:** -Linear in size. + **Complexity:** + Linear in size. -

+

-``` -static_unordered_flat_set(static_unordered_flat_set&& other); -``` +8. ``` + static_unordered_flat_set(static_unordered_flat_set&& other); + ``` -**Effects:** -Move constructor. -Constructs the container with the contents of `other` using move semantics. + **Effects:** + Move constructor. + Constructs the container with the contents of `other` using move semantics. -`other` is not guaranteed to be empty after the move. + `other` is not guaranteed to be empty after the move. -`other` is in a valid but unspecified state after the move. + `other` is in a valid but unspecified state after the move. -**Complexity:** -Linear in size. + **Complexity:** + Linear in size. -

+

### (destructor) -``` -~static_unordered_flat_set(); -``` +1. ``` + ~static_unordered_flat_set(); + ``` -**Effects:** -Destructs the container. The destructors of the elements are called and the used storage is deallocated. + **Effects:** + Destructs the container. The destructors of the elements are called and the used storage is deallocated. -**Complexity:** -Linear in size. + **Complexity:** + Linear in size. -

+

### operator= -``` -static_unordered_flat_set& operator=(const static_unordered_flat_set& other); -``` - -**Effects:** -Copy assignment operator. -Replaces the contents with a copy of the contents of `other`. +1. ``` + static_unordered_flat_set& operator=(const static_unordered_flat_set& other); + ``` -**Returns:** -`*this()`. + **Effects:** + Copy assignment operator. + Replaces the contents with a copy of the contents of `other`. -**Complexity:** -Linear in size. + **Returns:** + `*this()`. -

+ **Complexity:** + Linear in size. +

-``` -static_unordered_flat_set& operator=(static_unordered_flat_set&& other); -``` -**Effects:** -Move assignment operator. -Replaces the contents with those of `other` using move semantics. +2. ``` + static_unordered_flat_set& operator=(static_unordered_flat_set&& other); + ``` -`other` is not guaranteed to be empty after the move. + **Effects:** + Move assignment operator. + Replaces the contents with those of `other` using move semantics. -`other` is in a valid but unspecified state after the move. + `other` is not guaranteed to be empty after the move. -**Returns:** -`*this()`. + `other` is in a valid but unspecified state after the move. -**Complexity:** -Linear in size. + **Returns:** + `*this()`. -

+ **Complexity:** + Linear in size. +

-``` -static_unordered_flat_set& operator=(std::initializer_list ilist); -``` -**Preconditions:** -`ilist.size() <= capacity()` +3. ``` + static_unordered_flat_set& operator=(std::initializer_list ilist); + ``` -**Effects:** -Replaces the contents with those identified by initializer list `ilist`. + **Preconditions:** + `ilist.size() <= capacity()` -**Note:** -The behavior is undefined if preconditions are not satisfied. + **Effects:** + Replaces the contents with those identified by initializer list `ilist`. -**Returns:** -`*this()`. + **Returns:** + `*this()`. -**Complexity:** -Linear in size. + **Complexity:** + Linear in size. -

+

### key_eq -``` -key_equal key_eq() const; -``` +1. ``` + key_equal key_eq() const; + ``` -**Effects:** -Returns the function object that compares keys for equality, which is a copy of this container's constructor argument `equal`. + **Effects:** + Returns the function object that compares keys for equality, which is a copy of this container's constructor argument `equal`. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

### begin, cbegin -``` -iterator begin() noexcept; -``` -``` -const_iterator begin() const noexcept; -``` -``` -const_iterator cbegin() const noexcept; -``` - -**Effects:** -Returns an iterator to the first element of the container. +1. ``` + iterator begin() noexcept; + ``` +2. ``` + const_iterator begin() const noexcept; + ``` +3. ``` + const_iterator cbegin() const noexcept; + ``` -If the container is empty, the returned iterator will be equal to `end()`. + **Effects:** + Returns an iterator to the first element of the container. + If the container is empty, the returned iterator will be equal to `end()`. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

### end, cend -``` -iterator end() noexcept; -``` -``` -const_iterator end() const noexcept; -``` -``` -const_iterator cend() const noexcept; -``` - -**Effects:** -Returns an iterator to the element following the last element of the container. +1. ``` + iterator end() noexcept; + ``` +2. ``` + const_iterator end() const noexcept; + ``` +3. ``` + const_iterator cend() const noexcept; + ``` -This element acts as a placeholder; attempting to access it results in undefined behavior. + **Effects:** + Returns an iterator to the element following the last element of the container. + This element acts as a placeholder; attempting to access it results in undefined behavior. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

### nth -``` -iterator nth(size_type pos) noexcept; -``` -``` -const_iterator nth(size_type pos) const noexcept; -``` +1. ``` + iterator nth(size_type pos) noexcept; + ``` +2. ``` + const_iterator nth(size_type pos) const noexcept; + ``` -**Preconditions:** -`pos <= size()` + **Preconditions:** + `pos <= size()` -**Effects:** -Returns an iterator to the element at position `pos`. -If `pos == size()`, the returned iterator is equal to `end()`. + **Effects:** + Returns an iterator to the element at position `pos`. -**Complexity:** -Constant. + If `pos == size()`, the returned iterator is equal to `end()`. -

+ **Complexity:** + Constant. + +

### index_of -``` -size_type index_of(const_iterator pos) const noexcept; -``` +1. ``` + size_type index_of(const_iterator pos) const noexcept; + ``` -**Preconditions:** -`cbegin() <= pos && pos <= cend()` + **Preconditions:** + `cbegin() <= pos && pos <= cend()` -**Effects:** -Returns position of the element pointed by iterator `pos`, i.e. `std::distance(begin(), pos)`. + **Effects:** + Returns position of the element pointed by iterator `pos`, i.e. `std::distance(begin(), pos)`. -If `pos == end()`, the returned value is equal to `size()`. + If `pos == end()`, the returned value is equal to `size()`. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

### empty -``` -bool empty() const noexcept; -``` +1. ``` + bool empty() const noexcept; + ``` -**Effects:** -Returns `true` if the container has no elements, i.e. whether `begin() == end()`. + **Effects:** + Returns `true` if the container has no elements, i.e. whether `begin() == end()`. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

### full -``` -bool full() const noexcept; -``` +1. ``` + bool full() const noexcept; + ``` -**Effects:** -Returns `true` if the container is full, i.e. whether `size() == capacity()`. + **Effects:** + Returns `true` if the container is full, i.e. whether `size() == capacity()`. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

### size -``` -size_type size() const noexcept; -``` +1. ``` + size_type size() const noexcept; + ``` -**Effects:** -Returns the number of elements in the container, i.e. `std::distance(begin(), end())`. + **Effects:** + Returns the number of elements in the container, i.e. `std::distance(begin(), end())`. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

### max_size -``` -static constexpr size_type max_size() const noexcept; -``` +1. ``` + static constexpr size_type max_size() const noexcept; + ``` -**Effects:** -Returns the maximum number of elements the container is able to hold, i.e. returns `N`. + **Effects:** + Returns the maximum number of elements the container is able to hold, i.e. `N`. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

### capacity -``` -static constexpr size_type capacity() const noexcept; -``` +1. ``` + static constexpr size_type capacity() const noexcept; + ``` -**Effects:** -Returns the maximum number of elements the container is able to hold, i.e. returns `N`. + **Effects:** + Returns the maximum number of elements the container is able to hold, i.e. `N`. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

### available -``` -size_type available() const noexcept; -``` +1. ``` + size_type available() const noexcept; + ``` -**Effects:** -Returns the number of elements that can be inserted into the container, i.e. returns `capacity() - size()`. + **Effects:** + Returns the number of elements that can be inserted into the container, i.e. `capacity() - size()`. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

### clear -``` -void clear() noexcept; -``` +1. ``` + void clear() noexcept; + ``` -**Effects:** -Erases all elements from the container. -After this call, `size()` returns zero and `capacity()` remains unchanged. + **Effects:** + Erases all elements from the container. + After this call, `size()` returns zero and `capacity()` remains unchanged. -**Complexity:** -Linear in `size()`. + **Complexity:** + Linear in `size()`. -

+

### emplace -``` -template -std::pair emplace(Args&&... args); -``` - -**Preconditions:** -`!full()` +1. ``` + template + std::pair emplace(Args&&... args); + ``` -**Effects:** -Inserts a new element into the container only if the container does not already contain an element with an equivalent key. + **Preconditions:** + `!full()` -New element is constructed as `value_type(std::forward(args)...)`. + **Effects:** + Inserts new element into the container if the container doesn't already contain an element with an equivalent key. -The element may be constructed even if there already is an element with the key in the container, in which case the newly constructed element will be destroyed immediately. + New element is constructed as `value_type(std::forward(args)...)`. -**Note:** -The behavior is undefined if preconditions are not satisfied. + The element may be constructed even if there already is an element with the key in the container, in which case the newly constructed element will be destroyed immediately. -**Returns:** -Pair consisting of an iterator to the inserted element, or the already-existing element if no insertion happened, and a `bool` denoting whether the insertion took place (`true` if insertion happened, `false` if it did not). + **Returns:** + The iterator component points to the inserted element or to the already existing element. The `bool` component is `true` if insertion happened and `false` if it did not. -

+

### emplace_hint -``` -template -iterator emplace_hint(const_iterator hint, Args&&... args); -``` +1. ``` + template + iterator emplace_hint(const_iterator hint, Args&&... args); + ``` -**Preconditions:** -1. `!full()` -2. `cbegin() <= hint && hint <= cend()` + **Preconditions:** + 1. `!full()` + 2. `cbegin() <= hint && hint <= cend()` -**Effects:** -Inserts a new element into the container only if the container does not already contain an element with an equivalent key. + **Effects:** + Inserts new element into the container if the container doesn't already contain an element with an equivalent key. -New element is constructed as `value_type(std::forward(args)...)`. + New element is constructed as `value_type(std::forward(args)...)`. -The element may be constructed even if there already is an element with the key in the container, in which case the newly constructed element will be destroyed immediately. + The element may be constructed even if there already is an element with the key in the container, in which case the newly constructed element will be destroyed immediately. -Iterator `hint` is used as a suggestion where to start to search insert position. + Iterator `hint` is used as a suggestion where to start to search insert position. -**Note:** -The behavior is undefined if preconditions are not satisfied. + Iterator `hint` is ignored due to container's underlying storage implementation. This overload exists just to have this container compatible with standard C++ containers as much as possible. -**Returns:** -Iterator to the inserted element or to the already existing element. + **Returns:** + Iterator to the inserted element or to the already existing element. -

+

### insert -``` -std::pair insert(const value_type& value); -``` - -**Preconditions:** -`!full()` - -**Effects:** -Inserts copy of `value` only if the container does not already contain an element with an key equivalent to the key of `value`. +1. ``` + std::pair insert(const value_type& value); + ``` -**Note:** -The behavior is undefined if preconditions are not satisfied. + **Preconditions:** + `!full()` -**Returns:** -Pair consisting of an iterator to the inserted element, or the already-existing element if no insertion happened, and a `bool` denoting whether the insertion took place (`true` if insertion happened, `false` if it did not). + **Effects:** + Inserts copy of `value` if the container doesn't already contain an element with an equivalent key. -

+ **Returns:** + The iterator component points to the inserted element or to the already existing element. The `bool` component is `true` if insertion happened and `false` if it did not. +

-``` -std::pair insert(value_type&& value); -``` -**Preconditions:** -`!full()` +2. ``` + std::pair insert(value_type&& value); + ``` -**Effects:** -Inserts `value` using move semantics only if the container does not already contain an element with an key equivalent to the key of `value`. + **Preconditions:** + `!full()` -**Note:** -The behavior is undefined if preconditions are not satisfied. + **Effects:** + Inserts `value` using move semantics if the container doesn't already contain an element with an equivalent key. -**Returns:** -Pair consisting of an iterator to the inserted element, or the already-existing element if no insertion happened, and a `bool` denoting whether the insertion took place (`true` if insertion happened, `false` if it did not). + **Returns:** + The iterator component points to the inserted element or to the already existing element. The `bool` component is `true` if insertion happened and `false` if it did not. -

+

-``` -iterator insert(const_iterator hint, const value_type& value); -``` +3. ``` + template + std::pair insert(K&& x); + ``` -**Preconditions:** -1. `!full()` -2. `cbegin() <= hint && hint <= cend()` + **Preconditions:** + `!full()` -**Effects:** -Inserts copy of `value` only if the container does not already contain an element with an key equivalent to the key of `value`. + **Effects:** + Inserts new element if the container doesn't already contain an element with a key equivalent to `x`. -Iterator `hint` is used as a suggestion where to start to search insert position. + New element is constructed as `value_type(std::forward(x))`. -**Note:** -The behavior is undefined if preconditions are not satisfied. + **Note:** This overload participates in overload resolution only if `KeyEqual::is_transparent` exists and is a valid type. It allows calling this function without constructing an instance of `Key`. -**Returns:** -Iterator to the inserted element or to the already existing element. + **Returns:** + The iterator component points to the inserted element or to the already existing element. The `bool` component is `true` if insertion happened and `false` if it did not. -

+

-``` -iterator insert(const_iterator hint, value_type&& value); -``` - -**Preconditions:** -1. `!full()` -2. `cbegin() <= hint && hint <= cend()` +4. ``` + iterator insert(const_iterator hint, const value_type& value); + ``` -**Effects:** -Inserts `value` using move semantics only if the container does not already contain an element with an key equivalent to the key of `value`. + **Preconditions:** + 1. `!full()` + 2. `cbegin() <= hint && hint <= cend()` -Iterator `hint` is used as a suggestion where to start to search insert position. + **Effects:** + Inserts copy of `value` if the container doesn't already contain an element with an equivalent key. -**Note:** -The behavior is undefined if preconditions are not satisfied. + Iterator `hint` is used as a suggestion where to start to search insert position. -**Returns:** -Iterator to the inserted element or to the already existing element. + Iterator `hint` is ignored due to container's underlying storage implementation. This overload exists just to have this container compatible with standard C++ containers as much as possible. -

+ **Returns:** + Iterator to the inserted element or to the already existing element. +

-``` -template -void insert(InputIt first, InputIt last); -``` -**Preconditions:** -`std::distance(first, last) <= available()` - -**Effects:** -Inserts elements from range `[first, last)`. +5. ``` + iterator insert(const_iterator hint, value_type&& value); + ``` -The call to this function is equivalent to: -``` -while (first != last) -{ - insert(*first); - ++first; -} -``` + **Preconditions:** + 1. `!full()` + 2. `cbegin() <= hint && hint <= cend()` -**Note:** -This overload participates in overload resolution only if `InputIt` satisfies requirements of [*LegacyInputIterator*](https://en.cppreference.com/w/cpp/named_req/InputIterator). + **Effects:** + Inserts `value` using move semantics if the container doesn't already contain an element with an equivalent key. -**Note:** -The behavior is undefined if preconditions are not satisfied. + Iterator `hint` is used as a suggestion where to start to search insert position. -

+ Iterator `hint` is ignored due to container's underlying storage implementation. This overload exists just to have this container compatible with standard C++ containers as much as possible. + **Returns:** + Iterator to the inserted element or to the already existing element. +

-``` -void insert(std::initializer_list ilist); -``` -**Preconditions:** -`ilist.size() <= available()` -**Effects:** -Inserts elements from initializer list `ilist`. +6. ``` + template + iterator insert(const_iterator hint, K&& x); + ``` -The call to this function is equivalent to: -``` -insert(ilist.begin(), ilist.end()); -``` + **Preconditions:** + 1. `!full()` + 2. `cbegin() <= hint && hint <= cend()` -**Note:** -The behavior is undefined if preconditions are not satisfied. + **Effects:** + Inserts new element if the container doesn't already contain an element with a key equivalent to `x`. -

+ New element is constructed as `value_type(std::forward(x))`. + Iterator `hint` is used as a suggestion where to start to search insert position. + Iterator `hint` is ignored due to container's underlying storage implementation. This overload exists just to have this container compatible with standard C++ containers as much as possible. -### erase + **Note:** This overload participates in overload resolution only if all following conditions are satisfied: + 1. `KeyEqual::is_transparent` exists and is a valid type. It allows calling this function without constructing an instance of `Key`. + 2. `std::is_convertible_v` is `false`. + 3. `std::is_convertible_v` is `false`. -``` -iterator erase(iterator pos); -``` -``` -iterator erase(const_iterator pos); -``` + **Returns:** + Iterator to the inserted element or to the already existing element. -**Preconditions:** -`cbegin() <= pos && pos < cend()` +

-**Effects:** -Removes the element at `pos`. -**Note:** -The behavior is undefined if preconditions are not satisfied. -**Returns:** -Iterator following the last removed element. +7. ``` + template + void insert(InputIt first, InputIt last); + ``` -

+ **Preconditions:** + `std::distance(first, last) <= available()` + **Effects:** + Inserts elements from range `[first, last)`. + The call to this function is equivalent to: + ``` + while (first != last) + { + insert(*first); + ++first; + } + ``` -``` -iterator erase(const_iterator first, const_iterator last); -``` + **Note:** + This overload participates in overload resolution only if `InputIt` satisfies requirements of [*LegacyInputIterator*](https://en.cppreference.com/w/cpp/named_req/InputIterator). -**Preconditions:** -`cbegin() <= first && first <= last && last <= cend()` +

-**Effects:** -Removes the elements in the range `[first, last)`. -**Note:** -The behavior is undefined if preconditions are not satisfied. -**Returns:** -Iterator following the last removed element. +8. ``` + void insert(std::initializer_list ilist); + ``` -

+ **Preconditions:** + `ilist.size() <= available()` + **Effects:** + Inserts elements from initializer list `ilist`. + The call to this function is equivalent to `insert(ilist.begin(), ilist.end())`. -``` -size_type erase(const Key& key); -``` +

-**Effects:** -Removes the element (if one exists) with the key equivalent to `key`. -**Returns:** -Number of elements removed (0 or 1). -

+### erase +1. ``` + iterator erase(iterator pos); + ``` +2. ``` + iterator erase(const_iterator pos); + ``` + **Preconditions:** + `cbegin() <= pos && pos < cend()` -``` -template -size_type erase(K&& x); -``` + **Effects:** + Removes the element at `pos`. -**Effects:** -Removes the element (if one exists) with key that compares equivalent to the value `x`. + **Returns:** + Iterator following the last removed element. -**Note:** -This overload participates in overload resolution only if `Compare::is_transparent` exists and is a valid type. It allows calling this function without constructing an instance of `Key`. +

-**Returns:** -Number of elements removed (0 or 1). -

+3. ``` + iterator erase(const_iterator first, const_iterator last); + ``` + **Preconditions:** + `cbegin() <= first && first <= last && last <= cend()` -### swap + **Effects:** + Removes the elements in the range `[first, last)`. -``` -void swap(static_unordered_flat_set& other); -``` + **Returns:** + Iterator following the last removed element. -**Effects:** -Exchanges the contents of the container with those of `other`. +

-**Complexity:** -Linear in size. -

+4. ``` + size_type erase(const Key& key); + ``` +5. ``` + template + size_type erase(K&& x); + ``` + **Effects:** + Removes the element (if one exists) with the key equivalent to `key` or `x`. -### find + **Note:** + Overload (5) participates in overload resolution only if `KeyEqual::is_transparent` exists and is a valid type. It allows calling this function without constructing an instance of `Key`. -``` -iterator find(const Key& key); -``` -``` -const_iterator find(const Key& key) const; -``` + **Returns:** + Number of elements removed (0 or 1). -**Effects:** -Returns an iterator to an element with key equivalent to `key`, or `end()` if such an element is not found. +

-**Complexity:** -Constant in the best case. Linear in `size()` in the worst case. -

+### swap +1. ``` + void swap(static_unordered_flat_set& other); + ``` -``` -template -iterator find(const K& x); -``` -``` -template -const_iterator find(const K& x) const; -``` + **Effects:** + Exchanges the contents of the container with those of `other`. -**Effects:** -Returns an iterator to an element with key that compares equivalent to `x`, or `end()` if such an element is not found. + **Complexity:** + Linear in size. -**Note:** -This overload participates in overload resolution only if `KeyEqual::is_transparent` exists and is a valid type. It allows calling this function without constructing an instance of `Key`. +

-**Complexity:** -Constant in the best case. Linear in `size()` in the worst case. -

+### find +1. ``` + iterator find(const Key& key); + ``` +2. ``` + const_iterator find(const Key& key) const; + ``` +3. ``` + template + iterator find(const K& x); + ``` +4. ``` + template + const_iterator find(const K& x) const; + ``` -### count + **Effects:** + Returns an iterator pointing to the element with key equivalent to `key` or `x`. Returns `end()` if no such element is found. -``` -size_type count(const Key& key) const; -``` + **Note:** + Overloads (3) and (4) participate in overload resolution only if `KeyEqual::is_transparent` exists and is a valid type. It allows calling these functions without constructing an instance of `Key`. -**Effects:** -Returns the number of elements with key equivalent to `key`, which is either 1 or 0 since this container does not allow duplicates. + **Complexity:** + Constant in the best case. Linear in `size()` in the worst case. -**Complexity:** -Constant in the best case. Linear in `size()` in the worst case. +

-

+### count -``` -template -size_type count(const K& x) const; -``` +1. ``` + size_type count(const Key& key) const; + ``` +2. ``` + template + size_type count(const K& x) const; + ``` -**Effects:** -Returns the number of elements with key that compares equivalent to `x`, which is either 1 or 0 since this container does not allow duplicates. + **Effects:** + Returns the number of elements with key equivalent to `key` or `x`, which is either 1 or 0 since this container does not allow duplicates. -**Note:** -This overload participates in overload resolution only if `KeyEqual::is_transparent` exists and is a valid type. It allows calling this function without constructing an instance of `Key`. + **Note:** + Overload (2) participates in overload resolution only if `KeyEqual::is_transparent` exists and is a valid type. It allows calling this function without constructing an instance of `Key`. -**Complexity:** -Constant in the best case. Linear in `size()` in the worst case. + **Complexity:** + Constant in the best case. Linear in `size()` in the worst case. -

+

### contains -``` -bool contains(const Key& key) const; -``` - -**Effects:** -Returns `true` if the container contains an element with key equivalent to `key`, otherwise returns `false`. - -**Complexity:** -Constant in the best case. Linear in `size()` in the worst case. - -

- - - -``` -template -bool contains(const K& x) const; -``` +1. ``` + bool contains(const Key& key) const; + ``` +2. ``` + template + bool contains(const K& x) const; + ``` -**Effects:** -Returns `true` if the container contains an element with the key that compares equivalent to `x`, otherwise returns `false`. + **Effects:** + Returns `true` if the container contains an element with key equivalent to `key` or `x`, otherwise returns `false`. -**Note:** -This overload participates in overload resolution only if `KeyEqual::is_transparent` exists and is a valid type. It allows calling this function without constructing an instance of `Key`. + **Note:** + Overload (2) participates in overload resolution only if `KeyEqual::is_transparent` exists and is a valid type. It allows calling this function without constructing an instance of `Key`. -**Complexity:** -Constant in the best case. Linear in `size()` in the worst case. + **Complexity:** + Constant in the best case. Linear in `size()` in the worst case. -

+

### data -``` -value_type* data() noexcept; -``` -``` -const value_type* data() const noexcept; -``` +1. ``` + value_type* data() noexcept; + ``` +2. ``` + const value_type* data() const noexcept; + ``` -**Effects:** -Returns pointer to the underlying array serving as element storage. The pointer is such that range `[data(), data() + size())` is always a valid range, even if the container is empty. `data()` is not dereferenceable if the container is empty. + **Effects:** + Returns pointer to the underlying array serving as element storage. The pointer is such that range `[data(), data() + size())` is always a valid range, even if the container is empty. `data()` is not dereferenceable if the container is empty. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

@@ -958,93 +929,93 @@ Constant. ### operator== -``` -template -bool operator== -( - const static_unordered_flat_set& x, - const static_unordered_flat_set& y -); -``` +1. ``` + template + bool operator== + ( + const static_unordered_flat_set& x, + const static_unordered_flat_set& y + ); + ``` -**Effects:** -Checks if the contents of `x` and `y` are equal. + **Effects:** + Checks if the contents of `x` and `y` are equal. -The contents of `x` and `y` are equal if the following conditions hold: -* `x.size() == y.size()` -* For each element in `x` there is equal element in `y`. + The contents of `x` and `y` are equal if the following conditions hold: + * `x.size() == y.size()` + * For each element in `x` there is equal element in `y`. -The comparison is performed by `std::is_permutation`. -This comparison ignores the container's `KeyEqual` function. + The comparison is performed by `std::is_permutation`. + This comparison ignores the container's `KeyEqual` function. -**Returns:** -`true` if the contents of the `x` and `y` are equal, `false` otherwise. + **Returns:** + `true` if the contents of the `x` and `y` are equal, `false` otherwise. -

+

### operator!= -``` -template -bool operator!= -( - const static_unordered_flat_set& x, - const static_unordered_flat_set& y -); -``` +1. ``` + template + bool operator!= + ( + const static_unordered_flat_set& x, + const static_unordered_flat_set& y + ); + ``` -**Effects:** -Checks if the contents of `x` and `y` are equal. + **Effects:** + Checks if the contents of `x` and `y` are equal. -For details see `operator==`. + For details see `operator==`. -**Returns:** -`true` if the contents of the `x` and `y` are not equal, `false` otherwise. + **Returns:** + `true` if the contents of the `x` and `y` are not equal, `false` otherwise. -

+

### swap -``` -template -void swap -( - static_unordered_flat_set& x, - static_unordered_flat_set& y -); -``` +1. ``` + template + void swap + ( + static_unordered_flat_set& x, + static_unordered_flat_set& y + ); + ``` -**Effects:** -Swaps the contents of `x` and `y`. Calls `x.swap(y)`. + **Effects:** + Swaps the contents of `x` and `y`. Calls `x.swap(y)`. -

+

### erase_if -``` -template -typename static_unordered_flat_set::size_type - erase_if(static_unordered_flat_set& c, Predicate pred); -``` +1. ``` + template + typename static_unordered_flat_set::size_type + erase_if(static_unordered_flat_set& c, Predicate pred); + ``` -**Effects:** -Erases all elements that satisfy the predicate `pred` from the container. + **Effects:** + Erases all elements that satisfy the predicate `pred` from the container. -`pred` is unary predicate which returns `true` if the element should be removed. + `pred` is unary predicate which returns `true` if the element should be removed. -**Returns:** -The number of erased elements. + **Returns:** + The number of erased elements. -**Complexity:** -Linear. + **Complexity:** + Linear. -

+

diff --git a/doc/static_vector.md b/doc/static_vector.md index ad44d62..b107401 100644 --- a/doc/static_vector.md +++ b/doc/static_vector.md @@ -135,1067 +135,979 @@ static constexpr size_type static_capacity = N; ### (constructor) -``` -static_vector() noexcept; -``` - -**Effects:** -Constructs an empty container. +1. ``` + static_vector() noexcept; + ``` -**Complexity:** -Constant. + **Effects:** + Constructs an empty container. -

+ **Complexity:** + Constant. +

-``` -static_vector(size_type n); -``` -**Preconditions:** -`n <= capacity()` +2. ``` + static_vector(size_type n); + ``` -**Effects:** -Constructs the container with `n` [value-initialized](https://en.cppreference.com/w/cpp/language/value_initialization) elements. + **Preconditions:** + `n <= capacity()` -**Note:** -The behavior is undefined if preconditions are not satisfied. + **Effects:** + Constructs the container with `n` [value-initialized](https://en.cppreference.com/w/cpp/language/value_initialization) elements. -**Complexity:** -Linear in `n`. + **Complexity:** + Linear in `n`. -

+

-``` -static_vector(size_type n, sfl::default_init_t); -``` - -**Preconditions:** -`n <= capacity()` +3. ``` + static_vector(size_type n, sfl::default_init_t); + ``` -**Effects:** -Constructs the container with `n` [default-initialized](https://en.cppreference.com/w/cpp/language/default_initialization) elements. + **Preconditions:** + `n <= capacity()` -**Note:** -The behavior is undefined if preconditions are not satisfied. + **Effects:** + Constructs the container with `n` [default-initialized](https://en.cppreference.com/w/cpp/language/default_initialization) elements. -**Complexity:** -Linear in `n`. + **Complexity:** + Linear in `n`. -

+

-``` -static_vector(size_type n, const T& value); -``` - -**Preconditions:** -`n <= capacity()` +4. ``` + static_vector(size_type n, const T& value); + ``` -**Effects:** -Constructs the container with `n` copies of elements with value `value`. + **Preconditions:** + `n <= capacity()` -**Note:** -The behavior is undefined if preconditions are not satisfied. + **Effects:** + Constructs the container with `n` copies of elements with value `value`. -**Complexity:** -Linear in `n`. + **Complexity:** + Linear in `n`. -

+

-``` -template -static_vector(InputIt first, InputIt last); -``` - -**Preconditions:** -`std::distance(first, last) <= capacity()` - -**Effects:** -Constructs the container with the contents of the range `[first, last)`. +5. ``` + template + static_vector(InputIt first, InputIt last); + ``` -**Note:** -This overload participates in overload resolution only if `InputIt` satisfies requirements of [*LegacyInputIterator*](https://en.cppreference.com/w/cpp/named_req/InputIterator). + **Preconditions:** + `std::distance(first, last) <= capacity()` -**Note:** -The behavior is undefined if preconditions are not satisfied. + **Effects:** + Constructs the container with the contents of the range `[first, last)`. -**Complexity:** -Linear in `std::distance(first, last)`. + **Note:** + This overload participates in overload resolution only if `InputIt` satisfies requirements of [*LegacyInputIterator*](https://en.cppreference.com/w/cpp/named_req/InputIterator). -

+ **Complexity:** + Linear in `std::distance(first, last)`. +

-``` -static_vector(std::initializer_list ilist); -``` -**Preconditions:** -`ilist.size() <= capacity()` +6. ``` + static_vector(std::initializer_list ilist); + ``` -**Effects:** -Constructs the container with the contents of the initializer list `ilist`. + **Preconditions:** + `ilist.size() <= capacity()` -**Note:** -The behavior is undefined if preconditions are not satisfied. + **Effects:** + Constructs the container with the contents of the initializer list `ilist`. -**Complexity:** -Linear in `ilist.size()`. + **Complexity:** + Linear in `ilist.size()`. -

+

-``` -static_vector(const static_vector& other); -``` +7. ``` + static_vector(const static_vector& other); + ``` -**Effects:** -Copy constructor. -Constructs the container with the copy of the contents of `other`. + **Effects:** + Copy constructor. + Constructs the container with the copy of the contents of `other`. -**Complexity:** -Linear in size. + **Complexity:** + Linear in size. -

+

-``` -static_vector(static_vector&& other); -``` +8. ``` + static_vector(static_vector&& other); + ``` -**Effects:** -Move constructor. -Constructs the container with the contents of `other` using move semantics. + **Effects:** + Move constructor. + Constructs the container with the contents of `other` using move semantics. -`other` is not guaranteed to be empty after the move. + `other` is not guaranteed to be empty after the move. -`other` is in a valid but unspecified state after the move. + `other` is in a valid but unspecified state after the move. -**Complexity:** -Linear in size. + **Complexity:** + Linear in size. -

+

### (destructor) -``` -~static_vector(); -``` +1. ``` + ~static_vector(); + ``` -**Effects:** -Destructs the container. The destructors of the elements are called and the used storage is deallocated. + **Effects:** + Destructs the container. The destructors of the elements are called and the used storage is deallocated. -**Complexity:** -Linear in size. + **Complexity:** + Linear in size. -

+

### assign -``` -void assign(size_type n, const T& value); -``` - -**Preconditions:** -`n <= capacity()` - -**Effects:** -Replaces the contents of the container with `n` copies of value `value`. +1. ``` + void assign(size_type n, const T& value); + ``` -**Note:** -The behavior is undefined if preconditions are not satisfied. + **Preconditions:** + `n <= capacity()` -**Complexity:** -Linear in size. + **Effects:** + Replaces the contents of the container with `n` copies of value `value`. -

+ **Complexity:** + Linear in size. +

-``` -template -void assign(InputIt first, InputIt last); -``` -**Preconditions:** -`std::distance(first, last) <= capacity()` +2. ``` + template + void assign(InputIt first, InputIt last); + ``` -**Effects:** -Replaces the contents of the container with the contents of the range `[first, last)`. + **Preconditions:** + `std::distance(first, last) <= capacity()` -**Note:** -This overload participates in overload resolution only if `InputIt` satisfies requirements of [*LegacyInputIterator*](https://en.cppreference.com/w/cpp/named_req/InputIterator). + **Effects:** + Replaces the contents of the container with the contents of the range `[first, last)`. -**Note:** -The behavior is undefined if preconditions are not satisfied. + **Note:** + This overload participates in overload resolution only if `InputIt` satisfies requirements of [*LegacyInputIterator*](https://en.cppreference.com/w/cpp/named_req/InputIterator). -**Note:** -The behavior is undefined if either `first` or `last` is an iterator into `*this`. + **Note:** + The behavior is undefined if either `first` or `last` is an iterator into `*this`. -**Complexity:** -Linear in size. + **Complexity:** + Linear in size. -

+

-``` -void assign(std::initializer_list ilist); -``` - -**Preconditions:** -`ilist.size() <= capacity()` +3. ``` + void assign(std::initializer_list ilist); + ``` -**Effects:** -Replaces the contents of the container with the contents of the initializer list `ilist`. + **Preconditions:** + `ilist.size() <= capacity()` -**Note:** -The behavior is undefined if preconditions are not satisfied. + **Effects:** + Replaces the contents of the container with the contents of the initializer list `ilist`. -**Complexity:** -Linear in size. + **Complexity:** + Linear in size. -

+

### operator= -``` -static_vector& operator=(const static_vector& other); -``` +1. ``` + static_vector& operator=(const static_vector& other); + ``` -**Effects:** -Copy assignment operator. -Replaces the contents with a copy of the contents of `other`. + **Effects:** + Copy assignment operator. + Replaces the contents with a copy of the contents of `other`. -**Returns:** -`*this()`. + **Returns:** + `*this()`. -**Complexity:** -Linear in size. + **Complexity:** + Linear in size. -

+

-``` -static_vector& operator=(static_vector&& other); -``` - -**Effects:** -Move assignment operator. -Replaces the contents with those of `other` using move semantics. +2. ``` + static_vector& operator=(static_vector&& other); + ``` -`other` is not guaranteed to be empty after the move. + **Effects:** + Move assignment operator. + Replaces the contents with those of `other` using move semantics. -`other` is in a valid but unspecified state after the move. + `other` is not guaranteed to be empty after the move. -**Returns:** -`*this()`. + `other` is in a valid but unspecified state after the move. -**Complexity:** -Linear in size. + **Returns:** + `*this()`. -

+ **Complexity:** + Linear in size. +

-``` -static_vector& operator=(std::initializer_list ilist); -``` -**Preconditions:** -`ilist.size() <= capacity()` +3. ``` + static_vector& operator=(std::initializer_list ilist); + ``` -**Effects:** -Replaces the contents with those identified by initializer list `ilist`. + **Preconditions:** + `ilist.size() <= capacity()` -**Note:** -The behavior is undefined if preconditions are not satisfied. + **Effects:** + Replaces the contents with those identified by initializer list `ilist`. -**Returns:** -`*this()`. + **Returns:** + `*this()`. -**Complexity:** -Linear in size. + **Complexity:** + Linear in size. -

+

### begin, cbegin -``` -iterator begin() noexcept; -``` -``` -const_iterator begin() const noexcept; -``` -``` -const_iterator cbegin() const noexcept; -``` - -**Effects:** -Returns an iterator to the first element of the container. +1. ``` + iterator begin() noexcept; + ``` +2. ``` + const_iterator begin() const noexcept; + ``` +3. ``` + const_iterator cbegin() const noexcept; + ``` -If the container is empty, the returned iterator will be equal to `end()`. + **Effects:** + Returns an iterator to the first element of the container. + If the container is empty, the returned iterator will be equal to `end()`. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

### end, cend -``` -iterator end() noexcept; -``` -``` -const_iterator end() const noexcept; -``` -``` -const_iterator cend() const noexcept; -``` - -**Effects:** -Returns an iterator to the element following the last element of the container. +1. ``` + iterator end() noexcept; + ``` +2. ``` + const_iterator end() const noexcept; + ``` +3. ``` + const_iterator cend() const noexcept; + ``` -This element acts as a placeholder; attempting to access it results in undefined behavior. + **Effects:** + Returns an iterator to the element following the last element of the container. + This element acts as a placeholder; attempting to access it results in undefined behavior. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

### rbegin, crbegin -``` -reverse_iterator rbegin() noexcept; -``` -``` -const_reverse_iterator rbegin() const noexcept; -``` -``` -const_reverse_iterator crbegin() const noexcept; -``` +1. ``` + reverse_iterator rbegin() noexcept; + ``` +2. ``` + const_reverse_iterator rbegin() const noexcept; + ``` +3. ``` + const_reverse_iterator crbegin() const noexcept; + ``` -**Effects:** -Returns a reverse iterator to the first element of the reversed container. -It corresponds to the last element of the non-reversed container. -If the container is empty, the returned iterator is equal to `rend()`. + **Effects:** + Returns a reverse iterator to the first element of the reversed container. + It corresponds to the last element of the non-reversed container. + If the container is empty, the returned iterator is equal to `rend()`. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

### rend, crend -``` -reverse_iterator rend() noexcept; -``` -``` -const_reverse_iterator rend() const noexcept; -``` -``` -const_reverse_iterator crend() const noexcept; -``` +1. ``` + reverse_iterator rend() noexcept; + ``` +2. ``` + const_reverse_iterator rend() const noexcept; + ``` +3. ``` + const_reverse_iterator crend() const noexcept; + ``` -**Effects:** -Returns a reverse iterator to the element following the last element of the reversed container. -It corresponds to the element preceding the first element of the non-reversed container. -This element acts as a placeholder, attempting to access it results in undefined behavior. + **Effects:** + Returns a reverse iterator to the element following the last element of the reversed container. + It corresponds to the element preceding the first element of the non-reversed container. + This element acts as a placeholder, attempting to access it results in undefined behavior. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

### nth -``` -iterator nth(size_type pos) noexcept; -``` -``` -const_iterator nth(size_type pos) const noexcept; -``` +1. ``` + iterator nth(size_type pos) noexcept; + ``` +2. ``` + const_iterator nth(size_type pos) const noexcept; + ``` -**Preconditions:** -`pos <= size()` + **Preconditions:** + `pos <= size()` -**Effects:** -Returns an iterator to the element at position `pos`. -If `pos == size()`, the returned iterator is equal to `end()`. + **Effects:** + Returns an iterator to the element at position `pos`. -**Note:** -The behavior is undefined if preconditions are not satisfied. + If `pos == size()`, the returned iterator is equal to `end()`. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

### index_of -``` -size_type index_of(const_iterator pos) const noexcept; -``` - -**Preconditions:** -`cbegin() <= pos && pos <= cend()` +1. ``` + size_type index_of(const_iterator pos) const noexcept; + ``` -**Effects:** -Returns position of the element pointed by iterator `pos`, i.e. `std::distance(begin(), pos)`. + **Preconditions:** + `cbegin() <= pos && pos <= cend()` -If `pos == end()`, the returned value is equal to `size()`. + **Effects:** + Returns position of the element pointed by iterator `pos`, i.e. `std::distance(begin(), pos)`. -**Note:** -The behavior is undefined if preconditions are not satisfied. + If `pos == end()`, the returned value is equal to `size()`. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

### empty -``` -bool empty() const noexcept; -``` +1. ``` + bool empty() const noexcept; + ``` -**Effects:** -Returns `true` if the container has no elements, i.e. whether `begin() == end()`. + **Effects:** + Returns `true` if the container has no elements, i.e. whether `begin() == end()`. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

### full -``` -bool full() const noexcept; -``` +1. ``` + bool full() const noexcept; + ``` -**Effects:** -Returns `true` if the container is full, i.e. whether `size() == capacity()`. + **Effects:** + Returns `true` if the container is full, i.e. whether `size() == capacity()`. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

### size -``` -size_type size() const noexcept; -``` +1. ``` + size_type size() const noexcept; + ``` -**Effects:** -Returns the number of elements in the container, i.e. `std::distance(begin(), end())`. + **Effects:** + Returns the number of elements in the container, i.e. `std::distance(begin(), end())`. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

### max_size -``` -static constexpr size_type max_size() const noexcept; -``` +1. ``` + static constexpr size_type max_size() const noexcept; + ``` -**Effects:** -Returns the maximum number of elements the container is able to hold, i.e. returns `N`. + **Effects:** + Returns the maximum number of elements the container is able to hold, i.e. `N`. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

### capacity -``` -static constexpr size_type capacity() const noexcept; -``` +1. ``` + static constexpr size_type capacity() const noexcept; + ``` -**Effects:** -Returns the maximum number of elements the container is able to hold, i.e. returns `N`. + **Effects:** + Returns the maximum number of elements the container is able to hold, i.e. `N`. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

### available -``` -size_type available() const noexcept; -``` +1. ``` + size_type available() const noexcept; + ``` -**Effects:** -Returns the number of elements that can be inserted into the container, i.e. returns `capacity() - size()`. + **Effects:** + Returns the number of elements that can be inserted into the container, i.e. `capacity() - size()`. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

### at -``` -reference at(size_type pos); -``` -``` -const_reference at(size_type pos) const; -``` +1. ``` + reference at(size_type pos); + ``` +2. ``` + const_reference at(size_type pos) const; + ``` -**Effects:** -Returns a reference to the element at specified location `pos`, with bounds checking. + **Effects:** + Returns a reference to the element at specified location `pos`, with bounds checking. -**Complexity:** -Constant. + **Complexity:** + Constant. -**Exceptions:** -`std::out_of_range` if `pos >= size()`. + **Exceptions:** + `std::out_of_range` if `pos >= size()`. -

+

### operator[] -``` -reference operator[](size_type pos) noexcept; -``` -``` -const_reference operator[](size_type pos) const noexcept; -``` - -**Preconditions:** -`pos < size()` +1. ``` + reference operator[](size_type pos) noexcept; + ``` +2. ``` + const_reference operator[](size_type pos) const noexcept; + ``` -**Effects:** -Returns a reference to the element at specified location pos. No bounds checking is performed. + **Preconditions:** + `pos < size()` -**Note:** -The behavior is undefined if preconditions are not satisfied. + **Effects:** + Returns a reference to the element at specified location pos. No bounds checking is performed. -**Note:** -This operator never inserts a new element into the container. + **Note:** + This operator never inserts a new element into the container. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

### front -``` -reference front() noexcept; -``` -``` -const_reference front() const noexcept; -``` - -**Preconditions:** -`!empty()` +1. ``` + reference front() noexcept; + ``` +2. ``` + const_reference front() const noexcept; + ``` -**Effects:** -Returns a reference to the first element in the container. + **Preconditions:** + `!empty()` -**Note:** -The behavior is undefined if preconditions are not satisfied. + **Effects:** + Returns a reference to the first element in the container. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

### back -``` -reference back() noexcept; -``` -``` -const_reference back() const noexcept; -``` +1. ``` + reference back() noexcept; + ``` +2. ``` + const_reference back() const noexcept; + ``` -**Preconditions:** -`!empty()` + **Preconditions:** + `!empty()` -**Effects:** -Returns a reference to the last element in the container. + **Effects:** + Returns a reference to the last element in the container. -**Note:** -The behavior is undefined if preconditions are not satisfied. + **Complexity:** + Constant. -**Complexity:** -Constant. - -

+

### data -``` -T* data() noexcept; -``` -``` -const T* data() const noexcept; -``` +1. ``` + T* data() noexcept; + ``` +2. ``` + const T* data() const noexcept; + ``` -**Effects:** -Returns pointer to the underlying array serving as element storage. The pointer is such that range `[data(), data() + size())` is always a valid range, even if the container is empty. `data()` is not dereferenceable if the container is empty. + **Effects:** + Returns pointer to the underlying array serving as element storage. The pointer is such that range `[data(), data() + size())` is always a valid range, even if the container is empty. `data()` is not dereferenceable if the container is empty. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

### clear -``` -void clear() noexcept; -``` +1. ``` + void clear() noexcept; + ``` -**Effects:** -Erases all elements from the container. -After this call, `size()` returns zero. + **Effects:** + Erases all elements from the container. + After this call, `size()` returns zero. -**Complexity:** -Linear in `size()`. + **Complexity:** + Linear in `size()`. -

+

### emplace -``` -template -iterator emplace(const_iterator pos, Args&&... args); -``` - -**Preconditions:** -1. `!full()` -2. `cbegin() <= pos && pos <= cend()` +1. ``` + template + iterator emplace(const_iterator pos, Args&&... args); + ``` -**Effects:** -Inserts a new element into the container at position `pos`. + **Preconditions:** + 1. `!full()` + 2. `cbegin() <= pos && pos <= cend()` -New element is constructed as `value_type(std::forward(args)...)`. + **Effects:** + Inserts a new element into the container at position `pos`. -`args...` may directly or indirectly refer to a value in the container. + New element is constructed as `value_type(std::forward(args)...)`. -**Note:** -The behavior is undefined if preconditions are not satisfied. + `args...` may directly or indirectly refer to a value in the container. -**Returns:** -Iterator to the inserted element. + **Returns:** + Iterator to the inserted element. -**Complexity:** -Constant plus linear in `std::distance(pos, end())`. + **Complexity:** + Constant plus linear in `std::distance(pos, end())`. -

+

### insert -``` -iterator insert(const_iterator pos, const T& value); -``` - -**Preconditions:** -1. `!full()` -2. `cbegin() <= pos && pos <= cend()` +1. ``` + iterator insert(const_iterator pos, const T& value); + ``` -**Effects:** -Inserts copy of `value` at position `pos`. + **Preconditions:** + 1. `!full()` + 2. `cbegin() <= pos && pos <= cend()` -**Note:** -The behavior is undefined if preconditions are not satisfied. + **Effects:** + Inserts copy of `value` at position `pos`. -**Returns:** -Iterator to the inserted element. + **Returns:** + Iterator to the inserted element. -**Complexity:** -Constant plus linear in `std::distance(pos, end())`. + **Complexity:** + Constant plus linear in `std::distance(pos, end())`. -

+

-``` -iterator insert(const_iterator pos, T&& value); -``` - -**Preconditions:** -1. `!full()` -2. `cbegin() <= pos && pos <= cend()` +2. ``` + iterator insert(const_iterator pos, T&& value); + ``` -**Effects:** -Inserts `value` using move semantics at position `pos`. + **Preconditions:** + 1. `!full()` + 2. `cbegin() <= pos && pos <= cend()` -**Note:** -The behavior is undefined if preconditions are not satisfied. + **Effects:** + Inserts `value` using move semantics at position `pos`. -**Returns:** -Iterator to the inserted element. + **Returns:** + Iterator to the inserted element. -**Complexity:** -Constant plus linear in `std::distance(pos, end())`. + **Complexity:** + Constant plus linear in `std::distance(pos, end())`. -

+

-``` -iterator insert(const_iterator pos, size_type n, const T& value); -``` +3. ``` + iterator insert(const_iterator pos, size_type n, const T& value); + ``` -**Preconditions:** -1. `n <= available()` -2. `cbegin() <= pos && pos <= cend()` + **Preconditions:** + 1. `n <= available()` + 2. `cbegin() <= pos && pos <= cend()` -**Effects:** -Inserts `n` copies of `value` before position `pos`. + **Effects:** + Inserts `n` copies of `value` before position `pos`. -**Note:** -The behavior is undefined if preconditions are not satisfied. + **Returns:** + Iterator to the first element inserted, or `pos` if `n == 0`. -**Returns:** -Iterator to the first element inserted, or `pos` if `n == 0`. + **Complexity:** + Linear in `n` plus linear in `std::distance(pos, end())`. -**Complexity:** -Linear in `n` plus linear in `std::distance(pos, end())`. +

-

+4. ``` + template + iterator insert(const_iterator pos, InputIt first, InputIt last); + ``` -``` -template -iterator insert(const_iterator pos, InputIt first, InputIt last); -``` - -**Preconditions:** -1. `std::distance(first, last) <= available()` -2. `cbegin() <= pos && pos <= cend()` - -**Effects:** -Inserts elements from the range `[first, last)` before position `pos`. + **Preconditions:** + 1. `std::distance(first, last) <= available()` + 2. `cbegin() <= pos && pos <= cend()` -**Note:** -This overload participates in overload resolution only if `InputIt` satisfies requirements of [*LegacyInputIterator*](https://en.cppreference.com/w/cpp/named_req/InputIterator). + **Effects:** + Inserts elements from the range `[first, last)` before position `pos`. -**Note:** -The behavior is undefined if either `first` or `last` is an iterator into `*this`. + **Note:** + This overload participates in overload resolution only if `InputIt` satisfies requirements of [*LegacyInputIterator*](https://en.cppreference.com/w/cpp/named_req/InputIterator). -**Returns:** -Iterator to the first element inserted, or `pos` if `first == last`. + **Returns:** + Iterator to the first element inserted, or `pos` if `first == last`. -**Complexity:** -Linear in `std::distance(first, last)` plus linear in `std::distance(pos, end())`. + **Complexity:** + Linear in `std::distance(first, last)` plus linear in `std::distance(pos, end())`. -

+

-``` -iterator insert(const_iterator pos, std::initializer_list ilist); -``` - -**Preconditions:** -1. `ilist.size() <= available()` -2. `cbegin() <= pos && pos <= cend()` +5. ``` + iterator insert(const_iterator pos, std::initializer_list ilist); + ``` -**Effects:** -Inserts elements from initializer list `ilist` before position `pos`. + **Preconditions:** + 1. `ilist.size() <= available()` + 2. `cbegin() <= pos && pos <= cend()` -**Note:** -The behavior is undefined if preconditions are not satisfied. + **Effects:** + Inserts elements from initializer list `ilist` before position `pos`. -**Returns:** -Iterator to the first element inserted, or `pos` if `ilist` is empty. + **Returns:** + Iterator to the first element inserted, or `pos` if `ilist` is empty. -**Complexity:** -Linear in `ilist.size()` plus linear in `std::distance(pos, end())`. + **Complexity:** + Linear in `ilist.size()` plus linear in `std::distance(pos, end())`. -

+

### emplace_back -``` -template -reference emplace_back(Args&&... args); -``` - -**Preconditions:** -`!full()` +1. ``` + template + reference emplace_back(Args&&... args); + ``` -**Effects:** -Inserts a new element at the end of container. + **Preconditions:** + `!full()` -New element is constructed as `value_type(std::forward(args)...)`. + **Effects:** + Inserts a new element at the end of container. -**Note:** -The behavior is undefined if preconditions are not satisfied. + New element is constructed as `value_type(std::forward(args)...)`. -**Returns:** -Reference to the inserted element. + **Returns:** + Reference to the inserted element. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

### push_back -``` -void push_back(const T& value); -``` - -**Preconditions:** -`!full()` - -**Effects:** -Inserts copy of `value` at the end of container. +1. ``` + void push_back(const T& value); + ``` -**Note:** -The behavior is undefined if preconditions are not satisfied. + **Preconditions:** + `!full()` -**Complexity:** -Constant. + **Effects:** + Inserts copy of `value` at the end of container. -

+ **Complexity:** + Constant. +

-``` -void push_back(T&& value); -``` -**Preconditions:** -`!full()` +2. ``` + void push_back(T&& value); + ``` -**Effects:** -Inserts `value` using move semantics at the end of container. + **Preconditions:** + `!full()` -**Note:** -The behavior is undefined if preconditions are not satisfied. + **Effects:** + Inserts `value` using move semantics at the end of container. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

### pop_back -``` -void pop_back(); -``` - -**Preconditions:** -`!empty()` +1. ``` + void pop_back(); + ``` -**Effects:** -Removes the last element of the container. + **Preconditions:** + `!empty()` -**Note:** -The behavior is undefined if preconditions are not satisfied. + **Effects:** + Removes the last element of the container. -**Complexity:** -Constant. + **Complexity:** + Constant. -

+

### erase -``` -iterator erase(const_iterator pos); -``` - -**Preconditions:** -`cbegin() <= pos && pos < cend()` +1. ``` + iterator erase(const_iterator pos); + ``` -**Effects:** -Removes the element at `pos`. + **Preconditions:** + `cbegin() <= pos && pos < cend()` -**Note:** -The behavior is undefined if preconditions are not satisfied. + **Effects:** + Removes the element at `pos`. -**Returns:** -Iterator following the last removed element. + **Returns:** + Iterator following the last removed element. -If `pos` refers to the last element, then the `end()` iterator is returned. + If `pos` refers to the last element, then the `end()` iterator is returned. -

+

-``` -iterator erase(const_iterator first, const_iterator last); -``` - -**Preconditions:** -`cbegin() <= first && first <= last && last <= cend()` +2. ``` + iterator erase(const_iterator first, const_iterator last); + ``` -**Effects:** -Removes the elements in the range `[first, last)`. + **Preconditions:** + `cbegin() <= first && first <= last && last <= cend()` -**Note:** -The behavior is undefined if preconditions are not satisfied. + **Effects:** + Removes the elements in the range `[first, last)`. -**Returns:** -Iterator following the last removed element. + **Returns:** + Iterator following the last removed element. -If `last == end()` prior to removal, then the updated `end()` iterator is returned. + If `last == end()` prior to removal, then the updated `end()` iterator is returned. -If `[first, last)` is an empty range, then `last` is returned. + If `[first, last)` is an empty range, then `last` is returned. -

+

### resize -``` -void resize(size_type n); -``` - -**Preconditions:** -`n <= capacity()` - -**Effects:** -Resizes the container to contain `n` elements. - -1. If the `n > size()`, additional elements are inserted at the end of container. Additional elements are [value-initialized](https://en.cppreference.com/w/cpp/language/value_initialization). -2. If the `n < size()`, the last `size() - n` elements are removed. +1. ``` + void resize(size_type n); + ``` -**Note:** -The behavior is undefined if preconditions are not satisfied. + **Preconditions:** + `n <= capacity()` -**Complexity:** -Linear in difference between `size()` and `n`. + **Effects:** + Resizes the container to contain `n` elements. -

+ 1. If the `n > size()`, additional elements are inserted at the end of container. Additional elements are [value-initialized](https://en.cppreference.com/w/cpp/language/value_initialization). + 2. If the `n < size()`, the last `size() - n` elements are removed. + **Complexity:** + Linear in difference between `size()` and `n`. +

-``` -void resize(size_type n, sfl::default_init_t); -``` -**Preconditions:** -`n <= capacity()` -**Effects:** -Resizes the container to contain `n` elements. +2. ``` + void resize(size_type n, sfl::default_init_t); + ``` -1. If the `n > size()`, additional elements are inserted at the end of container. Additional elements are [default-initialized](https://en.cppreference.com/w/cpp/language/default_initialization). -2. If the `n < size()`, the last `size() - n` elements are removed. + **Preconditions:** + `n <= capacity()` -**Note:** -The behavior is undefined if preconditions are not satisfied. + **Effects:** + Resizes the container to contain `n` elements. -**Complexity:** -Linear in difference between `size()` and `n`. + 1. If the `n > size()`, additional elements are inserted at the end of container. Additional elements are [default-initialized](https://en.cppreference.com/w/cpp/language/default_initialization). + 2. If the `n < size()`, the last `size() - n` elements are removed. -

+ **Complexity:** + Linear in difference between `size()` and `n`. +

-``` -void resize(size_type n, const T& value); -``` -**Preconditions:** -`n <= capacity()` +3. ``` + void resize(size_type n, const T& value); + ``` -**Effects:** -Resizes the container to contain `n` elements. + **Preconditions:** + `n <= capacity()` -1. If the `n > size()`, additional copies of `value` are inserted at the end of container. -2. If the `n < size()`, the last `size() - n` elements are removed. + **Effects:** + Resizes the container to contain `n` elements. -**Note:** -The behavior is undefined if preconditions are not satisfied. + 1. If the `n > size()`, additional copies of `value` are inserted at the end of container. + 2. If the `n < size()`, the last `size() - n` elements are removed. -**Complexity:** -Linear in difference between `size()` and `n`. + **Complexity:** + Linear in difference between `size()` and `n`. -

+

### swap -``` -void swap(static_vector& other); -``` +1. ``` + void swap(static_vector& other); + ``` -**Effects:** -Exchanges the contents of the container with those of `other`. + **Effects:** + Exchanges the contents of the container with those of `other`. -**Complexity:** -Linear in size. + **Complexity:** + Linear in size. -

+

@@ -1203,217 +1115,217 @@ Linear in size. ### operator== -``` -template -bool operator== -( - const static_vector& x, - const static_vector& y -); -``` +1. ``` + template + bool operator== + ( + const static_vector& x, + const static_vector& y + ); + ``` -**Effects:** -Checks if the contents of `x` and `y` are equal. + **Effects:** + Checks if the contents of `x` and `y` are equal. -The contents of `x` and `y` are equal if the following conditions hold: -* `x.size() == y.size()` -* Each element in `x` compares equal with the element in `y` at the same position. + The contents of `x` and `y` are equal if the following conditions hold: + * `x.size() == y.size()` + * Each element in `x` compares equal with the element in `y` at the same position. -**Returns:** -`true` if the contents of the `x` and `y` are equal, `false` otherwise. + **Returns:** + `true` if the contents of the `x` and `y` are equal, `false` otherwise. -**Complexity:** -Constant if `x` and `y` are of different size, otherwise linear in the size of the container. + **Complexity:** + Constant if `x` and `y` are of different size, otherwise linear in the size of the container. -

+

### operator!= -``` -template -bool operator!= -( - const static_vector& x, - const static_vector& y -); -``` +1. ``` + template + bool operator!= + ( + const static_vector& x, + const static_vector& y + ); + ``` -**Effects:** -Checks if the contents of `x` and `y` are equal. + **Effects:** + Checks if the contents of `x` and `y` are equal. -For details see `operator==`. + For details see `operator==`. -**Returns:** -`true` if the contents of the `x` and `y` are not equal, `false` otherwise. + **Returns:** + `true` if the contents of the `x` and `y` are not equal, `false` otherwise. -**Complexity:** -Constant if `x` and `y` are of different size, otherwise linear in the size of the container. + **Complexity:** + Constant if `x` and `y` are of different size, otherwise linear in the size of the container. -

+

### operator< -``` -template -bool operator< -( - const static_vector& x, - const static_vector& y -); -``` +1. ``` + template + bool operator< + ( + const static_vector& x, + const static_vector& y + ); + ``` -**Effects:** -Compares the contents of `x` and `y` lexicographically. -The comparison is performed by a function `std::lexicographical_compare`. + **Effects:** + Compares the contents of `x` and `y` lexicographically. + The comparison is performed by a function `std::lexicographical_compare`. -**Returns:** -`true` if the contents of the `x` are lexicographically less than the contents of `y`, `false` otherwise. + **Returns:** + `true` if the contents of the `x` are lexicographically less than the contents of `y`, `false` otherwise. -**Complexity:** -Linear in the size of the container. + **Complexity:** + Linear in the size of the container. -

+

### operator> -``` -template -bool operator> -( - const static_vector& x, - const static_vector& y -); -``` +1. ``` + template + bool operator> + ( + const static_vector& x, + const static_vector& y + ); + ``` -**Effects:** -Compares the contents of `x` and `y` lexicographically. -The comparison is performed by a function `std::lexicographical_compare`. + **Effects:** + Compares the contents of `x` and `y` lexicographically. + The comparison is performed by a function `std::lexicographical_compare`. -**Returns:** -`true` if the contents of the `x` are lexicographically greater than the contents of `y`, `false` otherwise. + **Returns:** + `true` if the contents of the `x` are lexicographically greater than the contents of `y`, `false` otherwise. -**Complexity:** -Linear in the size of the container. + **Complexity:** + Linear in the size of the container. -

+

### operator<= -``` -template -bool operator<= -( - const static_vector& x, - const static_vector& y -); -``` +1. ``` + template + bool operator<= + ( + const static_vector& x, + const static_vector& y + ); + ``` -**Effects:** -Compares the contents of `x` and `y` lexicographically. -The comparison is performed by a function `std::lexicographical_compare`. + **Effects:** + Compares the contents of `x` and `y` lexicographically. + The comparison is performed by a function `std::lexicographical_compare`. -**Returns:** -`true` if the contents of the `x` are lexicographically less than or equal to the contents of `y`, `false` otherwise. + **Returns:** + `true` if the contents of the `x` are lexicographically less than or equal to the contents of `y`, `false` otherwise. -**Complexity:** -Linear in the size of the container. + **Complexity:** + Linear in the size of the container. -

+

### operator>= -``` -template -bool operator>= -( - const static_vector& x, - const static_vector& y -); -``` +1. ``` + template + bool operator>= + ( + const static_vector& x, + const static_vector& y + ); + ``` -**Effects:** -Compares the contents of `x` and `y` lexicographically. -The comparison is performed by a function `std::lexicographical_compare`. + **Effects:** + Compares the contents of `x` and `y` lexicographically. + The comparison is performed by a function `std::lexicographical_compare`. -**Returns:** -`true` if the contents of the `x` are lexicographically greater than or equal to the contents of `y`, `false` otherwise. + **Returns:** + `true` if the contents of the `x` are lexicographically greater than or equal to the contents of `y`, `false` otherwise. -**Complexity:** -Linear in the size of the container. + **Complexity:** + Linear in the size of the container. -

+

### swap -``` -template -void swap -( - static_vector& x, - static_vector& y -); -``` +1. ``` + template + void swap + ( + static_vector& x, + static_vector& y + ); + ``` -**Effects:** -Swaps the contents of `x` and `y`. Calls `x.swap(y)`. + **Effects:** + Swaps the contents of `x` and `y`. Calls `x.swap(y)`. -

+

### erase -``` -template -typename static_vector::size_type - erase(static_vector& c, const U& value); -``` +1. ``` + template + typename static_vector::size_type + erase(static_vector& c, const U& value); + ``` -**Effects:** -Erases all elements that compare equal to `value` from the container. + **Effects:** + Erases all elements that compare equal to `value` from the container. -**Returns:** -The number of erased elements. + **Returns:** + The number of erased elements. -**Complexity:** -Linear. + **Complexity:** + Linear. -

+

### erase_if -``` -template -typename static_vector::size_type - erase_if(static_vector& c, Predicate pred); -``` +1. ``` + template + typename static_vector::size_type + erase_if(static_vector& c, Predicate pred); + ``` -**Effects:** -Erases all elements that satisfy the predicate `pred` from the container. + **Effects:** + Erases all elements that satisfy the predicate `pred` from the container. -`pred` is unary predicate which returns `true` if the element should be removed. + `pred` is unary predicate which returns `true` if the element should be removed. -**Returns:** -The number of erased elements. + **Returns:** + The number of erased elements. -**Complexity:** -Linear. + **Complexity:** + Linear. -

+