MCPcopy
hub / github.com/Jack-Lee-Hiter/AlgorithmsByPython / Stack

Class Stack

Stack.py:3–21  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1# Python3.5
2# 定义一个栈类
3class Stack():
4 # 栈的初始化
5 def __init__(self):
6 self.items = []
7 # 判断栈是否为空,为空返回True
8 def isEmpty(self):
9 return self.items ==[]
10 # 向栈内压入一个元素
11 def push(self, item):
12 self.items.append(item)
13 # 从栈内推出最后一个元素
14 def pop(self):
15 return self.items.pop()
16 # 返回栈顶元素
17 def peek(self):
18 return self.items[len(self.items)-1]
19 # 判断栈的大小
20 def size(self):
21 return len(self.items)
22
23# 栈属性测试
24# 测试数据

Callers 6

buildParseTreeFunction · 0.90
revstringFunction · 0.85
parCheckerFunction · 0.85
Dec2BinFunction · 0.85
baseConverterFunction · 0.85
infixToPostfixFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected