boo_1544.htm
来自「ARM编辑、编译软件」· HTM 代码 · 共 17 行
HTM
17 行
<HTML><HEAD><TITLE>Boolean Vectors</TITLE></HEAD>
<BODY>
<A HREF="ug.htm"><IMG SRC="images/banner.gif"></A>
<P><STRONG>Click on the banner to return to the user guide home page.</STRONG></P>
<P>©Copyright 1996 Rogue Wave Software</P>
<H2>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<bool></I></B>, are a superset of those for an ordinary vector, only the implementation is more efficient.</P>
<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<bool> bvec(27);
bvec.flip(); // flip all values
bvec[17].flip(); // flip bit 17</PRE>
<P><B><I>vector<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_8233.htm"><IMG SRC="images/prev.gif"></A> <A HREF="booktoc.htm"><IMG SRC="images/toc.gif"></A> <A HREF="exa_4427.htm"><IMG SRC="images/next.gif"></A></BODY></HTML>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?