Skip to content

Commit e272b9d

Browse files
Add typing to data_structures/queue/queue_on_pseudo_stack.py (TheAlgorithms#7037)
* Add typing hacktoberfest * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent aeb933b commit e272b9d

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

data_structures/queue/queue_on_pseudo_stack.py

+6-5
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Queue represented by a pseudo stack (represented by a list with pop and append)"""
2+
from typing import Any
23

34

45
class Queue:
@@ -14,7 +15,7 @@ def __str__(self):
1415
@param item
1516
item to enqueue"""
1617

17-
def put(self, item):
18+
def put(self, item: Any) -> None:
1819
self.stack.append(item)
1920
self.length = self.length + 1
2021

@@ -23,7 +24,7 @@ def put(self, item):
2324
@return dequeued
2425
item that was dequeued"""
2526

26-
def get(self):
27+
def get(self) -> Any:
2728
self.rotate(1)
2829
dequeued = self.stack[self.length - 1]
2930
self.stack = self.stack[:-1]
@@ -35,7 +36,7 @@ def get(self):
3536
@param rotation
3637
number of times to rotate queue"""
3738

38-
def rotate(self, rotation):
39+
def rotate(self, rotation: int) -> None:
3940
for i in range(rotation):
4041
temp = self.stack[0]
4142
self.stack = self.stack[1:]
@@ -45,13 +46,13 @@ def rotate(self, rotation):
4546
"""Reports item at the front of self
4647
@return item at front of self.stack"""
4748

48-
def front(self):
49+
def front(self) -> Any:
4950
front = self.get()
5051
self.put(front)
5152
self.rotate(self.length - 1)
5253
return front
5354

5455
"""Returns the length of this.stack"""
5556

56-
def size(self):
57+
def size(self) -> int:
5758
return self.length

0 commit comments

Comments
 (0)