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

📄 bit_vector.html

📁 STL_doc
💻 HTML
📖 第 1 页 / 共 2 页
字号:
<TD VAlign=top> <A href="Sequence.html">Sequence</A></TD><TD VAlign=top>Creates a bit_vector with <tt>n</tt> copies of <tt>t</tt>.</TD></TR><TR><TD VAlign=top><tt>bit_vector(const bit_vector&amp;)</tt></TD><TD VAlign=top> <A href="Container.html">Container</A></TD><TD VAlign=top>The copy constructor.</TD></TR><TR><TD VAlign=top><pre>template &lt;class <A href="InputIterator.html">InputIterator</A>&gt;bit_vector(InputIterator, InputIterator)<A href="#1">[1]</A></pre></TD><TD VAlign=top> <A href="Sequence.html">Sequence</A></TD><TD VAlign=top>Creates a bit_vector with a copy of a range.</TD></TR><TR><TD VAlign=top><tt>~bit_vector()</tt></TD><TD VAlign=top> <A href="Container.html">Container</A></TD><TD VAlign=top>The destructor.</TD></TR><TR><TD VAlign=top><tt>bit_vector&amp; operator=(const bit_vector&amp;)</tt></TD><TD VAlign=top> <A href="Container.html">Container</A></TD><TD VAlign=top>The assignment operator</TD></TR><TR><TD VAlign=top><tt>void reserve(size_t)</tt></TD><TD VAlign=top><tt>bit_vector</tt></TD><TD VAlign=top>See below.</TD></TR><TR><TD VAlign=top><tt>reference front()</tt></TD><TD VAlign=top> <A href="Sequence.html">Sequence</A></TD><TD VAlign=top>Returns the first element.</TD></TR><TR><TD VAlign=top><tt>const_reference front() const</tt></TD><TD VAlign=top> <A href="Sequence.html">Sequence</A></TD><TD VAlign=top>Returns the first element.</TD></TR><TR><TD VAlign=top><tt>reference back()</tt></TD><TD VAlign=top> <A href="BackInsertionSequence.html">Back Insertion Sequence</A></TD><TD VAlign=top>Returns the last element.</TD></TR><TR><TD VAlign=top><tt>const_reference back() const</tt></TD><TD VAlign=top> <A href="BackInsertionSequence.html">Back Insertion Sequence</A></TD><TD VAlign=top>Returns the last element.</TD></TR><TR><TD VAlign=top><tt>void push_back(const T&amp;)</tt></TD><TD VAlign=top> <A href="BackInsertionSequence.html">Back Insertion Sequence</A></TD><TD VAlign=top>Inserts a new element at the end.</TD></TR><TR><TD VAlign=top><tt>void pop_back()</tt></TD><TD VAlign=top> <A href="BackInsertionSequence.html">Back Insertion Sequence</A></TD><TD VAlign=top>Removes the last element.</TD></TR><TR><TD VAlign=top><tt>void swap(bit_vector&amp;)</tt></TD><TD VAlign=top> <A href="Container.html">Container</A></TD><TD VAlign=top>Swaps the contents of two bit_vectors.</TD></TR><TR><TD VAlign=top><pre>void swap(bit_vector::reference x,          bit_vector::reference y)</pre></TD><TD VAlign=top><tt>bit_vector</tt></TD><TD VAlign=top>See below.</TD></TR><TR><TD VAlign=top><tt>iterator insert(iterator pos, bool x)</tt></TD><TD VAlign=top> <A href="Sequence.html">Sequence</A></TD><TD VAlign=top>Inserts <tt>x</tt> before <tt>pos</tt>.</TD></TR><TR><TD VAlign=top><pre>template &lt;class <A href="InputIterator.html">InputIterator</A>&gt;void insert(iterator pos,            InputIterator f, InputIterator l)<A href="#1">[1]</A></pre></TD><TD VAlign=top> <A href="Sequence.html">Sequence</A></TD><TD VAlign=top>Inserts the range <tt>[f, l)</tt> before <tt>pos</tt>.</TD></TR><TR><TD VAlign=top><pre>void insert(iterator pos,             size_type n, bool x)</pre></TD><TD VAlign=top> <A href="Sequence.html">Sequence</A></TD><TD VAlign=top>Inserts <tt>n</tt> copies of <tt>x</tt> before <tt>pos</tt>.</TD></TR><TR><TD VAlign=top><tt>void erase(iterator pos)</tt></TD><TD VAlign=top> <A href="Sequence.html">Sequence</A></TD><TD VAlign=top>Erases the element at position <tt>pos</tt>.</TD></TR><TR><TD VAlign=top><tt>void erase(iterator first, iterator last)</tt></TD><TD VAlign=top> <A href="Sequence.html">Sequence</A></TD><TD VAlign=top>Erases the range <tt>[first, last)</tt></TD></TR><TR><TD VAlign=top><tt>void clear()</tt></TD><TD VAlign=top> <A href="Sequence.html">Sequence</A></TD><TD VAlign=top>Erases all of the elements.</TD></TR><TR><TD VAlign=top><pre>bool operator==(const bit_vector&amp;,                 const bit_vector&amp;)</pre></TD><TD VAlign=top> <A href="ForwardContainer.html">Forward Container</A></TD><TD VAlign=top>Tests two bit_vectors for equality.  This is a global function, not   a member function.</TD></TR><TR><TD VAlign=top><pre>bool operator&lt;(const bit_vector&amp;,                const bit_vector&amp;)</pre></TD><TD VAlign=top> <A href="ForwardContainer.html">Forward Container</A></TD><TD VAlign=top>Lexicographical comparison.  This is a global function, not   a member function.</TD></tr></table><h3>New members</h3>These members are not defined in the <A href="RandomAccessContainer.html">Random access container</A> and <A href="BackInsertionSequence.html">Back insertion sequence</A>requirements, but are specific to <tt>vector</tt>.<Table border><TR><TH>Member</TH><TH>Description</TH></TR><TR><TD VAlign=top><tt>reference</tt></TD><TD VAlign=top>A proxy class that acts as a reference to a single bit; the reason it   exists is to allow expressions like <tt>V[0] = true</tt>.  (A proxy   class like this is necessary, because the C++ memory model does not   include independent addressing of objects smaller than one byte.)   The public member functions of <tt>reference</tt> are <tt>operator bool() const</tt>,   <tt>reference&amp; operator=(bool)</tt>, and <tt>void flip()</tt>.  That is, <tt>reference</tt>   acts like an ordinary reference: you can convert a <tt>reference</tt> to <tt>bool</tt>,    assign a <tt>bool</tt> value through a <tt>reference</tt>, or flip the bit that a   <tt>reference</tt> refers to.</TD></TR><TR><TD VAlign=top><tt>size_type capacity() const</tt></TD><TD VAlign=top>Number of bits for which memory has been allocated.   <tt>capacity()</tt> is always greater than or equal to <tt>size()</tt>.   <A href="#2">[2]</A> <A href="#3">[3]</A></TD></TR><TR><TD VAlign=top><tt>void reserve(size_type n)</tt></TD><TD VAlign=top>If <tt>n</tt> is less than or equal to <tt>capacity()</tt>, this call has no effect.    Otherwise, it is a request for the allocation of additional     memory.  If the request is successful, then <tt>capacity()</tt> is    greater than or equal to <tt>n</tt>; otherwise, <tt>capacity()</tt> is unchanged.    In either case, <tt>size()</tt> is unchanged.  <A href="#2">[2]</A> <A href="#4">[4]</A></TD></TR><TR><TD VAlign=top><pre>void swap(bit_vector::reference x,          bit_vector::reference y)</pre></TD><TD VAlign=top>Swaps the bits referred to by <tt>x</tt> and <tt>y</tt>.  This is a global function,   not a member function.  It is necessary because the ordinary version   of <tt><A href="swap.html">swap</A></tt> takes arguments of type <tt>T&amp;</tt>, and <tt>bit_vector::reference</tt>   is a class, not a built-in C++ reference.</TD></tr></table><h3>Notes</h3><P><A name="1">[1]</A>This member function relies on <i>member template</i> functions, whichat present (early 1998) are not supported by all compilers.  If yourcompiler supports member templates, you can call this function withany type of <A href="InputIterator.html">input iterator</A>.  If yourcompiler does not yet support member templates, though, then thearguments must either be of type <tt>const bool*</tt> or of type<tt>bit_vector::const_iterator</tt>.<P><A name="2">[2]</A>Memory will be reallocated automatically if more than <tt>capacity() -size()</tt> bits are inserted into the bit_vector.  Reallocation doesnot change <tt>size()</tt>, nor does it change the values of any bitsof the bit_vector.  It does, however, increase <tt>capacity()</tt>,and it invalidates <A href="#5">[5]</A> any iterators that point intothe bit_vector.<P><A name="3">[3]</A>When it is necessary to increase <tt>capacity()</tt>,<tt>bit_vector</tt> usually increases it by a factor of two.  It iscrucial that the amount of growth is proportional to the current<tt>capacity()</tt>, rather than a fixed constant: in the former caseinserting a series of bits into a bit_vector is a linear timeoperation, and in the latter case it is quadratic.<P><A name="4">[4]</A><tt>reserve()</tt> is used to cause a reallocation manually.  The mainreason for using <tt>reserve()</tt> is efficiency: if you know thecapacity to which your <tt>bit_vector</tt> must eventually grow, thenit is probably more efficient to allocate that memory all at oncerather than relying on the automatic reallocation scheme.  The otherreason for using <tt>reserve()</tt> is to control the invalidation ofiterators. <A href="#5">[5]</A><P><A name="5">[5]</A>A <tt>bit_vector</tt>'s iterators are invalidated when its memory isreallocated.  Additionally, inserting or deleting a bit in the middleof a bit_vector invalidates all iterators that point to bits followingthe insertion or deletion point.  It follows that you can prevent abit_vector's iterators from being invalidated if you use<tt>reserve()</tt> to preallocate as much storage as the bit_vectorwill ever use, and if all insertions and deletions are at thebit_vector's end.<h3>See also</h3><A href="Vector.html">vector</A><!--start footer--> <HR SIZE="6"><A href="http://www.sgi.com/"><IMG SRC="surf.gif" HEIGHT="54" WIDTH="54"         ALT="[Silicon Surf]"></A><A HREF="index.html"><IMG SRC="stl_home.gif"         HEIGHT="54" WIDTH="54" ALT="[STL Home]"></A><BR><FONT SIZE="-2"><A href="http://www.sgi.com/Misc/sgi_info.html" TARGET="_top">Copyright &copy; 1999 Silicon Graphics, Inc.</A> All Rights Reserved.</FONT><FONT SIZE="-3"><a href="http://www.sgi.com/Misc/external.list.html" TARGET="_top">TrademarkInformation</A></FONT><P></BODY></HTML> 

⌨️ 快捷键说明

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