File tree Expand file tree Collapse file tree
data_structures/binary_tree Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1414from __future__ import annotations
1515
1616from collections .abc import Iterator
17+ from dataclasses import dataclass , field
1718
1819
20+ @dataclass
1921class Node :
20- """A single node of a splay tree."""
22+ """
23+ A single node of a splay tree.
24+
25+ The ``left`` and ``right`` children are excluded from ``repr`` so that a
26+ node prints compactly instead of recursively dumping the whole subtree.
2127
22- def __init__ (self , key : int ) -> None :
23- self .key = key
24- self .left : Node | None = None
25- self .right : Node | None = None
28+ >>> Node(10)
29+ Node(key=10)
30+ """
2631
27- def __repr__ (self ) -> str :
28- return f"Node({ self .key } )"
32+ key : int
33+ left : Node | None = field (default = None , repr = False )
34+ right : Node | None = field (default = None , repr = False )
2935
3036
3137class SplayTree :
You can’t perform that action at this time.
0 commit comments