1package tests.persistent.map;
2
3import ds.persistent.map.BinaryTree;
4import ds.util.KV;
5import ds.util.K;
6
7import static ds.util.K.mkK;
8import static ds.util.V.mkV;
9import static ds.util.KV.mkPair;
10
11import tests.util.Args;
12
13public class BinaryTreeWorstCase {
14
15 public static void main(String [] args) {
16 int noOfElems = Args.getInt(args, 0, 1023);
17
18 (new Main(noOfElems)).run();
19 }
20
21 private static
22 class Main
23 extends tests.persistent.map.util.MainBinaryTree {
24
25 Main(int n1) {
26 super(n1);
27 }
28
29 protected void buildTree() {
30 startTime("building binary search tree by inserting " +
31 n +
32 " elements in ascending order (worst case)");
33 for (int i = 0; i < n; ++i) {
34 t = t.insert(mkK(i), mkV(i));
35 }
36 stopTime();
37 }
38
39 protected void removeAll() {
40 startTime("removing all elements in ascending order");
41
42 for (int i = 0; i < n; ++i) {
43 t = t.remove(mkK(i));
44 }
45 stopTime();
46 }
47 }
48}