PegasusWang / python_data_structures_and_algorithms

Python 中文数据结构和算法教程

Home Page:http://pegasuswang.github.io/python_data_structures_and_algorithms/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

循环双端列表链表append问题

71n9 opened this issue · comments

commented

dll = CirculateDoubleLinkedList()
此时maxsize = None 使用append方法 和appendleft 还是可以添加

append方法里面没有抛出异常
if self.maxsize is not None and len(self) > self.maxsize:
raise Exception("full")

改成下面代码就可以限制
if self.maxsize is None or len(self) >= self.maxsize:
raise Exception("full")