MCPcopy Index your code
hub / github.com/TheAlgorithms/Python / size

Method size

data_structures/stacks/stack.py:123–142  ·  view source on GitHub ↗

Return the size of the stack. >>> S = Stack(3) >>> S.size() 0 >>> S = Stack(3) >>> S.push(10) >>> S.size() 1 >>> S = Stack(3) >>> S.push(10) >>> S.push(20) >>> S.size() 2

(self)

Source from the content-addressed store, hash-verified

121 return self.size() == self.limit
122
123 def size(self) -> int:
124 """
125 Return the size of the stack.
126
127 >>> S = Stack(3)
128 >>> S.size()
129 0
130
131 >>> S = Stack(3)
132 >>> S.push(10)
133 >>> S.size()
134 1
135
136 >>> S = Stack(3)
137 >>> S.push(10)
138 >>> S.push(20)
139 >>> S.size()
140 2
141 """
142 return len(self.stack)
143
144 def __contains__(self, item: T) -> bool:
145 """

Callers 3

is_fullMethod · 0.95
test_stackFunction · 0.95
_maybe_downloadFunction · 0.45

Calls

no outgoing calls

Tested by 1

test_stackFunction · 0.76