Prefer member functions to algorithms with the same names
来源:互联网 发布:品茗BIM软件 编辑:程序博客网 时间:2024/04/30 22:19
有些容器拥有和STL算法同名的成员函数。关联容器提供了count、find、lower_bound、upper_bound和equal_range,而list提供了remove、remove_if、unique、sort、merge和reverse。大多数情况下,你应该用成员函数代替算法。这样做有两个理由。首先,成员函数更快。其次,比起算法来,它们与容器结合得更好(尤其是关联容器)。那是因为同名的算法和成员函数通常并不是是一样的。
Some containers have member functions with the same names as STL algorithms. The associative containers offer count, find, lower_bound. upper_bound, and equal_range, while list offers remove, remove_if, unique, sort, merge, and reverse. Most of the time, you'll want to use the member functions instead of the algorithms. There are two reasons for this. First, the member functions are faster. Second, they integrate better with the containers (especially the associative containers) than do the algorithms. That's because algorithms and member functions that share the same name typically do not do exactly the same thing.
Some containers have member functions which have the same name with STL algorithms. Associated containers provide count, find, lower_bound. upper_bound, and equal_range, while list provides remove, remove_if, unique, sort, merge, and reverse. In most cases, you should use member functions instead of algorithms. There are two reasons for doing this. For one thing, member functions are faster. For another, comparing to algorithms, they are better-combined with contianers(especially associated containers). Algorithms and member functions with the same name are usually not the same.
- Prefer member functions to algorithms with the same names
- Effective C++ 23. Prefer non-member non-friend functions to member functions
- Item 5. Prefer range member functions to their single-element counterparts.
- Two output file names resolved to the same output path
- subroutine has the same name with build_in functions
- the same as,the same to,the same with的用法区别
- Prefer to make base class virtual functions private
- Item11 Prefer deleted functions to private undefined ones
- multiple lua files with same-named functions
- Unity打包安卓 Found plugins with same names x86_64
- To deal with files in the same file folder with .exe uder UNICODE of VC08
- A slave with the same server_uuid as this slave has connected to the master
- 混沌 IN C++::Pointers-to-Member functions 解迷
- Ambiguous reference to member 'dataTask(with:completionHandler:)'
- How to Backup Different Release Databases with the Same Catalog Database
- Unable to install this application because an application with the same identity is already installe
- Ch8.6: write a method to paint-fill a closed ring with the same color
- Unable to start MySQL service. Another MySQL daemon is already running with the same UNIX socket
- 个税起征点升高----节省了多少?
- 官方 NSIS 插件全集简单介绍
- 个性化信息服务综述(一)
- 个性化信息服务综述(二)
- 精确计算-整数相除
- Prefer member functions to algorithms with the same names
- 弹出窗口总结
- 老婆使用说明书
- datagrid下下拉框1
- 老婆快要考试了
- SQL中 case when then end的用法
- Coyahogo的持久层访问
- 放假啦,高兴...........
- 关于assert,ASSERT,TRACE,VERIFY