Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members  

simple_bitset.cxx

00001 /* $Header: /home/hopper/src/cvs/C++/LCore/simple_bitset.cxx,v 1.4 2002/08/29 00:58:04 hopper Exp $ */
00002 
00003 // For a log, see ChangeLog
00004 
00005 #ifdef __GNUG__
00006 #  pragma implementation "simple_bitset.h"
00007 #endif
00008 
00009 #ifdef __GNUG__
00010 #  pragma implementation "simple_bitset_optim.h"
00011 #endif
00012 
00013 #include "LCore/simple_bitset.h"
00014 #include <algorithm>
00015 
00016 namespace strmod {
00017 namespace lcore {
00018 namespace priv {
00019 
00020 const unsigned int _base_simple_bitset::bits_in[256] = {
00021    0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4,
00022    1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5,
00023    1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5,
00024    2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
00025    1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5,
00026    2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
00027    2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
00028    3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7,
00029    1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5,
00030    2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
00031    2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
00032    3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7,
00033    2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
00034    3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7,
00035    3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7,
00036    4, 5, 5, 6, 5, 6, 6, 7, 5, 6, 6, 7, 6, 7, 7, 8
00037 };
00038 const _base_simple_bitset::bits_t _base_simple_bitset::allones_;
00039 const size_t _base_simple_bitset::bits_t_bits;
00040 
00041 ::std::string _base_simple_bitset::to_string(const bits_t bitary[],
00042                                              size_t size, bits_t lastmask)
00043 {
00044    const size_t mysize = size;
00045    ::std::string str = "b";
00046    if (size == 0)
00047       return "";
00048    for (size_t i = 0; i < mysize; ++i)
00049    {
00050       const bits_t curnum = bitary[i];
00051       const bits_t maxmask = (i == (mysize - 1)) ? lastmask : allones_;
00052       bits_t curmask = 1U;
00053       while (curmask && (curmask < maxmask))
00054       {
00055          if (curnum & curmask)
00056          {
00057             str += '1';
00058          }
00059          else
00060          {
00061             str += '0';
00062          }
00063          curmask <<= 1;
00064       }
00065    }
00066    ::std::reverse(str.begin(), str.end());
00067    return str;
00068 }
00069 } // namespace priv
00070 } // namespace lcore
00071 } // namespace strmod

Generated on Wed Jan 29 00:32:44 2003 for libNet by doxygen1.3-rc1