master > master: code go - vereinfachte logging

This commit is contained in:
RD
2021-11-04 11:06:16 +01:00
parent 701032a109
commit 552c3197e8
20 changed files with 235 additions and 235 deletions

View File

@@ -5,8 +5,6 @@ package binary
* ---------------------------------------------------------------- */
import (
"fmt"
"ads/internal/core/logging"
"ads/internal/core/metrics"
)
@@ -30,20 +28,20 @@ Outputs: Position von x in L, sonst 1 wenn x nicht in L.
*/
func BinarySearch(L []int, x int) int {
if len(L) == 0 {
logging.LogDebug(fmt.Sprintf("x nicht in L"))
logging.Debug("x nicht in L")
return -1
}
metrics.AddTimeCost()
m := int(len(L) / 2)
if L[m] == x {
logging.LogDebug(fmt.Sprintf("x in Position m gefunden"))
logging.Debug("x in Position m gefunden")
return m
} else if x < L[m] {
logging.LogDebug(fmt.Sprintf("Suche in linker Hälfte fortsetzen."))
logging.Debug("Suche in linker Hälfte fortsetzen.")
index := BinarySearch(L[:m], x)
return index
} else { // } else if x > L[m] {
logging.LogDebug(fmt.Sprintf("Suche in rechter Hälfte fortsetzen."))
logging.Debug("Suche in rechter Hälfte fortsetzen.")
index := BinarySearch(L[m+1:], x)
if index >= 0 {
index += (m + 1) // NOTE: muss Indexwert kompensieren