本文整理汇总了Python中pythonds.basic.stack.Stack.size方法的典型用法代码示例。如果您正苦于以下问题:Python Stack.size方法的具体用法?Python Stack.size怎么用?Python Stack.size使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pythonds.basic.stack.Stack
的用法示例。
在下文中一共展示了Stack.size方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: moveTower
# 需要导入模块: from pythonds.basic.stack import Stack [as 别名]
# 或者: from pythonds.basic.stack.Stack import size [as 别名]
def moveTower(height,fromPole, toPole, withPole):
fromPole = Stack()
toPole = Stack()
withPole = Stack()
for i in range(height):
fromPole.push(i)
if fromPole.size() == 1:
Disk = fromPole.pop()
toPole.push(Disk)
else:
moveTower(height-1, fromPole, toPole, withPole)
print fromPole, toPole, withPole
示例2: Stack
# 需要导入模块: from pythonds.basic.stack import Stack [as 别名]
# 或者: from pythonds.basic.stack.Stack import size [as 别名]
from pythonds.basic.stack import Stack
s = Stack()
s.push(33)
print(s.size())
开发者ID:ErikRHanson,项目名称:Problem-Solving-with-Algorithms-and-Data-Structures-Using-Python,代码行数:8,代码来源:stacktest.py
示例3: Stack
# 需要导入模块: from pythonds.basic.stack import Stack [as 别名]
# 或者: from pythonds.basic.stack.Stack import size [as 别名]
from pythonds.basic.stack import Stack
s = Stack()
assert(s.isEmpty())
s.push(4)
s.push('dog')
assert(s.peek() is 'dog')
s.push(True)
assert(s.size() is 3)
assert(s.isEmpty() is False)
s.push(8.4)
assert(s.pop() is 8.4)
assert(s.pop() is True)
assert(s.size() is 2)