A node holding data and its priority. Args: data: The stored value. priority: The priority of this node.
| 19 | |
| 20 | |
| 21 | class PriorityQueueNode: |
| 22 | """A node holding data and its priority. |
| 23 | |
| 24 | Args: |
| 25 | data: The stored value. |
| 26 | priority: The priority of this node. |
| 27 | """ |
| 28 | |
| 29 | def __init__(self, data: Any, priority: Any) -> None: |
| 30 | self.data = data |
| 31 | self.priority = priority |
| 32 | |
| 33 | def __repr__(self) -> str: |
| 34 | """Return a string representation of the node. |
| 35 | |
| 36 | Returns: |
| 37 | Formatted string with data and priority. |
| 38 | """ |
| 39 | return f"{self.data}: {self.priority}" |
| 40 | |
| 41 | |
| 42 | class PriorityQueue: |