Movatterモバイル変換


[0]ホーム

URL:


cppreference.com
Namespaces
Variants
    Actions

      std::flat_multiset<Key,Compare,KeyContainer>::insert

      From cppreference.com
      <cpp‎ |container‎ |flat multiset
       
       
       
      std::flat_multiset
      Member types
      Member functions
      Non-member functions
      Helper classes
      Tags
      Deduction guides
       
      iterator insert(const value_type& value)
      (1)(since C++23)
      iterator insert( value_type&& value);
      (2)(since C++23)
      iterator insert( const_iterator pos,const value_type& value);
      (3)(since C++23)
      iterator insert( const_iterator pos, value_type&& value);
      (4)(since C++23)
      template<class InputIt>
      void insert( InputIt first, InputIt last);
      (5)(since C++23)
      template<class InputIt>
      void insert(std::sorted_equivalent_t, InputIt first, InputIt last);
      (6)(since C++23)
      void insert(std::initializer_list<key_type> ilist);
      (7)(since C++23)
      void insert(std::sorted_equivalent_t s,std::initializer_list<key_type> ilist);
      (8)(since C++23)

      Inserts element(s) into the container. The order of the remaining equivalent elements is preserved.

      1) Insertsvalue. If the container has elements with equivalent key, inserts at the upper bound of that range. Equivalent toreturn emplace(value);.
      2) Insertsvalue. If the container has elements with equivalent key, inserts at the upper bound of that range. Equivalent toreturn emplace(std::move(value));.
      3) Insertsvalue in the position as close as possible to the position just prior topos. Equivalent toreturn emplace_hint(pos, value);.
      4) Insertsvalue in the position as close as possible to the position just prior topos. Equivalent toreturn emplace_hint(pos, std::move(value));.
      5) Inserts elements from range[firstlast) as if performing the following operations sequentially:
      1. Adds elements toc as if byc.insert(c.end(), first, last);.
      2. Sorts the range of newly inserted elements with respect tocompare.
      3. Merges the resulting sorted range and the sorted range of pre-existing elements into a single sorted range.
      May allocate memory during the in-place merge stage.
      6) Inserts elements from range[firstlast). Equivalent toinsert(first, last);.
      7) Inserts elements from initializer listilist. Equivalent toinsert(ilist.begin(), ilist.end());.
      8) Inserts elements from initializer listilist. Equivalent toinsert(s, ilist.begin(), ilist.end());.
      Information on iterator invalidation is copied fromhere

      Contents

      [edit]Parameters

      pos - iterator to the position before which the new element will be inserted
      value - element value to insert
      first, last - the pair of iterators defining the sourcerange of elements to insert
      ilist - initializer list to insert the values from
      s - a disambiguation tag indicating that the input sequence is sorted (with respect tokey_compare)
      Type requirements
      -
      InputIt must meet the requirements ofLegacyInputIterator.

      [edit]Return value

      1-4) An iterator to the inserted element.
      5-8) (none)

      [edit]Exceptions

      1-4) Depends on underlying container.
      5-8) No exception safety guarantee.
      This section is incomplete
      Reason: exception guarantees 1..8

      [edit]Complexity

      1-4) Linear.
      5)N+ M·log(M), whereNN is thesize() before the operation andM isstd::distance(first, last).
      6) Linear.
      7)N+ M·log(M), whereNN is thesize() before the operation andM isilist.size().
      8) Linear.
      This section is incomplete
      Reason: recheck the complexity: 1-4, 8

      [edit]Example

      This section is incomplete
      Reason: no example

      [edit]See also

      constructs element in-place
      (public member function)[edit]
      constructs elements in-place using a hint
      (public member function)[edit]
      creates astd::insert_iterator of type inferred from the argument
      (function template)[edit]
      Retrieved from "https://en.cppreference.com/mwiki/index.php?title=cpp/container/flat_multiset/insert&oldid=180885"

      [8]ページ先頭

      ©2009-2025 Movatter.jp