Data Structures in Typescript #6 - Linked List Implementation

preview_player
Показать описание

Рекомендации по теме
Комментарии
Автор

RE: "a better way to null check" @ 14:00 -- basically just a simple if statement worked well for me. 
I only renamed the variables a tiny bit, otherwise it should be equivalent. Loving this series btw. Very helpful.

findIndexOfValue(value: T, equalsFn?: EqualsFunction<T>): number {
if (!this.#list) {
return -1;
}

const isEqual = equalsFn || getIsEqual;

let traversalIndex = 0;
let currentNode = this.#list.head;

while (!isEqual(currentNode.value, value)) {
if (currentNode.next) {
currentNode = currentNode.next;
traversalIndex += 1;
}
}

return traversalIndex;
}

benw.
Автор

At 5:37, isn't it supposed to be i == this.size() - 1 ?
and if it should be i == this.size(), why at 6:04 you check if i greater than or *equals* to this.size() and not just greater than?

eyalovadya
Автор

@15:24 why did you implement a ternary operation while the contains method already accepts the same parameter as indexOf?

uguremirmustafaoglu
Автор

Hey Jeff, just wanted to thank you for the great video. Very clear implementation of the linked list. Look forward to watch your video in implementing a stack with the linked list.

Freeman
Автор

I think indexOf’s while loop needs boundary check. It will throws error after tail because next will be undefined

umutaktas
Автор

great job and explanation, I have one more thing to tell you... I can't find how to tell TS about cur = cur.next!; in a better way than that :( hahaha cheers!

FOLKENT
join shbcf.ru