Skip to content

doubly linked list: add dataclass and typing #12647

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 15 commits into from
Apr 1, 2025
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix mypy errors
  • Loading branch information
isidroas committed Mar 31, 2025
commit d09b1823b5776854c1fd2dff927d43f6d3ea60b2
8 changes: 4 additions & 4 deletions data_structures/linked_list/doubly_linked_list_two.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ def insert_before_node(self, node: Node, node_to_insert: Node) -> None:
node_to_insert.next = node
node_to_insert.previous = node.previous

if node.get_previous() is None:
if not node.previous:
self.head = node_to_insert
else:
node.previous.next = node_to_insert
Expand All @@ -117,7 +117,7 @@ def insert_after_node(self, node: Node, node_to_insert: Node) -> None:
node_to_insert.previous = node
node_to_insert.next = node.next

if node.get_next() is None:
if node.next is None:
self.tail = node_to_insert
else:
node.next.previous = node_to_insert
Expand Down Expand Up @@ -156,10 +156,10 @@ def delete_value(self, value):

@staticmethod
def remove_node_pointers(node: Node) -> None:
if node.get_next():
if node.next:
node.next.previous = node.previous

if node.get_previous():
if node.previous:
node.previous.next = node.next

node.next = None
Expand Down