-
Notifications
You must be signed in to change notification settings - Fork 1
Node
Pritam Kundu edited this page Aug 3, 2023
·
8 revisions
- A node is a fundamental data block which for storage.
- It is a self-referential data structures which uses pointer internally to reference its next item.
- Used with data-structures like Lists, preferably LinkedLists
- It is a basic unit block and can hold any data type along with a reference to its next Node.
from datastax.Nodes import Node
class Node(AbstractNode):
data: Any
def __init__(self, data: Any, _next: Optional[Self] = None) -> None: ...
def set_next(self, _next: Optional[Self]): ...
- Takes 1 required parameter data of Any type
- Takes 1 optional parameter _next of Node type to reference next node
Node(10) # ✅
Node(None) # ✅
Node("string") # ✅
Node(10, None) # ✅
Node(None, None) # ✅
Node(10, Node(20)) # ✅
Node(data=10, _next=Node(20)) # ✅
Node(10, _next=None) # ✅
Node(_next=None, data=10) # ✅
Node() # ❌ TypeError: Node missing 1 required positional argument: 'data'
Node(10, 20) # ❌ TypeError: The 'next' parameter must be an instance of Node
Node(_next=10) # ❌ TypeError: Node missing 1 required positional argument: 'data'
- 1. Home
- 2. Arrays
- 3. Nodes
- 4. Lists
- 5. Trees
- 6. Tables