Browse Source

kommentare

master
elif.efe 6 months ago
parent
commit
70fc2385e9
  1. 17
      SparseVector.java

17
SparseVector.java

@ -12,7 +12,6 @@ public class SparseVector {
}
}
// Standard Konstruktor mit einem leeren Vektor initialisieren
private Node head = null;
private int length = 0;
@ -28,7 +27,7 @@ public class SparseVector {
this.head = null;
this.length = n;
}
// die den Wert value an der Stelle index in den Vektor einfugt.
/* den value in index hinzufügen
- Aktualiiseren des Wertes, wenn der head an dem Index mit einem Wert exisitiert
- Neuer head mit neuem Wert hinzufügen, wenn der head an dem Index nicht existiert
@ -62,7 +61,7 @@ public class SparseVector {
}
// Eine Methode double getElement(int index) das den Wert des durch index definierten Eintrags wiedergibt (oder 0.0, falls der Eintrag an dieser Stelle nicht existiert).
/* getElement: return the Wert value of that index
input das Index, und return den entsprechenden Wert des Index
*/
@ -114,18 +113,17 @@ public class SparseVector {
if (now != null && now.index == index) {
pre.next = now.next;
// System.out.println("index " + index + " found and the value " + now.value + " deleted.");
System.out.println("index " + index + " found and the value " + now.value + " deleted.");
} else {
// System.out.println("Element not found with index " + index);
System.out.println("Element not found with index " + index);
}
}
// Länge des Vektors ausgeben
public int getLength() {
int length = SparseVector.this.length;
@ -134,8 +132,8 @@ public class SparseVector {
}
// bool Methode equals: testen, ob other = this (nur vergleichen die Nicht-Null Elemente)
// die testet, ob der übergebene SparseVector other mit der aktuellen Instanz identisch ist.
// testen, ob other = this (nur vergleichen die Nicht-Null Elemente)
public boolean equals(SparseVector other) {
@ -163,8 +161,7 @@ public class SparseVector {
return true;
}
// void add: to add two vectors together and renew (overwrite) the this.vector
// die alle Einträge aus dem Vektor other auf die aktuelle Repräsentation addiert
public void add(SparseVector other) {
Node thisnow = this.head;

Loading…
Cancel
Save