diff --git a/coding2017-1 b/coding2017-1
new file mode 160000
index 0000000000..b5be7e853c
--- /dev/null
+++ b/coding2017-1
@@ -0,0 +1 @@
+Subproject commit b5be7e853cd9d2f5bbcc43149dc4df83749759a2
diff --git a/group05/371492887/task_01/.classpath b/group05/371492887/task_01/.classpath
new file mode 100644
index 0000000000..2d7497573f
--- /dev/null
+++ b/group05/371492887/task_01/.classpath
@@ -0,0 +1,7 @@
+
+
+
+
+
+
+
diff --git a/group05/371492887/task_01/.gitignore b/group05/371492887/task_01/.gitignore
new file mode 100644
index 0000000000..ae3c172604
--- /dev/null
+++ b/group05/371492887/task_01/.gitignore
@@ -0,0 +1 @@
+/bin/
diff --git a/group05/371492887/task_01/.project b/group05/371492887/task_01/.project
new file mode 100644
index 0000000000..eca593c703
--- /dev/null
+++ b/group05/371492887/task_01/.project
@@ -0,0 +1,17 @@
+
+
+ task_01
+
+
+
+
+
+ org.eclipse.jdt.core.javabuilder
+
+
+
+
+
+ org.eclipse.jdt.core.javanature
+
+
diff --git a/group05/371492887/task_01/src/com/nitasty/test/ArrayListTest.java b/group05/371492887/task_01/src/com/nitasty/test/ArrayListTest.java
new file mode 100644
index 0000000000..848b4fafe9
--- /dev/null
+++ b/group05/371492887/task_01/src/com/nitasty/test/ArrayListTest.java
@@ -0,0 +1,95 @@
+package com.nitasty.test;
+
+import static org.junit.Assert.*;
+import junit.framework.Assert;
+
+import org.junit.Before;
+import org.junit.Test;
+
+import com.nitasty.util.ArrayList;
+import com.nitasty.util.Iterator;
+
+public class ArrayListTest {
+
+ private ArrayList list;
+
+ @Before
+ public void init(){
+ list=new ArrayList();
+ for (int i = 0; i < 100; i++) {
+ list.add(i);
+ }
+ }
+
+ @Test
+ public void testAddObject() {
+ list.add(100);
+ Assert.assertEquals(101, list.size());
+ }
+
+ @Test
+ public void testAddIntObject() {
+ list.add(3,"test");
+ Assert.assertEquals("test", list.get(3));
+ }
+
+ @Test
+ public void testRemoveInt() {
+ list.add(3,"test");
+ list.remove(3);
+ Assert.assertEquals(3, list.get(3));
+ }
+
+ @Test
+ public void testRemoveObject() {
+ list.add(0,"test");
+ list.remove("test");
+ Assert.assertEquals(0, list.get(0));
+ }
+
+
+ @Test
+ public void testIsEmpty() {
+ list.clear();
+ Assert.assertEquals(true, list.isEmpty());
+ }
+
+ @Test
+ public void testContains() {
+ Assert.assertEquals(false, list.contains("test"));
+ list.add("test");
+ Assert.assertEquals(true, list.contains("test"));
+ }
+
+
+
+ @Test
+ public void testSet() {
+ Assert.assertEquals(true, list.contains(3));
+ list.set(3, "test");
+ Assert.assertEquals(true, list.contains("test"));
+ Assert.assertEquals(false, list.contains(3));
+ }
+
+ @Test
+ public void testIndexOf() {
+ list.set(3, "test");
+ Assert.assertEquals(3, list.indexOf("test"));
+ }
+
+ @Test
+ public void testLastIndexOf() {
+ list.set(3, "test");
+ list.set(33, "test");
+ Assert.assertEquals(33, list.lastIndexOf("test"));
+ }
+
+ @Test
+ public void testHasNext(){
+ int i=0;
+ for(Iterator it=list.iterator();it.hasNext();i++){
+ Assert.assertEquals(i, it.next());
+// System.out.println(it.next());
+ }
+ }
+}
diff --git a/group05/371492887/task_01/src/com/nitasty/test/BinaryTreeTest.java b/group05/371492887/task_01/src/com/nitasty/test/BinaryTreeTest.java
new file mode 100644
index 0000000000..abb27b5691
--- /dev/null
+++ b/group05/371492887/task_01/src/com/nitasty/test/BinaryTreeTest.java
@@ -0,0 +1,66 @@
+package com.nitasty.test;
+
+import static org.junit.Assert.*;
+import junit.framework.Assert;
+
+import org.junit.Before;
+import org.junit.Test;
+
+import com.nitasty.util.BinaryTree;
+
+public class BinaryTreeTest {
+
+ BinaryTree tree;
+
+ @Before
+ public void init(){
+ tree=new BinaryTree();
+ tree.insert(5);
+ tree.insert(3);
+ tree.insert(8);
+ tree.insert(2);
+ tree.insert(7);
+ tree.insert(9);
+ tree.insert(1);
+ tree.insert(4);
+ tree.insert(10);
+ tree.insert(6);
+ }
+
+ @Test
+ public void testMakeEmpty() {
+ tree.makeEmpty();
+ Assert.assertEquals(true, tree.isEmpty());
+ }
+
+ @Test
+ public void testGetHeight() {
+ Assert.assertEquals(3, tree.getHeight());
+ }
+
+ @Test
+ public void testContains() {
+ for (int i = 1; i < 11; i++) {
+ Assert.assertEquals(true, tree.contains(i));
+ }
+ }
+
+ @Test
+ public void testFindMin() {
+ Assert.assertEquals(1, tree.findMin());
+ }
+
+ @Test
+ public void testFindMax() {
+ Assert.assertEquals(10, tree.findMax());
+ }
+
+
+ @Test
+ public void testRemove() {
+ tree.remove(3);
+ Assert.assertEquals(false, tree.contains(3));
+ }
+
+
+}
diff --git a/group05/371492887/task_01/src/com/nitasty/test/LinkedListTest.java b/group05/371492887/task_01/src/com/nitasty/test/LinkedListTest.java
new file mode 100644
index 0000000000..dcbe6353c3
--- /dev/null
+++ b/group05/371492887/task_01/src/com/nitasty/test/LinkedListTest.java
@@ -0,0 +1,142 @@
+package com.nitasty.test;
+
+import static org.junit.Assert.*;
+import junit.framework.Assert;
+
+import org.junit.Before;
+import org.junit.Test;
+
+import com.nitasty.util.ArrayList;
+import com.nitasty.util.Iterator;
+import com.nitasty.util.LinkedList;
+
+public class LinkedListTest {
+
+ private LinkedList list;
+
+ @Before
+ public void init(){
+ list=new LinkedList();
+ for (int i = 0; i < 100; i++) {
+ list.add(i);
+ }
+ }
+
+ @Test
+ public void testGet() {
+ IndexOutOfBoundsException tx=null;
+ for (int i = 0; i < 100; i++) {
+ Assert.assertEquals(i, list.get(i));
+ }
+
+ try {
+ list.get(100);
+ } catch (IndexOutOfBoundsException e) {
+ tx=e;
+ }
+ Assert.assertEquals(IndexOutOfBoundsException.class,tx.getClass());
+ }
+
+ @Test
+ public void testRemoveInt() {
+ for (int i = 99; i >= 0; i--) {
+ Assert.assertEquals(i, list.remove(i));
+ }
+ }
+
+ @Test
+ public void testSize() {
+ Assert.assertEquals(100, list.size());
+ }
+
+ @Test
+ public void testAddFirst() {
+ list.addFirst(-1);
+ for (int i = 0; i < 101; i++) {
+ Assert.assertEquals(i-1, list.get(i));
+ }
+ }
+
+ @Test
+ public void testAddLast() {
+
+ for (int i = 100; i < 1000; i++) {
+ list.addLast(i);
+ }
+
+ for (int i = 0; i < 1000; i++) {
+ Assert.assertEquals(i, list.get(i));
+ }
+ }
+
+ @Test
+ public void testAddBefore() {
+ list.addBefore(66,list.node(3));
+ Assert.assertEquals(66, list.get(3));
+ }
+
+ @Test
+ public void testAddAfter() {
+ list.addAfter(66,list.node(3));
+ Assert.assertEquals(66, list.get(4));
+ }
+
+ @Test
+ public void testIsEmpty() {
+ list.clear();
+ Assert.assertEquals(true, list.isEmpty());
+ }
+
+ @Test
+ public void testContains() {
+ for (int i = 0; i < 100; i++) {
+ Assert.assertEquals(true, list.contains(i));
+ Assert.assertEquals(false, list.contains(i+100));
+ }
+ }
+
+
+ @Test
+ public void testAddIntObject() {
+ list.add(20,"test");
+ Assert.assertEquals("test", list.get(20));
+ }
+
+ @Test
+ public void testRemoveObject() {
+ list.remove(30);
+ Assert.assertEquals(31, list.get(30));
+ }
+
+ @Test
+ public void testSet() {
+ for (int i = 0; i < 100; i++) {
+ list.set(i, i+100);
+ Assert.assertEquals(i+100, list.get(i));
+ }
+ }
+
+ @Test
+ public void testIndexOf() {
+ list.set(3, "test");
+ Assert.assertEquals(3, list.indexOf("test"));
+ }
+
+ @Test
+ public void testLastIndexOf() {
+ list.set(3, "test");
+ list.set(33, "test");
+ Assert.assertEquals(33, list.lastIndexOf("test"));
+ }
+
+ @Test
+ public void testHasNext(){
+ int i=0;
+
+ for(Iterator it=list.iterator();it.hasNext();i++){
+ Assert.assertEquals(i, it.next());
+// System.out.println(it.next());
+ }
+ }
+
+}
diff --git a/group05/371492887/task_01/src/com/nitasty/test/QueueTest.java b/group05/371492887/task_01/src/com/nitasty/test/QueueTest.java
new file mode 100644
index 0000000000..fa17263108
--- /dev/null
+++ b/group05/371492887/task_01/src/com/nitasty/test/QueueTest.java
@@ -0,0 +1,49 @@
+package com.nitasty.test;
+
+import static org.junit.Assert.*;
+import junit.framework.Assert;
+
+import org.junit.Before;
+import org.junit.Test;
+
+import com.nitasty.util.LinkedList;
+import com.nitasty.util.Queue;
+
+public class QueueTest {
+
+ Queue queue;
+
+ @Before
+ public void init(){
+ queue=new Queue();
+ for (int i = 0; i < 100; i++) {
+ queue.enQueue(i);
+ }
+ }
+
+ @Test
+ public void testDeQueue() {
+ for(int i=0; i<100;i++){
+ Assert.assertEquals(i, queue.deQueue());
+ }
+ }
+
+ @Test
+ public void testIsEmpty() {
+ for(int i=0; i<100;i++){
+ queue.deQueue();
+ if(i<99)
+ Assert.assertEquals(false, queue.isEmpty());
+ }
+ Assert.assertEquals(true, queue.isEmpty());
+ }
+
+ @Test
+ public void testSize() {
+ for(int i=99; i>0;i--){
+ queue.deQueue();
+ Assert.assertEquals(i, queue.size());
+ }
+ }
+
+}
diff --git a/group05/371492887/task_01/src/com/nitasty/test/StackTest.java b/group05/371492887/task_01/src/com/nitasty/test/StackTest.java
new file mode 100644
index 0000000000..3ecd59219a
--- /dev/null
+++ b/group05/371492887/task_01/src/com/nitasty/test/StackTest.java
@@ -0,0 +1,51 @@
+package com.nitasty.test;
+
+import static org.junit.Assert.*;
+import junit.framework.Assert;
+
+import org.junit.Before;
+import org.junit.Test;
+
+import com.nitasty.util.LinkedList;
+import com.nitasty.util.Stack;
+
+public class StackTest {
+
+ Stack stack;
+
+ @Before
+ public void init(){
+ stack=new Stack();
+ for (int i = 0; i < 100; i++) {
+ stack.push(i);
+ }
+ }
+
+ @Test
+ public void testPop() {
+ for (int i = 99; i >=0; i--) {
+ Assert.assertEquals(i, stack.pop());
+ }
+ }
+
+ @Test
+ public void testPeek() {
+ for (int i = 99; i >=0; i--) {
+ Assert.assertEquals(99, stack.peek());
+ }
+ }
+
+ @Test
+ public void testIsEmpty() {
+ for (int i = 99; i >=0; i--) {
+ stack.pop();
+ }
+ Assert.assertEquals(true,stack.isEmpty());
+ }
+
+ @Test
+ public void testSize() {
+ Assert.assertEquals(100,stack.size());
+ }
+
+}
diff --git a/group05/371492887/task_01/src/com/nitasty/util/ArrayList.java b/group05/371492887/task_01/src/com/nitasty/util/ArrayList.java
new file mode 100644
index 0000000000..88ef682cf9
--- /dev/null
+++ b/group05/371492887/task_01/src/com/nitasty/util/ArrayList.java
@@ -0,0 +1,307 @@
+package com.nitasty.util;
+
+import java.util.Arrays;
+import java.util.Objects;
+
+public class ArrayList implements List {
+
+ // �����ڲ�����
+ private static final int DEFAULT_CAPACITY = 10;
+
+ private static final Object[] EMPTY_ELEMENTDATA = {};
+
+ private int size;
+
+ private Object[] elementData;
+
+ /**
+ *
+ * �γ�ʼ��Ϊ�����飬��ʡ�ռ�
+ */
+ public ArrayList() {
+ this.elementData = EMPTY_ELEMENTDATA;
+ }
+
+ /**
+ *
+ * @param initCapacity
+ */
+ public ArrayList(int initCapacity) {
+ if (initCapacity > 0) {
+ elementData = new Object[initCapacity];
+ } else if (initCapacity == 0) {
+ elementData = EMPTY_ELEMENTDATA;
+ } else {
+ throw new IllegalArgumentException("�Ƿ���ʼ������" + initCapacity);
+ }
+
+ }
+
+ // TODO
+ public ArrayList(List list) {
+ list.toArray();
+
+ }
+
+ /**
+ * ������
+ *
+ * @param minCapacity
+ */
+ private void ensureCapacity(int minCapacity) {
+
+ if (elementData.length < minCapacity) {
+ grow(minCapacity);
+ }
+
+ }
+
+ /**
+ * ��������
+ *
+ * @param minCapacity
+ * @return
+ */
+ private void grow(int minCapacity) {
+ // ������
+ int oldCapacity = this.elementData.length;
+ // ��������������1.5��
+ int newCapacity = oldCapacity + oldCapacity >> 1;
+ // ����������С�����Ƚ�
+ if (newCapacity < minCapacity) {
+ newCapacity = minCapacity;
+ }
+ // ���������ܴ���int���ֵ
+ if (newCapacity > Integer.MAX_VALUE) {
+ newCapacity = Integer.MAX_VALUE;
+ }
+ elementData = Arrays.copyOf(elementData, newCapacity);
+
+ }
+
+ @Override
+ public int size() {
+ return size;
+ }
+
+ @Override
+ public boolean isEmpty() {
+ return size == 0;
+ }
+
+ @Override
+ public boolean contains(Object o) {
+ return indexOf(o) >= 0; //��д=��������ֵ�bug
+ }
+
+ @Override
+ public boolean add(Object o) {
+
+ ensureCapacity(size + 1);
+
+ elementData[size++] = o;// size��index��1
+
+ return true;
+ }
+
+ private void rangeCheck(int index) {
+ if (index < 0 || index > size)
+ throw new IndexOutOfBoundsException(outOfBoundsMsg(index));
+ }
+
+ private String outOfBoundsMsg(int index) {
+ return "index:" + index + ", size:" + size;
+ }
+
+ @Override
+ public boolean add(int index, Object o) {
+
+ rangeCheck(index);
+ ensureCapacity(size + 1);
+ System.arraycopy(elementData, index, elementData, index + 1, size
+ - index);// size������ը��
+ elementData[index] = o;
+ return true;
+ }
+
+ @Override
+ public boolean addAll(Object[] o) {
+ int numNew = o.length;
+ ensureCapacity(size + numNew);
+ System.arraycopy(o, 0, elementData, size, numNew);
+ size += numNew;// size����
+ return numNew != 0;
+ }
+
+ @Override
+ public boolean addAll(int index, Object[] o) {
+ rangeCheck(index);
+ int numNew = o.length;
+ ensureCapacity(size + numNew);
+
+ int numMoved = size - index;// ����rangeCheck��index�϶�С��size��
+ if (numMoved > 0)
+ System.arraycopy(elementData, index, elementData, size + numNew,
+ numNew);// ������ԭԪ���Ƶ�����
+ System.arraycopy(o, 0, elementData, index, numNew);// ���ƽ�Ҫ���ӵ�Ԫ��
+
+ size += numNew;// ��Ҫ���˰�����������
+ return numNew != 0;
+ }
+
+ @Override
+ public Object remove(int index) {
+ rangeCheck(index);
+ Object oldValue = elementData[index];
+
+ int numMoved = size - index - 1;
+ if (numMoved > 0)
+ System.arraycopy(elementData, index+1, elementData, index,
+ numMoved);
+ elementData[--size] = null;// Clear to let gc do its work
+
+ return oldValue;
+ }
+
+ @Override
+ public boolean remove(Object o) {
+ int index=this.indexOf(o);
+ if(index==-1){
+ return false;
+ }else{
+ this.remove(index);
+ return true;
+ }
+ }
+
+ @Override
+ /**
+ * ����ɾ��list
+ */
+ public boolean removeAll(List list) {
+ Objects.requireNonNull(list);
+ return batchRemove(list,false);
+ }
+
+ /**
+ * ����ʵ��removeALl��retainAll
+ * @param list
+ * @param complement
+ * @return
+ */
+ private boolean batchRemove(List list, boolean complement) {
+ final Object[] elementData=this.elementData;
+ int r=0,w=0;
+ boolean modified=false;
+ try{
+ for(;r= 0; i--) {
+ if (elementData[i] == null) {
+ return i;
+ }
+ }
+ } else {
+ for (int i = size-1; i >= 0; i--) {
+ if (o.equals(elementData[i])) {
+ return i;
+ }
+ }
+ }
+ return -1;// û�ҵ�
+ }
+
+ @Override
+ public Iterator iterator() {
+ return new Itr();
+ }
+
+ @Override
+ public Object[] toArray() {
+ return Arrays.copyOf(elementData, size);//��Ҫֱ�ӷ���elementData
+ }
+
+ @Override
+ public void clear() {
+ for(int i=0; i ������ʵ����Comparable����
+ */
+public class BinaryTree> {
+
+ private BinaryNode root;
+
+ public BinaryTree(){
+ this.root=null;
+ }
+
+ public BinaryTree(BinaryNode root) {
+ this.root = root;
+ }
+
+ public void makeEmpty(){
+ root=null;
+ }
+
+ public boolean isEmpty(){
+ return root==null;
+ }
+
+ public int getHeight(){
+ return height(root);
+ }
+
+ public boolean contains(E x){
+ return contains(x,root);
+ }
+
+
+ public E findMin(){
+ if(isEmpty())
+ throw new NullPointerException();//��ʲô��������أ�TODO
+ return (E) findMin(root).data; //ΪʲôҪ��ת�ͣ�
+ }
+
+
+
+ public E findMax(){
+ if(isEmpty())
+ throw new NullPointerException();//��ʲô��������أ�TODO
+ return (E) findMax(root).data;//ΪʲôҪ��ת�ͣ�
+ }
+
+ public void insert(E x){
+ root=insert(x,root);//ΪɶҪ��root�ӷ���ֵ����Ϊ�ⷽ���ǵݹ��
+ }
+
+ public void remove(E x){
+ root=remove(x,root);//ΪɶҪ��root�ӷ���ֵ����Ϊ�ⷽ���ǵݹ��
+ }
+
+ //��ӡ����data
+ public void printTree(){
+ if(isEmpty())
+ System.out.println("Empty tree");
+ else
+ printTree(root);
+ }
+
+ public void printTreeStructure(){
+ if(isEmpty())
+ System.out.println("Empty tree");
+ else
+ printTreeStructure(root,0);
+ }
+
+ private void printTreeStructure(BinaryNode t,int i) {
+ StringBuffer buff=new StringBuffer();
+ if(t!=null){
+ for(int j=0;j t) {
+ if(t==null)
+ return false;
+ int compareResult=x.compareTo(t.data);
+
+ if(compareResult<0){
+ return contains(x,t.left);//�ݹ�������������Ƚ�
+ }else if(compareResult>0){
+ return contains(x,t.right);//�ݹ�������������Ƚ�
+ }else{
+ return true;
+ }
+ }
+
+ private BinaryNode findMin(BinaryNode t) {
+ if(t==null)
+ return null;
+ else if(t.left==null)
+ return t;
+ return findMin(t.left);//�ݹ������С������
+ }
+ private BinaryNode findMax(BinaryNode t) {
+ if(t==null)
+ return null;
+ else if(t.right==null){
+ return t;
+ }
+ return findMax(t.right);//�ݹ�������������
+ }
+
+
+ private BinaryNode insert(E x, BinaryNode t) {
+
+ if(t==null)
+ return new BinaryNode(x);
+ int compareResult=x.compareTo(t.data);
+ if(compareResult<0)
+ t.left=insert(x,t.left);
+ else if(compareResult>0)
+ t.right=insert(x,t.right);
+ else
+ ;//�ظ��ˣ���ʱɶ�����ɣ����ԼӸ��ռ������ظ���
+ return t;//����ԭ��������
+ }
+
+ /**
+ * ���ү��̫����
+ * @param x
+ * @param t
+ * @return
+ */
+ private BinaryNode remove(E x, BinaryNode t) {
+ // TODO Auto-generated method stub
+ if(t==null)
+ return t; //x�����ڣ�ɶ������
+ int compareResult=x.compareTo(t.data);
+
+ if(compareResult<0)
+ t.left=remove(x,t.left);
+ else if(compareResult>0)
+ t.right=remove(x,t.right);
+ else if(t.left!=null && t.right!=null){ //����������
+ t.data=findMin(t.right).data;
+ t.right=remove(t.data,t.right);//������ݹ��ˡ����Ҳ�
+ }
+ else
+ t=(t.left!=null)? t.left:t.right; //ֻ��һ�����ӣ������ӷ���ɾ���Ľڵ㴦��û�к�����Ϊ�գ�������Ҫ���е�������
+ return t; //�ݹ�����
+ }
+
+ private int height(BinaryNode t){
+ if(t==null)
+ return -1;
+ else
+ return 1+Math.max(height(t.left),height(t.right)); //����ݹ�̫��������ˣ�����
+ }
+
+ private void printTree(BinaryNode t){//�������
+ if(t!=null){
+ printTree(t.left);
+ System.out.println(t.data);
+ printTree(t.right);
+ }
+ }
+
+
+
+ public static class BinaryNode{
+ private E data;
+ private BinaryNode left;
+ private BinaryNode right;
+
+ //�½��ڵ������data,left,right
+ BinaryNode(E data, BinaryNode left, BinaryNode right) {
+ this.data = data;
+ this.left = left;
+ this.right = right;
+ }
+
+ //left��right����Ϊnull
+ BinaryNode(E data){
+ this(data, null, null);
+ }
+
+ }
+}
diff --git a/group05/371492887/task_01/src/com/nitasty/util/BinaryTreeNode.java b/group05/371492887/task_01/src/com/nitasty/util/BinaryTreeNode.java
new file mode 100644
index 0000000000..e04b6f7fed
--- /dev/null
+++ b/group05/371492887/task_01/src/com/nitasty/util/BinaryTreeNode.java
@@ -0,0 +1,43 @@
+package com.nitasty.util;
+
+public class BinaryTreeNode {
+
+ private Object data;
+ private BinaryTreeNode left;
+ private BinaryTreeNode right;
+
+
+
+ //�½��ڵ������data,left,right(left��right����Ϊnull)
+ public BinaryTreeNode(Object data, BinaryTreeNode left, BinaryTreeNode right) {
+ super();
+ this.data = data;
+ this.left = left;
+ this.right = right;
+ }
+
+
+ public Object getData() {
+ return data;
+ }
+ public void setData(Object data) {
+ this.data = data;
+ }
+ public BinaryTreeNode getLeft() {
+ return left;
+ }
+ public void setLeft(BinaryTreeNode left) {
+ this.left = left;
+ }
+ public BinaryTreeNode getRight() {
+ return right;
+ }
+ public void setRight(BinaryTreeNode right) {
+ this.right = right;
+ }
+
+ public BinaryTreeNode insert(Object o){
+ return null;
+ }
+
+}
diff --git a/group05/371492887/task_01/src/com/nitasty/util/Iterator.java b/group05/371492887/task_01/src/com/nitasty/util/Iterator.java
new file mode 100644
index 0000000000..3c51e350bc
--- /dev/null
+++ b/group05/371492887/task_01/src/com/nitasty/util/Iterator.java
@@ -0,0 +1,7 @@
+package com.nitasty.util;
+
+public interface Iterator {
+ public boolean hasNext();
+ public Object next();
+
+}
diff --git a/group05/371492887/task_01/src/com/nitasty/util/LinkedList.java b/group05/371492887/task_01/src/com/nitasty/util/LinkedList.java
new file mode 100644
index 0000000000..3497fdb57f
--- /dev/null
+++ b/group05/371492887/task_01/src/com/nitasty/util/LinkedList.java
@@ -0,0 +1,393 @@
+package com.nitasty.util;
+
+public class LinkedList implements List {
+
+ private Node first;
+
+ private Node last;
+
+ int size = 0;
+
+ public LinkedList() {
+
+ }
+
+ /**
+ * ��������
+ *
+ * @param index
+ * @return
+ */
+ public Node node(int index) {
+ if (index < (size >> 1)) { // ��������ܻ��ǰ�
+ Node x = first;
+ for (int i = 0; i < index; i++) {
+ x = x.next;
+ }
+ return x;
+ } else {
+ Node x = last;
+ for (int i = size-1; i > index; i--) {
+ x = x.prev;
+ }
+ return x;
+ }
+
+ }
+
+ public Object get(int index) {
+ checkElementIndex(index);
+ return node(index).data;
+ }
+
+ public Object remove(int index) {
+ checkElementIndex(index);
+ return (unlink(node(index)));
+ }
+
+ public int size() {
+ return size;
+ }
+
+ public void addFirst(Object o) {
+ final Node f = first;
+ final Node newNode = new Node(null, o, f);
+ first = newNode;
+
+ if (f == null) {
+ last = newNode;
+ } else {
+ f.prev = newNode;
+ }
+ size++;// ������
+ }
+
+ public void addLast(Object o) {
+ final Node l = last;
+ final Node newNode = new Node(l, o, null);
+ last=newNode;
+ if (l == null) {
+ first = newNode;
+ } else {
+ l.next = newNode;
+ }
+ size++;
+ }
+
+ public void addBefore(Object o, Node succ) {
+ final Node pred = succ.prev;
+ final Node newNode = new Node(pred, o, succ);
+ succ.prev = newNode;
+ if (pred == null) {
+ first = newNode;
+ } else {
+ pred.next = newNode;
+ }
+ size++;
+ }
+
+ public void addAfter(Object o, Node succ) {
+ final Node nextd = succ.next;
+ final Node newNode = new Node(succ, o, nextd);
+ succ.next = newNode;
+ if (nextd == null) {
+ last = newNode;
+ } else {
+ nextd.prev = newNode;
+ }
+ size++;
+ }
+
+ private Object unlink(Node n) {
+
+ Object data = n.data;
+ final Node prev = n.prev;
+ final Node next = n.next;
+
+ /* �Լ�д�ľ�����ôbug */
+ // if(n.prev==null){
+ // first=n.next;
+ // }else if(n.next==null){
+ // last=n.prev;
+ // }else {
+ // n.prev.next=n.next;
+ // n.next.prev=n.prev;
+ // }
+ //
+ // n=null;
+
+ if (prev == null) {
+ first = next;
+// first.prev = null;// Դ��û�����д��� why�� �𣺵� data, prev, ��NullPointException
+ // nextȫΪnullʱ����nodeΪnull��
+ } else {
+ prev.next = next;
+ n.prev = null;
+ }
+
+ if (next == null) {
+ last = prev;
+// last.next = null;// Դ��û�����д��� why�� ��NullPointException
+ } else {
+ next.prev = prev;
+ n.next = null;
+ }
+
+ n.data = null; // Ϊʲô��ֱ�� node=null���������ν� data, prev, next ��Ϊnull
+ size--; // ע��
+ return data;
+ }
+
+ public Object removeFirst() {// ΪɶԴ���л���Ҫ���� node��
+
+ final Object data = first.data;
+ final Node next = first.next;
+ first = next;
+
+ if (next == null)
+ first = null;
+ else
+ next.prev = null;
+
+ size--;
+ return data;
+ }
+
+ public Object removeLast() {// ΪɶԴ���л���Ҫ���� node��
+
+ final Object data = last.data;
+ final Node prev = last.prev;
+ last = prev;
+
+ if (prev == null)
+ last = null;
+ else
+ prev.next = null;
+
+ size--;
+ return data;
+ }
+
+ private static class Node {
+ Object data;
+ Node next;
+ Node prev;
+
+ Node(Node prev, Object data, Node next) {
+ this.prev = prev;
+ this.data = data;
+ this.next = next;
+ }
+ }
+
+ @Override
+ public boolean isEmpty() {
+ return size == 0;
+ }
+
+ @Override
+ public boolean contains(Object o) {
+ return indexOf(o) >= 0;
+ }
+
+ @Override
+ public boolean add(Object o) {
+ addLast(o);
+ return true;
+ }
+
+ @Override
+ public boolean add(int index, Object o) {
+ checkPositionIndex(index);
+ if (index == size)
+ addLast(o);
+ else
+ addBefore(o, node(index));
+ return true;
+ }
+
+ @Override
+ public boolean addAll(Object[] o) {
+ // add(size,o);
+ // return true;
+
+ return add(size, o);// ����
+ }
+
+ @Override
+ public boolean addAll(int index, Object[] o) {// ͦ���Ѷ�
+ checkPositionIndex(index);
+
+ int numNew = o.length;
+ if (numNew == 0)
+ return false;
+
+ Node pred, succ; // unlink�ڵ��ǰһ�ڵ㼰unlink�ڵ�
+ if (index == size) {
+ succ = null;
+ pred = last;
+ } else {
+ succ = node(index);
+ pred = succ.prev;
+ }
+
+ for (Object data : o) {
+ Node newNode = new Node(pred, data, null);// ���½ڵ�link��ǰһ�ڵ�
+ if (pred == null)
+ first = newNode;
+ else
+ pred.next = newNode;
+ pred = newNode;
+ // size++;
+ }
+
+ if (succ == null) {// link��succ
+ last = pred;
+ } else {
+// last = succ; // Դ��δ���� why�� succ�ֲ������һ���� ��Ȼ�������ˡ�
+// succ.next = null; // Դ��δ���� why��
+ pred.next = succ;
+ succ.prev = pred;
+ // size++;
+ }
+
+ size += numNew;
+
+ return true;
+ }
+
+ private String outOfBoundsMsg(int index) {
+ return "Index: " + index + ", Size: " + size;
+ }
+
+ private void checkElementIndex(int index) {
+ if (!isElementIndex(index))
+ throw new IndexOutOfBoundsException(outOfBoundsMsg(index));
+ }
+
+ private void checkPositionIndex(int index) {
+ if (!isElementIndex(index))
+ throw new IndexOutOfBoundsException(outOfBoundsMsg(index));
+ }
+
+ private boolean isElementIndex(int index) {
+ return index >= 0 && index < size;
+ }
+
+ private boolean isPositionIndex(int index) {
+ return index >= 0 && index <= size; // postion�������ӵ����
+ }
+
+ @Override
+ public boolean remove(Object o) {
+
+ return false;
+ }
+
+ @Override
+ public boolean removeAll(List list) {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public Object set(int index, Object o) {
+ checkElementIndex(index);
+ Node node=node(index);
+ Object oldValue=node.data;
+ node.data=o;
+ return oldValue;
+ }
+
+ @Override
+ public int indexOf(Object o) {
+ int index = 0;
+ if (o == null) {
+ for (Node x = first; x != null; x = x.next) { // �µ�ѭ����ʽ
+ if (x.data == null)
+ return index;
+ index++;
+ }
+ } else {
+ for (Node x = first; x != null; x = x.next) { // �µ�ѭ����ʽ
+ if (o.equals(x.data))
+ return index;
+ index++;
+ }
+ }
+ return -1;
+ }
+
+ @Override
+ public int lastIndexOf(Object o) {
+ int index = size-1;
+ if (o == null) {
+ for (Node x = last; x != null; x = x.prev) { // �µ�ѭ����ʽ
+ if (x.data == null)
+ return index;
+ index--;
+ }
+ } else {
+ for (Node x = last; x != null; x = x.prev) { // �µ�ѭ����ʽ
+ if (o.equals(x.data))
+ return index;
+ index--;
+ }
+ }
+ return -1;
+ }
+
+ @Override
+ public Object[] toArray() {
+ Object[] elementData = new Object[size];
+ int i = 0;
+ for (Node x = first; x != null; x = x.next) {
+ elementData[i++] = x.data;
+ }
+ return elementData;
+ }
+
+ @Override
+ public void clear() {
+ // bugը��
+ // for(Node x=first;x!=null;x=x.next){
+ // x=null;
+ // }
+
+ for (Node x = first; x != null;) {
+ Node next = x.next;
+ x.prev = null;
+ x.data = null;
+ x.next = null;
+ x = next;
+ }
+ size = 0;
+ first = last = null;
+ }
+
+ public Iterator iterator(){
+ return new Itr();
+ }
+
+ private class Itr implements Iterator{
+ private Node lastRetured;
+ private Node next;
+ int cursor;
+
+ @Override
+ public boolean hasNext() {
+ return cursor