Skip to content

Commit

Permalink
Add section on bit containers.
Browse files Browse the repository at this point in the history
(Not the most well written stuff in the universe :P)


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@42267 91177308-0d34-0410-b5e6-96231b3b80d8
  • Loading branch information
dberlin committed Sep 24, 2007
1 parent 06611df commit 1939ace
Showing 1 changed file with 49 additions and 0 deletions.
49 changes: 49 additions & 0 deletions docs/ProgrammersManual.html
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,11 @@
<li><a href="#dss_map">&lt;map&gt;</a></li>
<li><a href="#dss_othermap">Other Map-Like Container Options</a></li>
</ul></li>
<li><a href="#ds_bit">BitVector-like containers</a>
<ul>
<li><a href="#dss_bitvector">A dense bitvector</a></li>
<li><a href="#dss_sparsebitvector">A sparse bitvector</a></li>
</ul></li>
</ul>
</li>
<li><a href="#common">Helpful Hints for Common Operations</a>
Expand Down Expand Up @@ -705,6 +710,11 @@
iteration, but do not support efficient look-up based on a key.
</li>

<li>a <a href="#ds_bit">bit</a> container provides an efficient way to store and
perform set operations on sets of numeric id's, while automatically
eliminating duplicates. Bit containers require a maximum of 1 bit for each
identifier you want to store.
</li>
</ul>

<p>
Expand Down Expand Up @@ -1276,6 +1286,45 @@

</div>

<!-- ======================================================================= -->
<div class="doc_subsection">
<a name="ds_bit">Bit storage containers (BitVector, SparseBitVector)</a>
</div>

<div class="doc_text">
Unlike the other containers, there are only two bit storage containers, and when
to use each is relatively straightforward.
</div>

<!-- _______________________________________________________________________ -->
<div class="doc_subsubsection">
<a name="dss_bitvector">BitVector</a>
</div>

<div class="doc_text">
<p> The BitVector container provides a fixed size set of bits for manipulation.
It supports individual bit setting/testing, as well as set operations. The set
operations take time O(size of bitvector), but operations are performed one word
at a time, instead of one bit at a time. This makes the BitVector very fast for
set operations compared to other containers. Use the BitVector when you expect
the number of set bits to be high (IE a dense set).
</p>
</div>

<!-- _______________________________________________________________________ -->
<div class="doc_subsubsection">
<a name="dss_sparsebitvector">SparseBitVector</a>
</div>

<div class="doc_text">
<p> The SparseBitVector container is much like BitVector, with one major
difference: Only the bits that are set, are stored. This makes the
SparseBitVector much more space efficient than BitVector when the set is sparse,
as well as making set operations O(number of set bits) instead of O(size of
universe). The downside to the SparseBitVector is that setting and testing of random bits is O(N), and on large SparseBitVectors, this can be slower than BitVector. In our implementation, setting or testing bits in sorted order
(either forwards or reverse) is O(1) worst case. Testing and setting bits within 128 bits (depends on size) of the current bit is also O(1). As a general statement, testing/setting bits in a SparseBitVector is O(distance away from last set bit).
</p>
</div>

<!-- *********************************************************************** -->
<div class="doc_section">
Expand Down

0 comments on commit 1939ace

Please sign in to comment.