private FilterResult < G , C > filter ( final Seq < Phenotype < G , C > > population , final long generation ) { int killCount = 0 ; int invalidCount = 0 ; final MSeq < Phenotype < G , C > > pop = MSeq . of ( population ) ; for ( int i = 0 , n = pop . size ( ) ; i < n ; ++ i ) { final Phenotype < G , C > individual = pop . get ( i ) ; if ( ! _validator . test ( individual ) ) { pop . set ( i , newPhenotype ( generation ) ) ; ++ invalidCount ; } else if ( individual . getAge ( generation ) > _maximalPhenotypeAge ) { pop . set ( i , newPhenotype ( generation ) ) ; ++ killCount ; } } return new FilterResult <> ( pop . toISeq ( ) , killCount , invalidCount ) ; }
Filters out invalid and old individuals . Filtering is done in place .