| eingeben | |
| Ausgaben | - |
| einfügen | |
| entfernen | |
| suchen |
Listenansicht
List in list.js
class List {
#next;
#content;
constructor(content, next = null) {
this.content = content;
this.next = next;
}
append(content) {
if (this.next == null) {
this.next = new List(content);
} else {
this.next.append(content);
}
}
insert(content) {
this.next = new List(this.content, this.next);
this.content = content;
}
getLength() {
try {
return 1 + this.next.getLength();
} catch (e) {
return 1;
}
}
toString() {
try {
return this.content + " -> " + this.next.toString();
} catch (e) {
return this.content;
}
}
}