bool Split::subsetOf (Split &sp) { assert(ntaxa == sp.ntaxa); for (iterator it = begin(), it2 = sp.begin(); it != end(); it++, it2++) if ( ((*it) & (*it2)) != (*it) ) return false; return true; }
bool Split::operator==(const Split &sp) const{ if (ntaxa != sp.ntaxa) return false; for (const_iterator it = begin(), it2 = sp.begin(); it != end(); it++, it2++) if ((*it) != (*it2)) return false; return true; }
bool Split::overlap(Split &sp) { assert(ntaxa == sp.ntaxa); iterator it, it2; for (it = begin(), it2 = sp.begin(); it != end(); it++, it2++) if ((*it) & (*it2)) return true; return false; }
/** @param taxa_set set of taxa @return true if this split is preserved in the set taxa_set */ bool Split::preserved(Split &taxa_set) { // be sure that the two split has the same size assert(taxa_set.size() == size() && taxa_set.ntaxa == ntaxa); int time_zero = 0, time_notzero = 0; for (iterator it = begin(), sit = taxa_set.begin(); it != end(); it++, sit++) { UINT res = (*it) & (*sit); if (res != 0 && res != (*sit)) return true; if (*sit != 0) { if (res == 0) time_zero++; else time_notzero++; if (res == 0 && time_notzero > 0) return true; if (res != 0 && time_zero > 0) return true; } } return false; }
/** @param sp the other split @return true if this split is compatible with sp */ bool Split::compatible(Split &sp) { // be sure that the two split has the same size assert(sp.size() == size() && sp.ntaxa == ntaxa); UINT res = 0, res2 = 0, res3 = 0, res4 = 0; for (iterator it = begin(), sit = sp.begin(); it != end(); it++, sit++) { int num_bits = (it+1 == end()) ? ntaxa % UINT_BITS : UINT_BITS; UINT it2 = (1 << (num_bits-1)) - 1 + (1 << (num_bits-1)) - (*it); UINT sit2 = (1 << (num_bits-1)) - 1 + (1 << (num_bits-1)) - (*sit); res |= (*it) & (*sit); res2 |= (it2) & (sit2); res3 |= (*it) & (sit2); res4 |= (it2) & (*sit); if (res != 0 && res2 != 0 && res3 != 0 && res4 != 0) return false; //if (res != 0 && res != (*it) && res != (*sit) && res2 != 0) //return false; } return true; //return (res == 0) || (res2 == 0) || (res3 == 0) || (res4 == 0); }