⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 set_of.qbk

📁 Boost provides free peer-reviewed portable C++ source libraries. We emphasize libraries that work
💻 QBK
📖 第 1 页 / 共 3 页
字号:
operation (except possibly mod), then the element pointed to by position is erased.][endsect][section Set operations]`[multi]set_of` views provide the full lookup functionality required by__SGI_SORTED_ASSOCIATIVE_CONTAINER__ and __SGI_UNIQUE_ASSOCIATIVE_CONTAINER__,namely `find`, `count`, `lower_bound`, `upper_bound` and `equal_range`.Additionally, these member functions are templatized to allow for non-standardarguments, so extending the types of search operations allowed.[/The kinds of arguments permissible when invoking the lookup member functionsare defined by the following concept.Consider a __SGI_STRICT_WEAK_ORDERING__ `Compare` over values of type `Key`. A pair oftypes `(CompatibleKey, CompatibleCompare)` is said to be a ['compatible extension]of Compare if* `CompatibleCompare` is a __SGI_BINARY_PREDICATE__ over `(Key, CompatibleKey)`,* `CompatibleCompare` is a __SGI_BINARY_PREDICATE__ over `(CompatibleKey, Key)`,* if `c_comp(ck,k1)` then `!c_comp(k1,ck)`,* if `!c_comp(ck,k1)` and `!comp(k1,k2)` then `!c_comp(ck,k2)`,* if `!c_comp(k1,ck)` and `!comp(k2,k1)` then `!c_comp(k2,ck)`,for every `c_comp` of type `CompatibleCompare`, `comp` of type `Compare`, `ck` of type`CompatibleKey` and `k1`, `k2` of type `Key`.]A type `CompatibleKey` is said to be a ['compatible key] of `Compare`if `(CompatibleKey, Compare)` is a compatible extension of `Compare`. This impliesthat `Compare`, as well as being a strict weak ordering, accepts arguments of type`CompatibleKey`, which usually means it has several overloads of `operator()`.[/In the context of a compatible extension or a compatible key, the expressions"equivalent", "less than" and "greater than" take on their obvious interpretations.][#reference_set_of_find_key]    template< class CompatibleKey >    iterator find(const CompatibleKey & x);    template< class CompatibleKey >    const_iterator find(const CompatibleKey & x) const;* [*Requires: ] `CompatibleKey` is a compatible key of `key_compare`.* [*Effects:] Returns a pointer to an element whose key is equivalent to `x`, or`end()` if such an element does not exist.* [*Complexity:] O(log(n)).[/    template< class CompatibleKey, class CompatibleCompare >    iterator find(const CompatibleKey & x,                  const CompatibleCompare & comp);    template< class CompatibleKey, class CompatibleCompare >    const_iterator find(const CompatibleKey & x,                        const CompatibleCompare & comp) const;* [*Requires: ] `(CompatibleKey, CompatibleCompare)` is a compatible extension of`key_compare.`* [*Effects:] Returns a pointer to an element whose key isequivalent to `x`, or `end()` if such an element does not exist.* [*Complexity:] O(log(n)).][#reference_set_of_count_key]    template< class CompatibleKey >    size_type count(const key_type & x) const;* [*Requires: ] `CompatibleKey` is a compatible key of `key_compare`.* [*Effects:] Returns the number of elements with key equivalent to `x`.* [*Complexity:] O(log(n) + count(x)).[/    template< class CompatibleKey, class CompatibleCompare >    size_type count(const CompatibleKey & x,                    const CompatibleCompare & comp) const;* [*Requires: ] `(CompatibleKey, CompatibleCompare)` is a compatible extension of`key_compare.`* [*Effects:] Returns the number of elements with key equivalent to `x`.* [*Complexity:] O(log(n) + count(x)).][#reference_set_of_lower_bound_key]    template< class CompatibleKey >    iterator lower_bound(const key_type & x);    template< class CompatibleKey >    const_iterator lower_bound(const key_type & x) const;* [*Requires: ] `CompatibleKey` is a compatible key of `key_compare`.* [*Effects:] Returns an iterator pointing to the first element with key notless than `x`, or `end()` if such an element does not exist.* [*Complexity:] O(log(n)).[#reference_set_of_upper_bound_key]    template< class CompatibleKey >    iterator upper_bound(const key_type & x);    template< class CompatibleKey >    const_iterator upper_bound(const key_type & x) const;* [*Requires: ] `CompatibleKey` is a compatible key of `key_compare`.* [*Effects:] Returns an iterator pointing to the first element with key greaterthan `x`, or `end()` if such an element does not exist.* [*Complexity:] O(log(n)).[#reference_set_of_equal_range_key]    template< class CompatibleKey >    std::pair<iterator,iterator>        equal_range(const key_type & x);    template< class CompatibleKey >    std::pair<const_iterator,const_iterator>         equal_range(const key_type & x) const;* [*Requires: ] `CompatibleKey` is a compatible key of `key_compare`.* [*Effects:] Equivalent to `make_pair(lower_bound(x),upper_bound(x))`.* [*Complexity:] O(log(n)).[endsect][section Range operations]The member function range is not defined for sorted associativecontainers, but `[multi]set_of` map views provide it as a convenient utility.A range or interval is defined by two conditions for the lower and upperbounds, which are modelled after the following concepts.Consider a __SGI_STRICT_WEAK_ORDERING__ `Compare` over values of type Key.A type `LowerBounder` is said to be a lower bounder of `Compare` if* `LowerBounder` is a `Predicate` over `Key`,* if `lower(k1)` and `!comp(k2,k1)` then `lower(k2)`,for every `lower` of type `LowerBounder`, `comp` of type `Compare`, and `k1`, `k2`of type `Key`.Similarly, an upper bounder is a type `UpperBounder` such that* `UpperBounder` is a `Predicate` over `Key`,* if `upper(k1)` and `!comp(k1,k2)` then `upper(k2)`,for every `upper` of type `UpperBounder`, `comp` of type `Compare`, and `k1`, `k2`of type `Key`.[#reference_set_of_range_lower_upper]    template< class LowerBounder, class UpperBounder>    std::pair<const_iterator,const_iterator> range(        LowerBounder lower, UpperBounder upper) const;* [*Requires: ] `LowerBounder` and `UpperBounder` are a lower and upper bounder of`key_compare`, respectively.* [*Effects:] Returns a pair of iterators pointing tothe beginning and one past the end of the subsequence of elements satisfyinglower and upper simultaneously. If no such elements exist, the iterators bothpoint to the first element satisfying lower, or else are equal to `end()` if thislatter element does not exist.* [*Complexity:] O(log(n)).* [*Variants:] In place of lower or upper (or both), the singular value`boost::bimap::unbounded` can be provided. This acts as a predicate whichall values of type `key_type` satisfy.* [*Note:] Only provided for map views.[endsect][section at(), info_at() and operator\[\] - set_of only][#reference_set_of_at_key_const]    template< class CompatibleKey >    const data_type & at(const CompatibleKey & k) const;* [*Requires: ] `CompatibleKey` is a compatible key of `key_compare`.* [*Effects:] Returns the `data_type` reference that is associated with `k`, orthrows `std::out_of_range` if such key does not exist.* [*Complexity:] O(log(n)).* [*Note:] Only provided when `set_of` is used.The symmetry of bimap imposes some constraints on `operator[]` and the non constant version of at() that are not found in `std::maps`.Tey are only provided if the other collection type is mutable(`list_of`, `vector_of` and `unconstrained_set_of`).[#reference_set_of_operator_bracket_key]    template< class CompatibleKey >    data_type & operator[](const CompatibleKey & k);* [*Requires: ] `CompatibleKey` is a compatible key of `key_compare`.* [*Effects: ] `return insert(value_type(k,data_type()))->second;`* [*Complexity:] O(log(n)).* [*Note:] Only provided when `set_of` is used and the other collectiontype is mutable.[#reference_set_of_at_key]    template< class CompatibleKey >    data_type & at(const CompatibleKey & k);* [*Requires: ] `CompatibleKey` is a compatible key of `key_compare`.* [*Effects: ] Returns the `data_type` reference that is associated with `k`, orthrows `std::out_of_range` if such key does not exist.* [*Complexity:] O(log(n)).* [*Note:] Only provided when `set_of` is used and the other collectiontype is mutable.[/The symmetry of bimap imposes some constraints on `operator[]` that arenot found in `std::maps`. If other views are unique,`bimap::duplicate_value` is thrown whenever an assignment is attempted toa value that is already a key in these views. As for`bimap::value_not_found`, this exception is thrown while trying to accessa non-existent key: this behaviour differs from that of `std::map`, whichautomatically assigns a default value to non-existent keys referred toby `operator[]`.    const data_type & operator[](const typename key_type & k) const;* [*Effects:] Returns the `data_type` reference that is associated with `k`, orthrows `bimap::value_not_found` if such an element does not exist.* [*Complexity:] O(log(n)).    ``['-unspecified data_type proxy-]`` operator[](const typename key_type & k);* [*Effects:] Returns a proxy to a `data_type` associated with `k` and thebimap. The proxy behaves as a reference to the `data_type` object. If thisproxy is read and `k` was not in the bimap, the bimap::value_not_found isthrown. If it is written then `bimap::duplicate_value` is thrown if theassignment is not allowed by one of the other views of the `bimap`.* [link set_of_complexity_signature[*Complexity:]] If the assignment operator of the proxy is not used, thenthe order is O(log(n)). If it is used, the order is O(I(n)) if `k` was notin the bimap and O(R(n)) if it existed in the bimap.][#reference_set_of_info_at_key]    template< class CompatibleKey >    info_type & info_at(const CompatibleKey & k);    template< class CompatibleKey >    const info_type & info_at(const CompatibleKey & k) const;* [*Requires: ] `CompatibleKey` is a compatible key of `key_compare`.* [*Effects:] Returns the `info_type` reference that is associated with `k`, orthrows `std::out_of_range` if such key does not exist.* [*Complexity:] O(log(n)).* [*Note:] Only provided when `set_of` and `info_hook` are used[endsect][section Serialization]Views cannot be serialized on their own, but only as part of the `bimap`into which they are embedded. In describing the additional preconditions and guaranteesassociated to `[multi]set_of` views with respect to serialization of their embedding containers,we use the concepts defined in the `bimap` serialization section.[blurb  [*Operation:] saving of a `bimap` m to an output archive (XML archive) ar.]* [*Requires:] No additional requirements to those imposed by the container.[blurb [*Operation:] loading of a `bimap` m' from an input archive (XML archive) ar.]* [*Requires:] In addition to the general requirements, `value_comp()` must beserialization-compatible with `m.get<i>().value_comp()`, where i is the positionof the ordered view in the container.* [*Postconditions:] On successful loading, each of the elements of `[begin(), end())`is a restored copy of the corresponding element in `[m.get<i>().begin(), m.get<i>().end())`.[blurb [*Operation:] saving of an iterator or `const_iterator` it to an output archive(XML archive) ar.]* [*Requires: ] `it` is a valid iterator of the view. The associated `bimap`has been previously saved.[blurb [*Operation:] loading of an `iterator` or `const_iterator` `it`' from an input archive (XML archive) ar.]* [*Postconditions:] On successful loading, if it was dereferenceable then `*it`' is therestored copy of `*it`, otherwise `it`'` == end()`.* [*Note:] It is allowed that it be a `const_iterator` and the restored `it`' an iterator,or viceversa.[endsect][endsect][endsect]

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -