private void countKey ( Map < String , Integer > map , String key , int count ) { if ( map . containsKey ( key ) ) { map . put ( key , map . get ( key ) + count ) ; } else { map . put ( key , count ) ; } }
Helper method that stores in a hash map how often a certain key occurs . If the key has not been encountered yet a new entry is created for it in the map . Otherwise the existing value for the key is incremented .