chap10 list 单链表实现
来源:互联网 发布:xp深度优化工具 编辑:程序博客网 时间:2024/05/16 19:15
class Node: def __init__(self,key,next=None): self.key=key self.next=nextclass LinkList: def __init__(self): self.nil=Node('error',None) self.nil.next=self.nil def insert(self,x): x.next=self.nil.next self.nil.next=x def delete(self,x): prev,cur=self.nil,self.nil.next while(cur!=x): prev,cur=cur,cur.next if(prev==self.nil): return None prev.next=cur.next def delete_key(self,x): prev,cur=self.nil,self.nil.next while cur!=self.nil and cur.key!=x: prev,cur=cur,cur.next if cur==self.nil: return None prev.next=cur.next def __repr__(self): res='' cur=self.nil.next while(cur!=self.nil): res+=(str(cur.key)+' ') cur=cur.next return resl=LinkList()for i in range(0,10): print(i) l.insert(Node(i))print(l)for i in range(0,10): l.delete_key(i) print(l)
0 0
- chap10 list 单链表实现
- chap10 单链表倒置
- Chap10:在 Windows 中实现 Java 本地方法
- chap10-queue
- chap10-DLinkList
- chap10 name control
- Note of Chap10
- 英语学习--chap10 介词
- CSAPP Note chap10
- List单链表实现
- list实现
- List实现
- 基础文章1:APUE chap10 信号
- List(1)List单链表的链式实现
- 单链表(List)的模板实现
- 单链表Singly Linked List之JAVA实现
- [转贴] Windows编程和面向对象技术 chap10
- STL LIST实现
- 解决用户在Datepicker中手动输入数字后返回当前时间
- UVA10719 Quotient Polynomial
- centOS 7 使用yum安装jdk,mysql
- VS2012配置cocos2d-x 3.0版本的步骤,
- 函数声明、函数指针、指针函数 .
- chap10 list 单链表实现
- 开发模式——策略模式
- 一个简单的例子解析android中Handler线程和普通Thread的使用
- 使用PHP做多线程采集?
- Android学习路线图
- opencv1/opencv2摄像头成像
- AjaxPro.2.dll 使用指南
- 告诉你安装Linux的几种方法
- 火炬之光(TorchLight)使用的Ogre粒子系统插件ParticleUniverse研究