M
M
Below where you see ____THIS LINE
if that 80 is 32 then it works but anything over it blows up.
where am I wrong?
thanks
#include <bitset>
#include <map>
#include <iostream>
#pragma warning(disable:4786)
using namespace std;
typedef bitset<80> myBitSet;
struct eqmySet
{
bool operator()(const myBitSet& s1, const myBitSet& s2) const
{
return s1.to_ulong() < s2.to_ulong();
}
};
string ShowBitSet(myBitSet bs)
{
string s;
for(unsigned i = 0; i < bs.size(); i++)
{
if(bs.test(i))
{
s += "1";
}
else
s += "0";
}
return s;
}
typedef map<myBitSet, int, eqmySet> key_hash_t;
int main(int argc, char* argv[])
{
key_hash_t ht;
for(int j = 0; j < 3; j++)
{
myBitSet kb;
for(int i=0; i < 80; i++) <<<<<< ____THIS LINE
kb.set(i);
ht[kb]++;
}
key_hash_t::iterator p;
for(p = ht.begin(); p != ht.end(); ++p)
cout << ShowBitSet(p->first) << " : " << p->second << endl;
return 0;
}
if that 80 is 32 then it works but anything over it blows up.
where am I wrong?
thanks
#include <bitset>
#include <map>
#include <iostream>
#pragma warning(disable:4786)
using namespace std;
typedef bitset<80> myBitSet;
struct eqmySet
{
bool operator()(const myBitSet& s1, const myBitSet& s2) const
{
return s1.to_ulong() < s2.to_ulong();
}
};
string ShowBitSet(myBitSet bs)
{
string s;
for(unsigned i = 0; i < bs.size(); i++)
{
if(bs.test(i))
{
s += "1";
}
else
s += "0";
}
return s;
}
typedef map<myBitSet, int, eqmySet> key_hash_t;
int main(int argc, char* argv[])
{
key_hash_t ht;
for(int j = 0; j < 3; j++)
{
myBitSet kb;
for(int i=0; i < 80; i++) <<<<<< ____THIS LINE
kb.set(i);
ht[kb]++;
}
key_hash_t::iterator p;
for(p = ht.begin(); p != ht.end(); ++p)
cout << ShowBitSet(p->first) << " : " << p->second << endl;
return 0;
}