From 0d25be66c32360cefc212193532f423c5112ede1 Mon Sep 17 00:00:00 2001 From: Saetch Date: Sat, 29 Jun 2024 17:08:33 +0200 Subject: [PATCH] more debug --- Cluster/Node_cs/NodeBehavior.cs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/Cluster/Node_cs/NodeBehavior.cs b/Cluster/Node_cs/NodeBehavior.cs index b7984cd..fc8a880 100644 --- a/Cluster/Node_cs/NodeBehavior.cs +++ b/Cluster/Node_cs/NodeBehavior.cs @@ -139,14 +139,17 @@ private static int BinarySearchFittingNode(List hashValues, int ai int index = len/2; int upperBound = len -1; int lowerBound = 0; - int toPrint = 5; + int toPrint = 6; Console.WriteLine("Binary searching for NodeResponses: "); foreach (NodeResponse node in hashValues){ Console.WriteLine(node.name + " " + node.hash); } Console.WriteLine("Trying to find node for hashValue: "+aimedValue); while (true){ - Console.WriteLine("Current index: "+index); + if (toPrint > 0){ + Console.WriteLine("Current index: "+index); + toPrint--; + } int currentValue = hashValues[index].hash; int nextValue = hashValues[index + 1].hash; if (aimedValue > currentValue && aimedValue <= nextValue){ @@ -157,14 +160,12 @@ private static int BinarySearchFittingNode(List hashValues, int ai lowerBound = index+1; if (toPrint > 0){ Console.WriteLine("Increasing lowerBound to: "+lowerBound); - toPrint--; } index += (upperBound - index)/2; }else{ upperBound = index -1; if (toPrint > 0){ Console.WriteLine("Decreasing upperBound to: "+upperBound); - toPrint--; } index -= Math.Max(1,(index - lowerBound)/2); }