/** * Copyright (c): Uwe Schmidt, FH Wedel * * You may study, modify and distribute this source code * FOR NON-COMMERCIAL PURPOSES ONLY. * This copyright message has to remain unchanged. * * Note that this document is provided 'as is', * WITHOUT WARRANTY of any kind either expressed or implied. */ package tests.persistent.map; import ds.persistent.map.BinaryTree; import ds.util.KV; import ds.util.K; import static ds.util.K.mkK; import static ds.util.V.mkV; import static ds.util.KV.mkPair; import tests.util.Args; public class BinaryTreeWorstCase { public static void main(String [] args) { int noOfElems = Args.getInt(args, 0, 1023); (new Main(noOfElems)).run(); } private static class Main extends tests.persistent.map.util.MainBinaryTree { Main(int n1) { super(n1); } protected void buildTree() { startTime("building binary search tree by inserting " + n + " elements in ascending order (worst case)"); for (int i = 0; i < n; ++i) { t = t.insert(mkK(i), mkV(i)); } stopTime(); } protected void removeAll() { startTime("removing all elements in ascending order"); for (int i = 0; i < n; ++i) { t = t.remove(mkK(i)); } stopTime(); } } }