pdic/src/itemsets.cpp
bool joinable(bitmask_t a, bitmask_t b)
{
	return (POPCNT(a ^ b) == 2);
#ifdef __NEVER
	bitmask_t count = 0;

	for (bitmask_t c = a ^ b; c != 0; c = c & (c - 1)) {
		count++;
		if (count > 2)
			return false;
	}
	return (count == 2);
#endif
}
// Returns true if two given itemsets could be joined to make new candidate itemset, otherwise false.
// E.g. itemsets (1,2,3) and (1,2,4) are joinable into (1,2,3,4) candidate itemset 
// but itemsets (1,2,3) and (1,5,6) or (1,2,3) and (4,5,6) are not
// --------------
// In fact this function returns true iff a and b differ only in one bit.
// This found by counting 1 in c=(a xor b), i.e. number of 1 in c should be 2.

Returns true if two given itemsets could be joined to make new candidate itemset, otherwise false.

In fact this function returns true iff a and b differ only in one bit.
This found by counting 1 in c=(a xor b), i.e. number of 1 in c should be 2.
Returns true if two given itemsets could be joined to make new candidate itemset otherwise false . In fact this function returns true iff a and b differ only in one bit . This found by counting 1 in c = ( a xor b ) i . e . number of 1 in c should be 2 .
bool joinable(bitmask_t a, bitmask_t b)
{
	return (POPCNT(a ^ b) == 2);
#ifdef __NEVER
	bitmask_t count = 0;
	for (bitmask_t c = a ^ b; c != 0; c = c & (c - 1)) {
		count++;
		if (count > 2)
			return false;
	}
	return (count == 2);
#endif
}
bool joinable ( bitmask_t a , bitmask_t b ) { return ( POPCNT ( a ^ b ) == 2 ) ; #ifdef __NEVER bitmask_t count = 0 ; for ( bitmask_t c = a ^ b ; c != 0 ; c = c & ( c - 1 ) ) { count ++ ; if ( count > 2 ) return false ; } return ( count == 2 ) ; #endif }
Returns true if two given itemsets could be joined to make new candidate itemset, otherwise false.
Returns true if two given itemsets could be joined to make new candidate itemset otherwise false .