data_structures.linked_list.circular_linked_list ================================================ .. py:module:: data_structures.linked_list.circular_linked_list Classes ------- .. autoapisummary:: data_structures.linked_list.circular_linked_list.CircularLinkedList data_structures.linked_list.circular_linked_list.Node Functions --------- .. autoapisummary:: data_structures.linked_list.circular_linked_list.test_circular_linked_list Module Contents --------------- .. py:class:: CircularLinkedList .. py:method:: __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. .. py:method:: __len__() -> int Get the length (number of nodes) in the Circular Linked List. .. py:method:: __repr__() -> str Generate a string representation of the Circular Linked List. Returns: A string of the format "1->2->....->N". .. py:method:: 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. .. py:method:: 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. .. py:method:: 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. .. py:method:: insert_head(data: Any) -> None Insert a node with the given data at the beginning of the Circular Linked List. .. py:method:: 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. .. py:method:: insert_tail(data: Any) -> None Insert a node with the given data at the end of the Circular Linked List. .. py:method:: is_empty() -> bool Check if the Circular Linked List is empty. Returns: bool: True if the list is empty, False otherwise. .. py:attribute:: head :type: Node | None :value: None .. py:attribute:: tail :type: Node | None :value: None .. py:class:: Node .. py:attribute:: data :type: Any .. py:attribute:: next_node :type: Node | None :value: None .. py:function:: test_circular_linked_list() -> None Test cases for the CircularLinkedList class. >>> test_circular_linked_list()