本文整理汇总了Python中LinkedList.LinkedList.clear方法的典型用法代码示例。如果您正苦于以下问题:Python LinkedList.clear方法的具体用法?Python LinkedList.clear怎么用?Python LinkedList.clear使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LinkedList.LinkedList
的用法示例。
在下文中一共展示了LinkedList.clear方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: LLQueue
# 需要导入模块: from LinkedList import LinkedList [as 别名]
# 或者: from LinkedList.LinkedList import clear [as 别名]
class LLQueue(object):
def __init__(self, size=0):
self._list = LinkedList()
self._size = size
def enqueue(self, data):
if (self._size > 0 and self._list.count < self._size):
self._list.add(data)
else:
raise Exception("Too many items in the queue")
def dequeue(self):
if (self._list.count == 0):
raise Exception("No items in the queue")
node = self._list[0]
del self._list[0]
return node
def isEmpty(self):
return (self._list.count == 0)
def clear(self):
self._list.clear()
@property
def size(self):
return self._size
def __len__(self):
return len(self._list)
示例2: comment
# 需要导入模块: from LinkedList import LinkedList [as 别名]
# 或者: from LinkedList.LinkedList import clear [as 别名]
comment("OK -> " + test_name)
grade(points['ll_1e_remove'])
except:
e = sys.exc_info()[1]
comment("FAIL -> " + test_name + "\n" + str(e))
grade(0)
# Check one element list - clear()
try:
test_name = 'LinkedList con un elemento: clear()'
l = LinkedList()
l.insertAfter(17)
l.clear()
if l.head != None or l.tail != None or l.current != None:
comment("FAIL -> " + test_name +"\n clear() no actualiza correctamente head, tail o current")
grade(0)
else:
if l.size != 0:
comment("FAIL -> " + test_name +"\nclear() no actualiza correctamente el size de la lista")
grade(0)
else:
comment("OK -> " + test_name)
grade(points['ll_1e_clear'])
except:
e = sys.exc_info()[1]
comment("FAIL -> " + test_name + "\n" + str(e))
grade(0)