diff --git a/.gitignore b/.gitignore index 52b147513..32018e91e 100644 --- a/.gitignore +++ b/.gitignore @@ -58,3 +58,9 @@ __pycache__/ ################ .vscode/ .vs/ + +# Other Files # +################ +.idea/ +build/ +dist/ diff --git a/pydatastructs/linear_data_structures/linked_lists.py b/pydatastructs/linear_data_structures/linked_lists.py index 49159b3bf..dedc33e08 100644 --- a/pydatastructs/linear_data_structures/linked_lists.py +++ b/pydatastructs/linear_data_structures/linked_lists.py @@ -210,7 +210,7 @@ def pop_left(self): The leftmost element of linked list. """ - self.extract(0) + return self.extract(0) def pop_right(self): """ @@ -224,7 +224,7 @@ def pop_right(self): The leftmost element of linked list. """ - self.extract(-1) + return self.extract(-1) def extract(self, index): """ @@ -435,7 +435,7 @@ def pop_left(self): The leftmost element of linked list. """ - self.extract(0) + return self.extract(0) def pop_right(self): """ @@ -449,7 +449,7 @@ def pop_right(self): The leftmost element of linked list. """ - self.extract(-1) + return self.extract(-1) def extract(self, index): """ diff --git a/pydatastructs/linear_data_structures/tests/test_linked_lists.py b/pydatastructs/linear_data_structures/tests/test_linked_lists.py index a05bb338c..156dd8f44 100644 --- a/pydatastructs/linear_data_structures/tests/test_linked_lists.py +++ b/pydatastructs/linear_data_structures/tests/test_linked_lists.py @@ -17,8 +17,8 @@ def test_DoublyLinkedList(): dll.insert_at(0, 2) dll.insert_at(-1, 9) dll.extract(2) - dll.extract(0) - dll.extract(-1) + assert dll.pop_left().data == 2 + assert dll.pop_right().data == 4 dll[-2].data = 0 assert str(dll) == "[7, 5, 1, 6, 1, 0, 9]" assert len(dll) == 7 @@ -50,8 +50,8 @@ def test_SinglyLinkedList(): sll.insert_at(0, 2) sll.insert_at(-1, 9) sll.extract(2) - sll.extract(0) - sll.extract(-1) + assert sll.pop_left().data == 2 + assert sll.pop_right().data == 6 sll[-2].data = 0 assert str(sll) == "[2, 4, 1, 0, 9]" assert len(sll) == 5 @@ -83,8 +83,8 @@ def test_SinglyCircularLinkedList(): scll.insert_at(0, 2) scll.insert_at(-1, 9) scll.extract(2) - scll.extract(0) - scll.extract(-1) + assert scll.pop_left().data == 2 + assert scll.pop_right().data == 6 scll[-2].data = 0 assert str(scll) == "[2, 4, 1, 0, 9]" assert len(scll) == 5 @@ -118,8 +118,8 @@ def test_DoublyCircularLinkedList(): dcll.insert_at(0, 2) dcll.insert_at(-1, 9) dcll.extract(2) - dcll.extract(0) - dcll.extract(-1) + assert dcll.pop_left().data == 2 + assert dcll.pop_right().data == 4 dcll[-2].data = 0 assert str(dcll) == "[7, 5, 1, 6, 1, 0, 9]" assert len(dcll) == 7