@ Override public boolean add ( S solution ) { boolean solutionInserted = false ; if ( solutionList . size ( ) == 0 ) { solutionList . add ( solution ) ; solutionInserted = true ; } else { Iterator < S > iterator = solutionList . iterator ( ) ; boolean isDominated = false ; boolean isContained = false ; while ( ( ( ! isDominated ) && ( ! isContained ) ) && ( iterator . hasNext ( ) ) ) { S listIndividual = iterator . next ( ) ; int flag = dominanceComparator . compare ( solution , listIndividual ) ; if ( flag == - 1 ) { iterator . remove ( ) ; } else if ( flag == 1 ) { isDominated = true ; // dominated by one in the list } else if ( flag == 0 ) { int equalflag = equalSolutions . compare ( solution , listIndividual ) ; if ( equalflag == 0 ) // solutions are equals isContained = true ; } } if ( ! isDominated && ! isContained ) { solutionList . add ( solution ) ; solutionInserted = true ; } return solutionInserted ; } return solutionInserted ; }
Inserts a solution in the list