From 2e8d4efb96e544336fa3429c22cf2db7c1556239 Mon Sep 17 00:00:00 2001 From: "paul-anton.engel@informatik.hs-fulda.de" Date: Wed, 22 Nov 2023 16:39:29 +0100 Subject: [PATCH] =?UTF-8?q?Paul:=20=C3=9Cberarbeitung=20getElement?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- SparseVector.java | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/SparseVector.java b/SparseVector.java index 632d1e2..8ed337b 100644 --- a/SparseVector.java +++ b/SparseVector.java @@ -69,16 +69,13 @@ public class SparseVector { Node now = this.head; while (now != null && now.index < index) { - + if (now != null && now.index == index) { + return now.value; + } now = now.next; } - if (now != null && now.index == index) { - double result = now.value; - - return result; - } return 0.0; }