是个传颂厨

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::
# -*- coding: utf-8 -*-#输入中文要用
class Queue():
    def __init__(qu,size):#类比栈
        qu.queue=[];
        qu.size=size;
        qu.head=0;
        qu.tail=0;
    def Empty(qu):
        if qu.head==qu.tail:
            return True
        else:
            return False
    def Full(qu):
        if qu.tail-qu.head==qu.size:
            return True
        else:
            return False
    def push(qu,content):
        if qu.Full():
            print "Queue is Full!"
        else:
            qu.queue.append(content)
            qu.tail=qu.tail+1
    def out(qu):
        if qu.Empty():
            print "Queue is Empty!"
        else:
            qu.head=qu.head+1

 

posted on 2016-03-02 17:13  是个传颂厨  阅读(103)  评论(0编辑  收藏  举报