src.pydasa.structs.lists.ndlt ============================= .. py:module:: src.pydasa.structs.lists.ndlt .. autoapi-nested-parse:: Module ndlt.py =========================================== Module to represent the **Node** data structure for the **Linked List** and **Doubly Linked List** in *PyDASA*. Classes: **Node**: Base class for creating Single Linked List Node or **SLNode** and Double Linked List Node or **DLNode**. **SLNode**: Implements a single linked list node with data and next node reference. **DLNode**: Implements a double linked list node with data, next node, and previous node references. *IMPORTANT:* based on the implementations proposed by the following authors/books: # . Algorithms, 4th Edition, Robert Sedgewick and Kevin Wayne. # . Data Structure and Algorithms in Python, M.T. Goodrich, R. Tamassia, M.H. Goldwasser. Classes ------- .. autoapisummary:: src.pydasa.structs.lists.ndlt.Node src.pydasa.structs.lists.ndlt.SLNode src.pydasa.structs.lists.ndlt.DLNode Module Contents --------------- .. py:class:: Node Bases: :py:obj:`Generic`\ [\ :py:obj:`pydasa.structs.types.generics.T`\ ] **Node** base class for creating Single Linked List Node or **SLNode** and Double Linked List Node or **DLNode**. Fundamental for the **Linked List** and **Doubly Linked List** data structures. :param Generic: Generic type for a Python data structure. :type Generic: T :returns: A node object with the following attributes: - `_data`: The data stored in the node. :rtype: Node .. py:property:: data :type: pydasa.structs.types.generics.T *data* Property to read the data in the *Node*. Acts as a getter (*get()*) for the *_data* attribute. :returns: data stored in the *Node*. :rtype: T .. py:method:: __str__() *__str__()* function to return a string representation of the *Node*. It also extendes for the *SLNode* and *DLNode* classes. :returns: string representation of the *Node*. :rtype: str .. py:method:: __repr__() *__repr__()* function to return a string representation of the *Node*. It also extendes for the *SLNode* and *DLNode* classes. :returns: string representation of the *Node*. :rtype: str .. py:class:: SLNode Bases: :py:obj:`Node`\ [\ :py:obj:`pydasa.structs.types.generics.T`\ ] **SLNode** class for creating a Single Linked List Node. Inherits from the **Node** class. Fundamental for the **Linked List** data structure. :param Node: **Node** base class for creating single and double linked nodes. :type Node: dataclass :param Generic: Generic type for a Python data structure. :type Generic: T :returns: A single linked node object with the following attributes: - `_data`: The data stored in the node. - `_next`: The next node of the same type. :rtype: SLNode .. py:property:: next :type: Optional[SLNode[T]] "*next()* Property to read the next node in the list. Acts as a getter (*get()*) for the *_next* attribute. :returns: reference to the next node of the list. If there is no next node, it returns None. :rtype: Optional["SLNode[T]"] .. py:method:: __str__() *__str__()* function to return a string representation of the *SLNode*. It also extends the *Node* class. :returns: string representation of the *SLNode*. :rtype: str .. py:method:: __repr__() *__repr__()* function to return a string representation of the *SLNode*. It also extends the *Node* class. :returns: string representation of the *SLNode*. :rtype: str .. py:class:: DLNode Bases: :py:obj:`SLNode`\ [\ :py:obj:`pydasa.structs.types.generics.T`\ ] **DLNode** class for creating a Double Linked List Node. Inherits from the **SLNode** class. Fundamental for the **Doubly Linked List** data structure. :param SLNode: **SLNode** class for creating a single linked list node. :type SLNode: dataclass :param Generic: Generic type for a Python data structure. :type Generic: T :returns: A double linked node object with the following attributes: - `_data`: The data stored in the node. - `_next`: The next node of the same type. - `_prev`: The previous node of the same type. :rtype: DLNode .. py:property:: prev :type: Optional[DLNode[T]] *prev()* Property to read the previous node in the list. Acts as a getter (*get()*) for the *_prev* attribute. :returns: reference to the previous node of the list. :rtype: node (Optional["DLNode[T]"]) .. py:method:: __str__() *__str__()* function to return a string representation of the *DLNode*. It also extends the *Node* class. :returns: string representation of the *DLNode*. :rtype: str .. py:method:: __repr__() *__repr__()* function to return a string representation of the *DLNode*. It also extends the *Node* class. :returns: string representation of the *DLNode*. :rtype: str