From 1939ace3ba922f626d9fde242174c40037481cef Mon Sep 17 00:00:00 2001 From: Daniel Berlin Date: Mon, 24 Sep 2007 17:52:25 +0000 Subject: [PATCH] Add section on bit containers. (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 --- docs/ProgrammersManual.html | 49 +++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/docs/ProgrammersManual.html b/docs/ProgrammersManual.html index a9daba3ba93..795b91a76ba 100644 --- a/docs/ProgrammersManual.html +++ b/docs/ProgrammersManual.html @@ -77,6 +77,11 @@ option
  • <map>
  • Other Map-Like Container Options
  • +
  • BitVector-like containers +
  • Helpful Hints for Common Operations @@ -705,6 +710,11 @@ access the container. Based on that, you should use:

    iteration, but do not support efficient look-up based on a key.
  • +
  • a bit 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. +
  • @@ -1276,6 +1286,45 @@ expensive. Element iteration does not visit elements in a useful order.

    + +
    + Bit storage containers (BitVector, SparseBitVector) +
    + +
    +Unlike the other containers, there are only two bit storage containers, and when +to use each is relatively straightforward. +
    + + +
    + BitVector +
    + +
    +

    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). +

    +
    + + +
    + SparseBitVector +
    + +
    +

    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). +

    +