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

📄 boo_0584.htm

📁 C++标准库 C++标准库 C++标准库 C++标准库
💻 HTM
字号:
<HTML><HEAD><TITLE>5.3 Boolean Vectors</TITLE></HEAD><BODY><A HREF="ug1.htm"><IMG SRC="images/banner.gif"></A><BR><A HREF="vec_6528.htm"><IMG SRC="images/prev.gif"></A><A HREF="booktoc1.htm"><IMG SRC="images/toc.gif"></A><A HREF="tindex1.htm"><IMG SRC="images/tindex.gif"></A><A HREF="exa_7254.htm"><IMG SRC="images/next.gif"></A><BR><STRONG>Click on the banner to return to the user guide home page.</STRONG><H2>5.3 Boolean Vectors</H2><P>Vectors of bit values (boolean 1/0 values) are handled as a special case by the standard library, so that the values can be efficiently packed (several elements to a word).  The operations for a boolean vector , <B><I>vector&#60;bool></I></B>, are a superset of those for an ordinary vector, only the implementation is more efficient.</P><A NAME="idx63"><!></A><P>One new member function added to the boolean vector data type is <SAMP>flip().</SAMP>  When invoked, this function inverts all the bits of the vector.  Boolean vectors also return as reference an internal value that also supports the <SAMP>flip()</SAMP> member function.</P><PRE>   vector&#60;bool> bvec(27);   bvec.flip();               // flip all values   bvec[17].flip();           // flip bit 17</PRE><P><B><I>vector&#60;bool></I></B> also supports an additional <SAMP>swap()</SAMP> member function that allows you to swap the values indicated by a pair of references. </P><PRE>   bvec.swap(bvec [17], bvec [16]);</PRE><HR><A HREF="vec_6528.htm"><IMG SRC="images/prev.gif"></A> <A HREF="booktoc1.htm"><IMG SRC="images/toc.gif"></A><A HREF="tindex1.htm"><IMG SRC="images/tindex.gif"></A><A HREF="exa_7254.htm"><IMG SRC="images/next.gif"></A><P>&copy;Copyright 1996, Rogue Wave Software, Inc.</P></BODY></HTML>

⌨️ 快捷键说明

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