Skip to content
Snippets Groups Projects
Commit db5a0584 authored by Jordi Inglada's avatar Jordi Inglada
Browse files

STYLE: clean code a little bit

parent 0519abd5
No related branches found
No related tags found
No related merge requests found
......@@ -108,28 +108,28 @@ DecisionTree<AttributeValueType, LabelType>
DecisionTreeTestType theTest = theKey.second;
AttributeValueType theValue = theKey.first;
switch( theTest )
{
case LT:
if( attrValue < theValue )
return lmIt->second;
break;
case LE:
if( attrValue <= theValue )
return lmIt->second;
break;
case EQ:
if( attrValue == theValue )
return lmIt->second;
break;
case GE:
if( attrValue >= theValue )
return lmIt->second;
break;
case GT:
if( attrValue > theValue )
return lmIt->second;
break;
}
{
case LT:
if( attrValue < theValue )
return lmIt->second;
break;
case LE:
if( attrValue <= theValue )
return lmIt->second;
break;
case EQ:
if( attrValue == theValue )
return lmIt->second;
break;
case GE:
if( attrValue >= theValue )
return lmIt->second;
break;
case GT:
if( attrValue > theValue )
return lmIt->second;
break;
}
++lmIt;
}
......@@ -151,58 +151,62 @@ DecisionTree<AttributeValueType, LabelType>
DecisionTreeTestType theTest = theKey.second;
AttributeValueType theValue = theKey.first;
switch( theTest )
{
case LT:
if( attrValue < theValue )
{
candidateKeys.push_back( theKey );
found = true;
}
break;
case LE:
if( attrValue <= theValue )
{
candidateKeys.push_back( theKey );
found = true;
}
break;
case EQ:
if( attrValue == theValue )
{
candidateKeys.push_back( theKey );
found = true;
}
break;
case GE:
if( attrValue >= theValue )
{
candidateKeys.push_back( theKey );
found = true;
}
break;
case GT:
if( attrValue > theValue )
{
candidateKeys.push_back( theKey );
found = true;
}
break;
}
{
case LT:
if( attrValue < theValue )
{
candidateKeys.push_back( theKey );
found = true;
}
break;
case LE:
if( attrValue <= theValue )
{
candidateKeys.push_back( theKey );
found = true;
}
break;
case EQ:
if( attrValue == theValue )
{
candidateKeys.push_back( theKey );
found = true;
}
break;
case GE:
if( attrValue >= theValue )
{
candidateKeys.push_back( theKey );
found = true;
}
break;
case GT:
if( attrValue > theValue )
{
candidateKeys.push_back( theKey );
found = true;
}
break;
}
++tmIt;
}
if( ! found ) // attribute
// not found
// in the map
// not found
// in the map
{
itkGenericExceptionMacro(<< "Example could not be handled by decision tree.");
// If we found one or several matching tests
typename std::vector< KeyType >::const_iterator ckIt = candidateKeys.begin();
while ( ckIt != candidateKeys.end() )
}
else
{
std::cout << (*ckIt).first << " " << (*ckIt).second << std::endl;
Pointer child = (*m_TreeMap)[(*ckIt)];
return child->Decide(example);
// If we found one or several matching tests
typename std::vector< KeyType >::const_iterator ckIt = candidateKeys.begin();
while ( ckIt != candidateKeys.end() )
{
std::cout << (*ckIt).first << " " << (*ckIt).second << std::endl;
Pointer child = (*m_TreeMap)[(*ckIt)];
return child->Decide(example);
}
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment