MCPcopy
hub / github.com/keon/algorithms / push

Method push

algorithms/data_structures/stack.py:85–94  ·  view source on GitHub ↗

Push a value onto the stack. Args: value: The value to push.

(self, value: object)

Source from the content-addressed store, hash-verified

83 probe -= 1
84
85 def push(self, value: object) -> None:
86 """Push a value onto the stack.
87
88 Args:
89 value: The value to push.
90 """
91 self._top += 1
92 if self._top == len(self._array):
93 self._expand()
94 self._array[self._top] = value
95
96 def pop(self) -> object:
97 """Remove and return the top element.

Callers 1

test_array_stackMethod · 0.95

Calls 1

_expandMethod · 0.95

Tested by 1

test_array_stackMethod · 0.76