1 package com.cliffc.aa.util;
3 import java.util.concurrent.ConcurrentMap;
6 public static int find(
int[] es,
int e ) {
7 for(
int i=0; i<es.length; i++ )
if( es[i]==e )
return i;
10 public static <E>
int find( E[] es, E e ) {
11 for(
int i=0; i<es.length; i++ )
if( es[i]==e )
return i;
16 public static boolean eq( String s0, String s1 ) {
17 if( s0==s1 )
return true;
18 if( s0==
null || s1==
null )
return false;
19 assert !s0.equals(s1) :
"Not interned: "+s0;
25 if( (map.size() & ((1L<<16)-1)) == 0 )
31 for( Object k : map.keySet() ) {
32 int hash = k.hashCode();
33 Integer ii = hashs.
get(hash);
34 hashs.
put(hash,ii==
null ? 1 : ii+1);
36 int[] hist =
new int[16];
39 for(
long l : hashs.
keySet() ) {
40 int reps = hashs.
get(l);
41 if( reps > maxval ) { maxval=reps; maxkey=l; }
42 if( reps < hist.length ) hist[reps]++;
43 else System.out.println(
"hash "+l+
" repeats "+reps);
45 for(
int i=0; i<hist.length; i++ )
47 System.out.println(
"Number of hashes with "+i+
" repeats: "+hist[i]);
48 System.out.println(
"Max repeat key "+maxkey+
" repeats: "+maxval);