data_structures.linked_list.circular_linked_list¶
Classes¶
Functions¶
|
Test cases for the CircularLinkedList class. |
Module Contents¶
- class data_structures.linked_list.circular_linked_list.CircularLinkedList¶
- __iter__() collections.abc.Iterator[Any] ¶
Iterate through all nodes in the Circular Linked List yielding their data. Yields:
The data of each node in the linked list.
- __len__() int ¶
Get the length (number of nodes) in the Circular Linked List.
- __repr__() str ¶
Generate a string representation of the Circular Linked List. Returns:
A string of the format “1->2->….->N”.
- delete_front() Any ¶
Delete and return the data of the node at the front of the Circular Linked List. Raises:
IndexError: If the list is empty.
- delete_nth(index: int = 0) Any ¶
Delete and return the data of the node at the nth pos in Circular Linked List. Args:
index (int): The index of the node to be deleted. Defaults to 0.
- Returns:
Any: The data of the deleted node.
- Raises:
IndexError: If the index is out of range.
- delete_tail() Any ¶
Delete and return the data of the node at the end of the Circular Linked List. Returns:
Any: The data of the deleted node.
- Raises:
IndexError: If the index is out of range.
- insert_head(data: Any) None ¶
Insert a node with the given data at the beginning of the Circular Linked List.
- insert_nth(index: int, data: Any) None ¶
Insert the data of the node at the nth pos in the Circular Linked List. Args:
index: The index at which the data should be inserted. data: The data to be inserted.
- Raises:
IndexError: If the index is out of range.
- insert_tail(data: Any) None ¶
Insert a node with the given data at the end of the Circular Linked List.
- is_empty() bool ¶
Check if the Circular Linked List is empty. Returns:
bool: True if the list is empty, False otherwise.
- data_structures.linked_list.circular_linked_list.test_circular_linked_list() None ¶
Test cases for the CircularLinkedList class. >>> test_circular_linked_list()