示例#1
0
Term::Term(Term& first, Term& second, size_t new_dash) : 
    Binary(std::max(first.getDecimal(), second.getDecimal())),
    _dashes(),
    _minterms(),
    _remaining_minterms(),
    _selected(false),
    _prime_implicant(false),
    _dont_care(first.isDontCare() && second.isDontCare()),
    _literals_count(std::max(first.getLiteralCount(), second.getLiteralCount()))
{
    for (std::vector<size_t>::iterator it = first.getMinterms().begin();
         it < first.getMinterms().end(); ++it)
    {
        _minterms.push_back(*it);
    }
    
    for (std::vector<size_t>::iterator it = second.getMinterms().begin();
         it < second.getMinterms().end(); ++it)
    {
        _minterms.push_back(*it);
    }

    for (std::vector<size_t>::iterator it = first.getDashes().begin();
         it < first.getDashes().end(); ++it)
    {
        _dashes.push_back(*it);
    }

    for (std::vector<size_t>::iterator it = second.getDashes().begin();
         it < second.getDashes().end(); ++it)
    {
        _dashes.push_back(*it);
    }

    _dashes.push_back(new_dash);
}
示例#2
0
int Term::separatingBit(const Term& other) const {
    int separating_bit = -1;
    int max_num = std::max(_num, other.getDecimal());
    for (size_t i = 0; max_num > 0; ++i) {
        if (charAt(i) != other.charAt(i)) {
            if (separating_bit != -1) {
                // we already had one bit separating between
                // the terms! that means the terms are separated
                // by two or more bits.
                return -1;
            }

            separating_bit = i;
        }

        max_num = max_num / 2;
    }

    return separating_bit;
}