private void processSource ( FastQueue < AssociatedIndex > matches , int numSource , FastQueue < AssociatedIndex > output ) { //set up data structures scores . resize ( numSource ) ; solutions . resize ( numSource ) ; for ( int i = 0 ; i < numSource ; i ++ ) { solutions . data [ i ] = - 1 ; } // select best matches for ( int i = 0 ; i < matches . size ( ) ; i ++ ) { AssociatedIndex a = matches . get ( i ) ; int found = solutions . data [ a . src ] ; if ( found != - 1 ) { if ( found == - 2 ) { // the best solution is invalid because two or more had the same score, see if this is better double bestScore = scores . data [ a . src ] ; int result = type . compareTo ( bestScore , a . fitScore ) ; if ( result < 0 ) { // found a better one, use this now solutions . data [ a . src ] = i ; scores . data [ a . src ] = a . fitScore ; } } else { // see if this new score is better than the current best AssociatedIndex currentBest = matches . get ( found ) ; int result = type . compareTo ( currentBest . fitScore , a . fitScore ) ; if ( result < 0 ) { // found a better one, use this now solutions . data [ a . src ] = i ; scores . data [ a . src ] = a . fitScore ; } else if ( result == 0 ) { // two solutions have the same score solutions . data [ a . src ] = - 2 ; } } } else { // no previous match found solutions . data [ a . src ] = i ; scores . data [ a . src ] = a . fitScore ; } } output . reset ( ) ; for ( int i = 0 ; i < numSource ; i ++ ) { int index = solutions . data [ i ] ; if ( index >= 0 ) { output . add ( matches . get ( index ) ) ; } } }
Selects a subset of matches that have at most one association for each source feature .