1 |
424 |
jeremybenn |
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
2 |
|
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
3 |
|
|
<html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>HP/SGI</title><meta name="generator" content="DocBook XSL Stylesheets V1.75.2" /><meta name="keywords" content=" ISO C++ , library " /><link rel="home" href="../spine.html" title="The GNU C++ Library Documentation" /><link rel="up" href="ext_containers.html" title="Chapter 34. Containers" /><link rel="prev" href="ext_containers.html" title="Chapter 34. Containers" /><link rel="next" href="bk01pt12ch34s03.html" title="Deprecated HP/SGI" /></head><body><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">HP/SGI</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="ext_containers.html">Prev</a> </td><th width="60%" align="center">Chapter 34. Containers</th><td width="20%" align="right"> <a accesskey="n" href="bk01pt12ch34s03.html">Next</a></td></tr></table><hr /></div><div class="sect1" title="HP/SGI"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="manual.ext.containers.sgi"></a>HP/SGI</h2></div></div></div><p>
|
4 |
|
|
</p><p>A few extensions and nods to backwards-compatibility have been made with
|
5 |
|
|
containers. Those dealing with older SGI-style allocators are dealt with
|
6 |
|
|
elsewhere. The remaining ones all deal with bits:
|
7 |
|
|
</p><p>The old pre-standard <code class="code">bit_vector</code> class is present for
|
8 |
|
|
backwards compatibility. It is simply a typedef for the
|
9 |
|
|
<code class="code">vector<bool></code> specialization.
|
10 |
|
|
</p><p>The <code class="code">bitset</code> class has a number of extensions, described in the
|
11 |
|
|
rest of this item. First, we'll mention that this implementation of
|
12 |
|
|
<code class="code">bitset<N></code> is specialized for cases where N number of
|
13 |
|
|
bits will fit into a single word of storage. If your choice of N is
|
14 |
|
|
within that range (<=32 on i686-pc-linux-gnu, for example), then all
|
15 |
|
|
of the operations will be faster.
|
16 |
|
|
</p><p>There are
|
17 |
|
|
versions of single-bit test, set, reset, and flip member functions which
|
18 |
|
|
do no range-checking. If we call them member functions of an instantiation
|
19 |
|
|
of "bitset<N>," then their names and signatures are:
|
20 |
|
|
</p><pre class="programlisting">
|
21 |
|
|
bitset<N>& _Unchecked_set (size_t pos);
|
22 |
|
|
bitset<N>& _Unchecked_set (size_t pos, int val);
|
23 |
|
|
bitset<N>& _Unchecked_reset (size_t pos);
|
24 |
|
|
bitset<N>& _Unchecked_flip (size_t pos);
|
25 |
|
|
bool _Unchecked_test (size_t pos);
|
26 |
|
|
</pre><p>Note that these may in fact be removed in the future, although we have
|
27 |
|
|
no present plans to do so (and there doesn't seem to be any immediate
|
28 |
|
|
reason to).
|
29 |
|
|
</p><p>The semantics of member function <code class="code">operator[]</code> are not specified
|
30 |
|
|
in the C++ standard. A long-standing defect report calls for sensible
|
31 |
|
|
obvious semantics, which are already implemented here: <code class="code">op[]</code>
|
32 |
|
|
on a const bitset returns a bool, and for a non-const bitset returns a
|
33 |
|
|
<code class="code">reference</code> (a nested type). However, this implementation does
|
34 |
|
|
no range-checking on the index argument, which is in keeping with other
|
35 |
|
|
containers' <code class="code">op[]</code> requirements. The defect report's proposed
|
36 |
|
|
resolution calls for range-checking to be done. We'll just wait and see...
|
37 |
|
|
</p><p>Finally, two additional searching functions have been added. They return
|
38 |
|
|
the index of the first "on" bit, and the index of the first
|
39 |
|
|
"on" bit that is after <code class="code">prev</code>, respectively:
|
40 |
|
|
</p><pre class="programlisting">
|
41 |
|
|
size_t _Find_first() const;
|
42 |
|
|
size_t _Find_next (size_t prev) const;</pre><p>The same caveat given for the _Unchecked_* functions applies here also.
|
43 |
|
|
</p></div><div class="navfooter"><hr /><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="ext_containers.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="ext_containers.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="bk01pt12ch34s03.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">Chapter 34. Containers </td><td width="20%" align="center"><a accesskey="h" href="../spine.html">Home</a></td><td width="40%" align="right" valign="top"> Deprecated HP/SGI</td></tr></table></div></body></html>
|