public member function
<vector>
Flip bits
Flips all values in the container: All instances oftruebecomefalse, and all instances offalsebecometrue.
翻转容器内的所有值,即所有的true变为false,所有的false变为true;
例子:
<span style="color:#993399;">#include <iostream>
#include <vector>
using namespace std;
int main()
{
vector<bool> vb={true,false,false,true};
cout<<"vb=";
for(bool b:vb){
cout<<b<<" ";
}
cout<<endl;
vb.flip();
</span><span style="color:#ff0000;"> cout<<"vb.flip()"<<endl;</span><span style="color:#993399;">
for(bool b:vb){
cout<<b<<" ";
}
cout<<endl;
}
</span>
结果截图:
Parameters
none
Return value
none
Example
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
// vector<bool>::flip
#include <iostream>
#include <vector>
int main ()
{
std::vector<bool> mask;
mask.push_back(true);
mask.push_back(false);
mask.push_back(false);
mask.push_back(true);
mask.flip();
std::cout << std::boolalpha;
std::cout << "mask contains:";
for (unsigned i=0; i<mask.size(); i++)
std::cout << ' ' << mask.at(i);
std::cout << '\n';
return 0;
}
|
|
Output:
mask contains: false true true false
|
Complexity
Linear insize.
与数组大小线性相关。
Iterator validity
No changes.
Data races
The container is accessed.
容器将被访问。
All elements are modified.
所有的元素都将被修改。
Exception safety
No-throw guarantee:this member function never throws exceptions.
该成员方法不会抛出异常。
//翻译的不好的地方请多多指导,可以在下面留言或者点击左上方邮件地址给我发邮件,指出我的错误以及不足,以便我修改,更好的分享给大家,谢谢。
转载请注明出处:http://blog.csdn.net/qq844352155
2014-8-20
于GDUT
分享到:
相关推荐
帮助新学习STL的童鞋们了解容器
在删除选项中仔细选择<br>条款10:注意分配器的协定和约束<br>条款11:理解自定义分配器的正确用法<br>条款12:对STL容器线程安全性的期待现实一些<br>vector和string<br>条款13:尽量使用vector和string来代替动态...
#include <vector> using namespace std; struct student { int id; string name; float height; }; int main(int argc, char* argv[]) { vector<student> onit; cout<<"请输入相关学生数据:"<<endl; ...
在C++标准中,STL被组织为下面的几个头文件:<string>、<vector>、<list>、<deque>、<algorithm>、<iterator>、<set>、<map>、<memory>、<numeric>、<queue>、<functional>、<stack>和<utility>。文件中主要介绍了...
在C++标准中,STL被组织为下面的几个头文件:<string>、<vector>、<list>、<deque>、<algorithm>、<iterator>、<set>、<map>、<memory>、<numeric>、<queue>、<functional>、<stack>和<utility>。文件中主要介绍了...
在C++标准中,STL被组织为下面的几个头文件:<string>、<vector>、<list>、<deque>、<algorithm>、<iterator>、<set>、<map>、<memory>、<numeric>、<queue>、<functional>、<stack>和<utility>。文件中主要介绍了...
STL的代码从广义上讲分为三类...在C++标准中,STL被组织为下面的13个头文件:<algorithm>、<deque>、<functional>、<iterator>、<vector>、<list>、<map>、 <memory>、<numeric>、<queue>、<set>、<stack>和<utility>。
vector< bool> 并不是一个STL容器,不是一个STL容器,不是一个STL容器! 首先vector< bool> 并不是一个通常意义上的vector容器,这个源自于历史遗留问题。 早在C++98的时候,就有vector< bool>这个类型了,但是因为...
通用工具<br>5.Standard Template Library(STL,标准模板库)<br>6.STL容器(STL Container)<br>7.STL 迭代器(STL Iterators)<br>8.STL 仿函数(functors)(又名函数对象,function objects)<br>9.STL算法...
早在C++98的时候,就有vector< bool>这个类型了,但是因为当时为了考虑到节省空间的想法,所以vector< bool>里面不是一个Byte一个Byte储存的,它是一个bit一个bit储存的! 因为没有直接去给一个bit来操作,所以用...
# std::vector<T> -- via pvector command # std::list<T> -- via plist or plist_member command # std::map<T,T> -- via pmap or pmap_member command # std::multimap<T,T> -- via pmap or pmap_member command #...
STL(Standard Template ...在C++标准中,STL被组织为下面的13个头文 件:<algorithm>、<deque>、<functional>、<iterator>、<vector>、<list>、<map>、<memory>、<numeric>、<queue>、<set>、<stack> 和<utility>。
在使用STL容器(比如map、list、vector等)的时候,是用放一个对象还是放一个对象指针,即是用vector<int>还是vector<int>,这里的vector可以换成其他的容器,int可以换成其他基本类型,也可以自定义的数据结构或类...
STL(Standard Template ...在C++标准中,STL被组织为下面的13个头文件:<algorithm>、<deque>、<functional>、<iterator>、<vector>、<list>、<map>、<memory>、<numeric>、<queue>、<set>、<stack>和<utility>。
STL容器部分主要由头文件<vector>、<list>、<deque>、<set>、< map>、<stack>和<queue>组成。 (2)算法(Algorithms)。包括各种基本算法,如比较、交换、查找、排序、遍历操作、复制、修改、移除、反转、合并...
STL Algorithms<br/><br/>9.1 Algorithm Header Files<br/><br/>9.2 Algorithm Overview<br/><br/>9.3 Auxiliary Functions<br/><br/>9.4 The <br/><br/>9.5 Nonmodifying Algorithms<br/><br/>9.6 Modifying ...
VC++精品源码<br>VC 源代码 <br><br>--------------------------------------------------------------------------------<br> <br><br><br>CatListBox_src.zip<br>CatListBox_demo.zip<br><br> 这个程序模仿...
侯捷的<<STL源码剖析>>,不错的书.使用winrar可解压
<exception> 支持异常处理,这是处理程序中可能发生的错误的一种方式 <cstdarg> 支持接受数量可变的参数的函数。即在调用函数时,可以给函数传送数量不等的数据项。它定义了宏va_arg、va_end、va_start以及va_list...