| 14 | |
| 15 | |
| 16 | class MyQueue: |
| 17 | def __init__(self) -> None: |
| 18 | self.data: list[Any] = [] |
| 19 | self.head: int = 0 |
| 20 | self.tail: int = 0 |
| 21 | |
| 22 | def is_empty(self) -> bool: |
| 23 | return self.head == self.tail |
| 24 | |
| 25 | def push(self, data: Any) -> None: |
| 26 | self.data.append(data) |
| 27 | self.tail = self.tail + 1 |
| 28 | |
| 29 | def pop(self) -> Any: |
| 30 | ret = self.data[self.head] |
| 31 | self.head = self.head + 1 |
| 32 | return ret |
| 33 | |
| 34 | def count(self) -> int: |
| 35 | return self.tail - self.head |
| 36 | |
| 37 | def print_queue(self) -> None: |
| 38 | print(self.data) |
| 39 | print("**************") |
| 40 | print(self.data[self.head : self.tail]) |
| 41 | |
| 42 | |
| 43 | class MyNode: |