Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make it possible to add objects to LinkedList.
- Loading branch information
Showing
10 changed files
with
204 additions
and
189 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,10 @@ | ||
export default class LinkedListNode { | ||
constructor({ value, next = null, key = null }) { | ||
constructor(value, next = null) { | ||
this.value = value; | ||
this.next = next; | ||
|
||
// Key is added to make this linked list nodes to be reusable in hash tables. | ||
this.key = key; | ||
} | ||
|
||
toString() { | ||
if (this.key) { | ||
return `${this.key}:${this.value}`; | ||
} | ||
|
||
return `${this.value}`; | ||
toString(callback) { | ||
return callback ? callback(this.value) : `${this.value}`; | ||
} | ||
} |
Oops, something went wrong.