mirror of
https://github.com/TheAlgorithms/JavaScript.git
synced 2026-03-13 15:21:15 +08:00
Refactored code to improve performance of some methods (#1284)
* refactored code to improve perfomance * added 'check tail' test * corrected styling and spelling mistake
This commit is contained in:
@@ -150,6 +150,20 @@ describe('SinglyLinkedList', () => {
|
||||
expect(list.head()).toBe(30)
|
||||
})
|
||||
|
||||
it('Check tail', () => {
|
||||
const list = new LinkedList()
|
||||
expect(list.tail()).toBe(null)
|
||||
|
||||
list.addLast(10)
|
||||
expect(list.tail()).toBe(10)
|
||||
|
||||
list.addLast(20)
|
||||
expect(list.tail()).toBe(20)
|
||||
|
||||
list.addFirst(30)
|
||||
expect(list.tail()).toBe(20)
|
||||
})
|
||||
|
||||
it('Check size', () => {
|
||||
const list = new LinkedList()
|
||||
expect(list.size()).toBe(0)
|
||||
|
||||
Reference in New Issue
Block a user