"Fossies" - the Fresh Open Source Software Archive

Member "heaplayers-351/heaplayers/util/bitindex.cpp" (17 May 2006, 665 Bytes) of package /linux/misc/old/heaplayers_3_5_1.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "bitindex.cpp" see the Fossies "Dox" file reference documentation.

    1 #include "bitindex.h"
    2 
    3 // Definitions of static members of BitIndex.
    4 
    5 int BitIndex::index32[32];
    6 unsigned long BitIndex::on[32];
    7 unsigned long BitIndex::off[32];
    8 unsigned long BitIndex::lgtable[16];
    9 
   10 // Implementations.
   11 
   12 BitIndex::BitIndex (void)
   13 {
   14   setup();
   15 }
   16 
   17 
   18 void BitIndex::setup (void)
   19 {
   20   int t[] = { 0, 0, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3};
   21   int i;
   22   for (i = 0; i < 32; i++) {
   23     index32[ (debruijn32 << i) >> 27 ] = i;
   24   }
   25   for (i = 0; i < 16; i++) {
   26     lgtable[i] = t[i];
   27   }
   28   for (i = 0; i < 32; i++) {
   29     on[i] = 1 << i;
   30     off[i] = ~on[i];
   31   }
   32 }
   33 
   34 
   35 
   36 // One instance of BitIndex so everything will work.
   37 
   38 static BitIndex _hiddenBitIndex;