private void pruneTracks ( SetTrackInfo < Desc > info , GrowQueue_I32 unassociated ) { if ( unassociated . size > maxInactiveTracks ) { // make the first N elements the ones which will be dropped int numDrop = unassociated . size - maxInactiveTracks ; for ( int i = 0 ; i < numDrop ; i ++ ) { int selected = rand . nextInt ( unassociated . size - i ) + i ; int a = unassociated . get ( i ) ; unassociated . data [ i ] = unassociated . data [ selected ] ; unassociated . data [ selected ] = a ; } List < PointTrack > dropList = new ArrayList <> ( ) ; for ( int i = 0 ; i < numDrop ; i ++ ) { dropList . add ( info . tracks . get ( unassociated . get ( i ) ) ) ; } for ( int i = 0 ; i < dropList . size ( ) ; i ++ ) { dropTrack ( dropList . get ( i ) ) ; } } }
If there are too many unassociated tracks randomly select some of those tracks and drop them