From 8a6e58b0ea6c595a9bc89b72febf108ba5a66725 Mon Sep 17 00:00:00 2001 From: brian Date: Tue, 13 Jul 2004 05:23:47 +0000 Subject: [PATCH] remove debugging info from BalancedTree darcs-hash:20040713052347-24bed-19f9eb2b591fa9efdc569f7736a68b42dd3b048c.gz --- src/org/ibex/util/BalancedTree.java | 62 ----------------------------------- 1 file changed, 62 deletions(-) diff --git a/src/org/ibex/util/BalancedTree.java b/src/org/ibex/util/BalancedTree.java index 24c474d..dd993a0 100644 --- a/src/org/ibex/util/BalancedTree.java +++ b/src/org/ibex/util/BalancedTree.java @@ -16,8 +16,6 @@ package org.ibex.util; /** a weight-balanced tree with fake leaves */ public class BalancedTree { - private static final boolean DEBUG = true; - // Instance Variables /////////////////////////////////////////////////////////////////// private int root = 0; ///< the slot of the root element @@ -49,7 +47,6 @@ public class BalancedTree { left[arg] = right[arg] = parent[arg] = 0; size[arg] = 1; } - if(DEBUG) check(); } } @@ -63,7 +60,6 @@ public class BalancedTree { if (index >= treeSize()) index = treeSize() - 1; int arg = allocateSlot(o); insert(index, arg, root, 0, true, false); - if(DEBUG) check(); } } @@ -127,7 +123,6 @@ public class BalancedTree { left[del] = right[del] = size[del] = parent[del] = 0; Object ret = objects[del]; objects[del] = null; - if(DEBUG) check(); return ret; } } @@ -144,7 +139,6 @@ public class BalancedTree { } while(i != 0); root = 0; } - if(DEBUG) check(); } // Node Data ///////////////////////////////////////////////////////////////////////// @@ -301,8 +295,6 @@ public class BalancedTree { if (size[arg] != 0) throw new Error("double insertion"); - if(DEBUG) check(); - // we are replacing an existing node if (replace) { if (diff != 0) throw new Error("this should never happen"); // since we already clamped the index @@ -318,7 +310,6 @@ public class BalancedTree { if(right[slot] != 0) parent[right[slot]] = arg; objects[slot] = null; left[slot] = right[slot] = size[slot] = parent[slot] = 0; - if(DEBUG) check(); // we become the child of a former leaf } else if (slot == 0) { @@ -333,7 +324,6 @@ public class BalancedTree { // we take the place of a preexisting node } else { - if(DEBUG) check(); left[arg] = left[slot]; // steal slot's left subtree left[slot] = 0; right[arg] = slot; // make slot our right subtree @@ -425,45 +415,6 @@ public class BalancedTree { protected void finalize() { clear(); } - // Debugging /////////////////////////////////////////////////////////////////////////// - - public void check() { check(false); } - public void check(boolean expensive) { - if(expensive) System.err.println("--> Running expensive balanced tree checks"); - try { - if(expensive) - for(int i=0;i 0) { - if(parent[left[node]] != node) throw new Error("parent node mismatch on left child of " + node); - check(left[node]); - } - if(right[node] > 0) { - if(parent[right[node]] != node) throw new Error("parent node mismatch on right child of " + node); - check(right[node]); - } - } - public void printTree() { if(root == 0) System.err.println("Tree is empty"); else printTree(root,0,false); @@ -479,17 +430,4 @@ public class BalancedTree { printTree(right[node],indent+1,false); } } - - /*public static void main(String[] args) { - BalancedTree t = new BalancedTree(); - for(int i=0;i