Find an element in hash with minimum index value
int res_ind = Integer . MAX_VALUE , res = 0 ; for ( Map . Entry < Integer , Integer > x : hash . entrySet ( ) ) { if ( x . getValue ( ) < res_ind ) { res_ind = x . getValue ( ) ; res = x . getKey ( ) ; } } return res ; }