# 单链表 class ListNode: # 定义链表节点类 def __init__(self, elem_1, next_1): self.elem = elem_1 # 节点的值 self.next = next_1 # 指向下一个节点的链接 class LoopList: # 定义一个循环单链表 def __init__(self): self.rear = None def is_empty(self): # return self.rear is None def prepend(self, elem): # p = ListNode(elem, None) if self.rear is None: p.next = p # self.rear = p else: p.next = self.rear.next self.rear.next = p
线性表的循环单链表的类定义的代码实现(python语言)
最新推荐文章于 2021-09-18 22:16:21 发布