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

Method put

data_structures/queues/queue_by_two_stacks.py:59–72  ·  view source on GitHub ↗

Put `item` into the Queue >>> queue = QueueByTwoStacks() >>> queue.put(10) >>> queue.put(20) >>> len(queue) 2 >>> queue Queue((10, 20))

(self, item: T)

Source from the content-addressed store, hash-verified

57 return f"Queue({tuple(self._stack2[::-1] + self._stack1)})"
58
59 def put(self, item: T) -> None:
60 """
61 Put `item` into the Queue
62
63 >>> queue = QueueByTwoStacks()
64 >>> queue.put(10)
65 >>> queue.put(20)
66 >>> len(queue)
67 2
68 >>> queue
69 Queue((10, 20))
70 """
71
72 self._stack1.append(item)
73
74 def get(self) -> T:
75 """

Callers

nothing calls this directly

Calls 1

appendMethod · 0.45

Tested by

no test coverage detected