Browse Source

dynamic_bitset requires both sets to be same size

pcb_db
Seth Hillbrand 11 months ago
parent
commit
7ea6206126
  1. 60
      include/base_set.h

60
include/base_set.h

@ -186,21 +186,75 @@ public:
// Compound assignment AND operator
BASE_SET& operator&=(const BASE_SET& other)
{
sul::dynamic_bitset<uint64_t>::operator&=(other);
size_t my_size = size();
size_t other_size = other.size();
if( my_size == other_size )
{
sul::dynamic_bitset<uint64_t>::operator&=(other);
}
else if( my_size < other_size )
{
sul::dynamic_bitset<uint64_t>::resize( other_size );
sul::dynamic_bitset<uint64_t>::operator&=( other );
}
else
{
BASE_SET tmp( other );
tmp.resize( my_size );
sul::dynamic_bitset<uint64_t>::operator&=( tmp );
}
return *this;
}
// Compound assignment OR operator
BASE_SET& operator|=(const BASE_SET& other)
{
sul::dynamic_bitset<uint64_t>::operator|=(other);
size_t my_size = size();
size_t other_size = other.size();
if( my_size == other_size )
{
sul::dynamic_bitset<uint64_t>::operator|=(other);
}
else if( my_size < other_size )
{
sul::dynamic_bitset<uint64_t>::resize( other_size );
sul::dynamic_bitset<uint64_t>::operator|=( other );
}
else
{
BASE_SET tmp( other );
tmp.resize( my_size );
sul::dynamic_bitset<uint64_t>::operator|=( tmp );
}
return *this;
}
// Compound assignment XOR operator
BASE_SET& operator^=(const BASE_SET& other)
{
sul::dynamic_bitset<uint64_t>::operator^=(other);
size_t my_size = size();
size_t other_size = other.size();
if( my_size == other_size )
{
sul::dynamic_bitset<uint64_t>::operator^=(other);
}
else if( my_size < other_size )
{
sul::dynamic_bitset<uint64_t>::resize( other_size );
sul::dynamic_bitset<uint64_t>::operator^=( other );
}
else
{
BASE_SET tmp( other );
tmp.resize( my_size );
sul::dynamic_bitset<uint64_t>::operator^=( tmp );
}
return *this;
}

Loading…
Cancel
Save