From 775902ade60725089dbd7c07ff7266ea78d3d10b Mon Sep 17 00:00:00 2001 From: CyC2018 <1029579233@qq.com> Date: Wed, 6 Jun 2018 20:17:48 +0800 Subject: [PATCH] auto commit --- notes/算法.md | 46 ---------------------------------------------- 1 file changed, 46 deletions(-) diff --git a/notes/算法.md b/notes/算法.md index 4d818bad..58f49e4a 100644 --- a/notes/算法.md +++ b/notes/算法.md @@ -446,52 +446,6 @@ public class ListQueue implements MyQueue { } ``` -```java -public class Queue { - private Node first; - private Node last; - int N = 0; - - private class Node { - Item item; - Node next; - } - - public boolean isEmpty() { - return N == 0; - } - - public int size() { - return N; - } - - public void add(Item item) { - Node newNode = new Node(); - newNode.item = item; - newNode.next = null; - if (isEmpty()) { - last = newNode; - first = newNode; - } else { - last.next = newNode; - last = newNode; - } - N++; - } - - public Item remove() throws Exception { - if (isEmpty()) - throw new Exception("queue is empty"); - Node node = first; - first = first.next; - N--; - if (isEmpty()) - last = null; - return node.item; - } -} -``` - # 三、排序 待排序的元素需要实现 Java 的 Comparable 接口,该接口有 compareTo() 方法,可以用它来判断两个元素的大小关系。