栈
class FooStack(object):
def __init__(self):
self.FooList=[]
def push(self,num):
if isinstance(num,list):
self.FooList.extend(num)
else:
self.FooList.append(num)
def singlepop(self,number=1):
ret=self.FooList[-number:]
for i in range(0,number):
item=ret.pop()
yield item
def popall(self):
return self.singlepop(len(self.FooList))
def is_null(self):
if self.FooList==[]:
return True
else:
return False
text=FooStack()
text.push([1,2,3,4,5,6])
text.push([7,8,9,10])
ret=text.popall()
for item in ret:
print(item)
队列
class FooStack(object):
def __init__(self):
self.FooList=[]
def push(self,num):
if isinstance(num,list):
self.FooList.extend(num)
else:
self.FooList.append(num)
def singlepop(self,number=1):
ret=self.FooList[:number]
for i in range(0,number):
item=ret[i]
yield item
def popall(self):
return self.singlepop(len(self.FooList))
def is_null(self):
if self.FooList==[]:
return True
else:
return False
text=FooStack()
text.push([1,2,3,4,5,6])
text.push([7,8,9,10])
ret=text.popall()
for item in ret:
print(item)