Exemple #1
0
void SimpleQueryLinker::update_results(const std::string& qvar, 
        const ConditionSet& new_set)
{
    if(!is_initialized(qvar)) {
        _qvar_table[qvar] = new_set;
    } else {
        ConditionSet difference = _qvar_table[qvar].difference_with(new_set);
        if(!difference.is_empty()) {
            for(ConditionSet::iterator it = difference.begin(); 
                    it != difference.end(); ++it )
            {
                remove_condition(qvar, *it);
            }
        }
    }
}
void ConditionSet::intersect_with(const ConditionSet& other) {
    if(other.is_empty()) {
        // we are intersecting with empty set, and so
        // the result is also an empty set.
        _set.clear();
        return; 
    }

    std::set<ConditionPtr>::iterator it = _set.begin();
    while(it != _set.end()) {
        if(!other.has_element(*it)) {
            std::set<ConditionPtr>::iterator old_it = it++;
            _set.erase(old_it);
        } else {
            ++it;
        }
    }
}