Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use the insert of Clear11 container

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/01 Report--

This article introduces the knowledge of "how to use the insert of Clear11 container". Many people will encounter such a dilemma in the operation of actual cases, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

From Central98 to Clear11

The insert method declaration in Clipper 98

Iterator insert (iterator position

Const value_type& val); void insert (iterator position

Size_type n

Const value_type& val); template

Void insert (iterator position

InputIterator first

InputIterator last)

The insert method in Clipper 11

Iterator insert (const_iterator position

Const value_type& val); iterator insert (const_iterator position

Size_type n

Const value_type& val); template

Iterator insert (const_iterator position

InputIterator first

InputIterator last); iterator insert (const_iterator position

Value_type&& val); iterator insert (const_iterator position

Initializer_list il)

Detail comparison

Add a single element

Iterator insert (const_iterator position

Const value_type& val)

The only change is that the parameter type of position has changed, with the same functionality but increased support for const_iterator. This change applies to all insert methods, which are not explained below.

Populate multiple elements

Iterator insert (const_iterator position

Size_type n

Const value_type& val)

This method can populate n val at a specified location. In addition to the parameters, the return value of the method changes from void to iterator, returning the location of the last added element. With this return value, it is convenient to populate the element in the same place. For example, the following code:

Std::list demo {1, 2, 3, 4, 5, 6}

Auto position = std::find (demo.begin (), demo.end (), 3)

For (int I = 0; I < 5; + + I) {

Position = demo.insert (position, 2, I)

}

For (int var: demo) {

Std::cout

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report