- 16
- 0
- 约5.91千字
- 约 33页
- 2018-11-05 发布于广西
- 举报
* * * * * 双链表的设计(续) public void remove (Node p)throws Exception{ DLinkedNode node = check(p); node.getPre().setNext(node.getNext()); node.getNext().setPre(node.getPre()); size--; } 请设计方法移除尾部元素 public void removeLast() 双链表的设计(续) 请设计方法移除指定位置的元素 public void remove(int index) 请设计方法将链表中指定位置元素替换为指定的元素,并返回以前在指定位置处的元素 public void set(int index,Object obj) 链表的使用 可以使用链表替代数组实现栈和队列。 public class StackLinkedList { private SinglyLinkedNode top;// 指向栈顶元素 private int size;// 栈中元素数目 public StackLinkedList() { top = null; size = 0; } public int getSize() { return size; } public boolean isEmpty() { return (top
原创力文档

文档评论(0)