Skip to content

Commit f6ec735

Browse files
committed
添加自己实现的SimpleLinkedList代码
1 parent 0aa78f5 commit f6ec735

3 files changed

Lines changed: 67 additions & 0 deletions

File tree

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
package cn.byhieg.collectiontutorial.listtutorial;
2+
3+
import java.util.LinkedList;
4+
5+
/**
6+
* Created by byhieg on 17/2/15.
7+
* Mail to byhieg@gmail.com
8+
*/
9+
public class LinkedListDemo {
10+
11+
private LinkedList list = new LinkedList();
12+
13+
public LinkedList getList() {
14+
return list;
15+
}
16+
17+
public void setList(LinkedList list) {
18+
this.list = list;
19+
}
20+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
package cn.byhieg.collectiontutorial.listtutorial;
2+
3+
/**
4+
* Created by byhieg on 17/2/15.
5+
* Mail to byhieg@gmail.com
6+
*/
7+
public class SimpleLinkedList<E> {
8+
9+
private int size;
10+
11+
private Node<E> first;
12+
13+
private Node<E> last;
14+
15+
16+
private static class Node<E>{
17+
E item;
18+
Node<E> next;
19+
Node<E> prev;
20+
21+
public Node(E item, Node<E> next, Node<E> prev) {
22+
this.item = item;
23+
this.next = next;
24+
this.prev = prev;
25+
26+
}
27+
}
28+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package cn.byhieg.collectiontutorialtest;
2+
3+
import cn.byhieg.collectiontutorial.listtutorial.LinkedListDemo;
4+
import junit.framework.TestCase;
5+
6+
/**
7+
* Created by byhieg on 17/2/15.
8+
* Mail to byhieg@gmail.com
9+
*/
10+
public class LinkedListDemoTest extends TestCase {
11+
12+
public void testList() throws Exception {
13+
LinkedListDemo demo = new LinkedListDemo();
14+
demo.getList().add(111);
15+
System.out.println(demo.getList().get(0));
16+
demo.getList().remove(0);
17+
}
18+
19+
}

0 commit comments

Comments
 (0)