@@ -565,13 +565,13 @@ export class ObjectLinkedList<T extends LinkedListComparator<T>> {
565565
566566 // special case for head
567567 if ( this . _head . value . equals ( lookup ) ) {
568- const value = this . _head . value ;
568+ const oldValue = this . _head . value ;
569569 this . _head = this . _head . next ;
570570 if ( ! this . _head ) {
571571 this . _tail = null ;
572572 }
573573 this . _size -- ;
574- return value ;
574+ return oldValue ;
575575 }
576576
577577 // iterate currNode.next to index
@@ -646,12 +646,12 @@ export class ObjectLinkedList<T extends LinkedListComparator<T>> {
646646
647647 // special case for head
648648 if ( index === 0 ) {
649- const value = this . _head . value ;
649+ const oldHeadValue = this . _head . value ;
650650 this . _head = this . _head . next ;
651651 if ( ! this . _head ) {
652652 this . _tail = null ;
653653 }
654- return value ;
654+ return oldHeadValue ;
655655 }
656656
657657 // iterate currNode.next to index
@@ -661,13 +661,13 @@ export class ObjectLinkedList<T extends LinkedListComparator<T>> {
661661 }
662662
663663 // currNode.next should be removed
664- const value = currNode ! . next ! . value ;
664+ const oldValue = currNode ! . next ! . value ;
665665 if ( ! currNode ! . next ! . next ) {
666666 this . _tail = currNode ;
667667 }
668668 currNode ! . next = currNode ! . next ! . next ;
669669 this . _size -- ;
670- return value ;
670+ return oldValue ;
671671 }
672672
673673 /**
@@ -845,7 +845,7 @@ export class ObjectLinkedList<T extends LinkedListComparator<T>> {
845845 * @param size Amount of nodes that should remain linked to head.
846846 * @returns New head of the second part of the split linked list.
847847 */
848- function split < T > ( head : LinkedListNode < T > | null , size : number ) : LinkedListNode < T > | null {
848+ function split < U > ( head : LinkedListNode < U > | null , size : number ) : LinkedListNode < U > | null {
849849 let cur = head ;
850850 for ( let i = 1 ; cur && i < size ; i ++ ) {
851851 cur = cur . next ;
@@ -864,11 +864,11 @@ export class ObjectLinkedList<T extends LinkedListComparator<T>> {
864864 * @param compare Comparison function.
865865 * @returns Head and tail of the new merged list.
866866 */
867- function merge < T > ( a : LinkedListNode < T > | null , b : LinkedListNode < T > | null , compare : ( x : T , y : T ) => number ) : { head : LinkedListNode < T > | null ; tail : LinkedListNode < T > | null } {
867+ function merge < U > ( a : LinkedListNode < U > | null , b : LinkedListNode < U > | null , compare : ( x : U , y : U ) => number ) : { head : LinkedListNode < U > | null ; tail : LinkedListNode < U > | null } {
868868 // create new merged list
869- let head : LinkedListNode < T > | null = null ;
870- let tail : LinkedListNode < T > | null = null ;
871- const append = ( node : LinkedListNode < T > ) => {
869+ let head : LinkedListNode < U > | null = null ;
870+ let tail : LinkedListNode < U > | null = null ;
871+ const append = ( node : LinkedListNode < U > ) => {
872872 node . next = null ;
873873 if ( tail ) tail . next = node ;
874874 else head = node ;
@@ -1012,7 +1012,7 @@ export class ObjectLinkedList<T extends LinkedListComparator<T>> {
10121012 * @return Array containing all values in the linked list.
10131013 */
10141014 public toArray ( ) : T [ ] {
1015- const arr : Array < T > = new Array < T > ( this . _size ) ;
1015+ const arr : T [ ] = new Array < T > ( this . _size ) ;
10161016 let currNode = this . _head ;
10171017 for ( let i = 0 ; i < this . _size ; i ++ ) {
10181018 arr [ i ] = currNode ! . value ;
0 commit comments