variable_set.cc
//adds the variable to the variable set
//returns -1 if the variable is the next inside the variable set
//else it returns an old position inside the variable set that has the same value
adds the variable to the variable set
returns -1 if the variable is the next inside the variable set
else it returns an old position inside the variable set that has the same value
adds the variable to the variable set returns - 1 if the variable is the next inside the variable set else it returns an old position inside the variable set that has the same value
int64_t VariableSet::addVariable(Variable variable)  {
    int64_t variableId = -1; 
    if(variable.type != VariableSetType::BOOLEAN && 
       !(variable.type == VariableSetType::ID && variable.isEnum)) 
    { 
        vector<Variable>::iterator varId = find(variables.begin(), variables.end(), variable);
        if(varId != variables.end()) {
            int64_t originalVarId = distance(variables.begin(), varId);
            if(originalVarId < (((int64_t) 1) << bitsForSpecificVariableId ))  { 
                variableId = originalVarId; 
            }
        }
    }
    if(variableId == -1) 
        variables.push_back(variable);
    else
        return variableId; 
    #if DEBUG_POLICY_GENERATION
        addVariableForDebug(variable);
    #endif
    return variableId;
}
int64_t VariableSet :: addVariable ( Variable variable ) { int64_t variableId = -1 ; if ( variable . type != VariableSetType :: BOOLEAN && ! ( variable . type == VariableSetType :: ID && variable . isEnum ) ) { vector < Variable > :: iterator varId = find ( variables . begin ( ) , variables . end ( ) , variable ) ; if ( varId != variables . end ( ) ) { int64_t originalVarId = distance ( variables . begin ( ) , varId ) ; if ( originalVarId < ( ( ( int64_t ) 1 ) << bitsForSpecificVariableId ) ) { variableId = originalVarId ; } } } if ( variableId == -1 ) variables . push_back ( variable ) ; else return variableId ; #if DEBUG_POLICY_GENERATION addVariableForDebug ( variable ) ; #endif return variableId ; }
adds the variable to the variable set
returns -1 if the variable is the next inside the variable set
else it returns an old position inside the variable set that has the same value
adds the variable to the variable set returns - 1 if the variable is the next inside the variable set else it returns an old position inside the variable set that has the same value
//add the variable to the variable list //check if the variable is a duplicate //next variable is default //using the redundant feature with booleans is not worth it //do not use specific variables with enum ids, since then we need them in the set to identify the enum values //is a duplicate //skip the specific var id feature when the relation pos needs more bits than assigned for this feature //store the original variable id //just add new variables //don't add specific variables to the debug output //DEBUG output for VariableSet