設隊列頭指針為 front,隊列尾指針為 rear,隊列容量為 maxsize
隊空:front== rear
隊滿: (rear+1) mod maxsize == front ( mod 表示求余運算)
隊中元素個數 n=(rear-front+maxsize )mod maxsize
入隊:rear=(rear+1) % maxsize ;
出隊:front=(front+1) % maxsize ;
設隊列頭指針為 front,隊列尾指針為 rear,隊列容量為 maxsize
隊空:front== rear
隊滿: (rear+1) mod maxsize == front ( mod 表示求余運算)
隊中元素個數 n=(rear-front+maxsize )mod maxsize
入隊:rear=(rear+1) % maxsize ;
出隊:front=(front+1) % maxsize ;
本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。