12 |
|
* can create one from a real dictionary (1 line per word) and then run |
13 |
|
* linux "shuf" to randomize entries. |
14 |
|
*/ |
15 |
– |
import java.util.*; |
15 |
|
import java.io.*; |
16 |
+ |
import java.util.*; |
17 |
|
|
18 |
|
public class MapCheck { |
19 |
|
static final Object MISSING = new Object(); |
20 |
|
static TestTimer timer = new TestTimer(); |
21 |
< |
static Class eclass; |
22 |
< |
static Class mapClass = java.util.concurrent.ConcurrentHashMap.class; |
21 |
> |
static Class<?> eclass; |
22 |
> |
static Class<?> mapClass = java.util.concurrent.ConcurrentHashMap.class; |
23 |
|
|
24 |
|
static final LoopHelpers.SimpleRandom srng = new LoopHelpers.SimpleRandom(); |
25 |
|
static final Random rng = new Random(3152688); |
143 |
|
if (m.get(null) != null) throw new Error(); |
144 |
|
} |
145 |
|
|
146 |
– |
|
146 |
|
static void getTest(String nm, int n, Map s, Object[] key, int expect) { |
147 |
|
int sum = 0; |
148 |
|
timer.start(nm, n); |
156 |
|
checkSum += sum; |
157 |
|
} |
158 |
|
|
160 |
– |
|
159 |
|
// unused |
160 |
|
static void getTestBoxed(String nm, int n, Map s, Object[] key, int expect) { |
161 |
|
int sum = 0; |
242 |
|
checkSum += sum; |
243 |
|
} |
244 |
|
|
247 |
– |
|
245 |
|
static Object kitTest(Map s, int size) { |
246 |
|
Object last = null; |
247 |
|
int sum = 0; |
508 |
|
reallyAssert(s.size() == size); |
509 |
|
} |
510 |
|
|
514 |
– |
|
515 |
– |
|
511 |
|
static void initializeKeys(Object[] key, Object[] absent, int size) { |
512 |
|
if (eclass == Object.class) { |
513 |
|
for (int i = 0; i < size; ++i) key[i] = new Object(); |
616 |
|
} |
617 |
|
} |
618 |
|
|
624 |
– |
|
619 |
|
static void randomWords(Object[] ws, int origin, int size) { |
620 |
|
for (int i = origin; i < size; ++i) { |
621 |
|
int k = 0; |
696 |
|
} |
697 |
|
} |
698 |
|
|
705 |
– |
|
699 |
|
static void shuffle(Object[] keys) { |
700 |
|
int size = keys.length; |
701 |
< |
for (int i= size; i>1; i--) { |
701 |
> |
for (int i = size; i > 1; i--) { |
702 |
|
int r = rng.nextInt(i); |
703 |
|
Object t = keys[i-1]; |
704 |
|
keys[i-1] = keys[r]; |
708 |
|
|
709 |
|
static void shuffle(ArrayList keys) { |
710 |
|
int size = keys.size(); |
711 |
< |
for (int i= size; i>1; i--) { |
711 |
> |
for (int i = size; i > 1; i--) { |
712 |
|
int r = rng.nextInt(i); |
713 |
|
Object t = keys.get(i-1); |
714 |
|
keys.set(i-1, keys.get(r)); |