MCPcopy Create free account
hub / github.com/TheAlgorithms/Python / MyQueue

Class MyQueue

data_structures/binary_tree/avl_tree.py:16–40  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

14
15
16class 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
43class MyNode:

Callers 1

__str__Method · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected