public static < E > E argmax ( Counter < E > c ) { double max = Double . NEGATIVE_INFINITY ; E argmax = null ; for ( E key : c . keySet ( ) ) { double count = c . getCount ( key ) ; if ( argmax == null || count > max ) { // || (count == max && // tieBreaker.compare(key, argmax) < // 0)) { max = count ; argmax = key ; } } return argmax ; }
Finds and returns the key in the Counter with the largest count . Returning null if count is empty .