From f530c658e53b3b5d5af559a11208afbc38c66bc0 Mon Sep 17 00:00:00 2001
From: orajavac <oraclegit@126.com>
Date: Mon, 27 Feb 2017 09:53:27 +0800
Subject: [PATCH 1/3] 20170227_09:52

---
 .../orajavac/coding2017/basic/ArrayList.java  | 100 ++++++++++++++++
 .../coding2017/basic/BinaryTreeNode.java      |  32 +++++
 .../orajavac/coding2017/basic/Iterator.java   |   7 ++
 .../orajavac/coding2017/basic/LinkedList.java | 110 ++++++++++++++++++
 .../orajavac/coding2017/basic/List.java       |   9 ++
 .../orajavac/coding2017/basic/Queue.java      |  34 ++++++
 .../orajavac/coding2017/basic/Stack.java      |  49 ++++++++
 7 files changed, 341 insertions(+)
 create mode 100644 group02/562768642/src/com/github/orajavac/coding2017/basic/ArrayList.java
 create mode 100644 group02/562768642/src/com/github/orajavac/coding2017/basic/BinaryTreeNode.java
 create mode 100644 group02/562768642/src/com/github/orajavac/coding2017/basic/Iterator.java
 create mode 100644 group02/562768642/src/com/github/orajavac/coding2017/basic/LinkedList.java
 create mode 100644 group02/562768642/src/com/github/orajavac/coding2017/basic/List.java
 create mode 100644 group02/562768642/src/com/github/orajavac/coding2017/basic/Queue.java
 create mode 100644 group02/562768642/src/com/github/orajavac/coding2017/basic/Stack.java

diff --git a/group02/562768642/src/com/github/orajavac/coding2017/basic/ArrayList.java b/group02/562768642/src/com/github/orajavac/coding2017/basic/ArrayList.java
new file mode 100644
index 0000000000..cc5bbc8adc
--- /dev/null
+++ b/group02/562768642/src/com/github/orajavac/coding2017/basic/ArrayList.java
@@ -0,0 +1,100 @@
+package com.github.orajavac.coding2017.basic;
+
+public class ArrayList implements List,Iterator{
+	
+	private int size = 0;
+	
+	private int i=0;
+	
+	private Object[] elementData = new Object[2];
+	
+	public void add(Object o){
+		size=size();
+		if (size == elementData.length)
+			grow(elementData,size);
+		elementData[size]=o;
+	}
+	public void add(int index, Object o){
+		Object old=elementData[index];	//[3] old value=c
+		size=size();
+		size+=1;
+		if (size>elementData.length)
+			grow(elementData,size);
+		Object temp = null;
+		int len=elementData.length;
+		for (int i=0;i<len;i++){
+			if (i==index){
+				elementData[index]=o;
+			}else if(i>index){
+				temp=elementData[i];
+				elementData[i]=old;	//[4]=c
+				old=temp;
+			}
+		}
+	}
+	
+	public Object get(int index){
+		return elementData[index];
+	}
+	
+	public Object remove(int index){
+		if (index==elementData.length-1){	//É¾³ý×îºóÒ»¸öË÷ÒýÔªËØÀïµÄÖµ
+			elementData[index]=null;
+		}else{
+			elementData[index]=null;
+			int len=elementData.length;
+			for (int i=0;i<len;i++){
+				if (i==index){
+					elementData[i]=elementData[i+1];
+				}else if(i>index){
+					if(i+1!=len){
+						elementData[i]=elementData[i+1];
+					}else{	//ÎÒÃÇ¼ÙÉèÊý×éË÷Òý 0-3£¬ÄÇÃ´Êý×é³¤¶ÈÊÇ4£¬3+1==4£¬elementData[i+1]»á±¨´í
+						elementData[i]=null;
+					}
+				}
+			}
+		}
+		return null;
+	}
+	
+	public int size(){
+		size=0;
+		for (int i=0;i<elementData.length;i++){
+			if (elementData[i]!=null){
+				size++;
+			}
+		}
+		return size;
+	}
+	
+	public void grow(Object[] elementData,int size){
+		Object[] target = new Object[size+elementData.length];
+		System.arraycopy(elementData, 0, target, 0, elementData.length);
+		this.elementData=target;
+	}
+	
+	public Iterator iterator(){
+		ArrayList l = new ArrayList();
+		l.elementData=this.elementData;
+		l.size=this.size();
+		return l;
+	}
+	
+	
+	
+	public boolean hasNext(){
+		if (i<=size-1){
+			return true;
+		}else{
+			i=0;
+		}
+		return false;
+	}
+	
+	public Object next(){
+		Object obj=elementData[i];
+		i++;
+		return obj;
+	}
+}
diff --git a/group02/562768642/src/com/github/orajavac/coding2017/basic/BinaryTreeNode.java b/group02/562768642/src/com/github/orajavac/coding2017/basic/BinaryTreeNode.java
new file mode 100644
index 0000000000..65ef21a344
--- /dev/null
+++ b/group02/562768642/src/com/github/orajavac/coding2017/basic/BinaryTreeNode.java
@@ -0,0 +1,32 @@
+package com.github.orajavac.coding2017.basic;
+
+public class BinaryTreeNode {
+	
+	private Object data;
+	private BinaryTreeNode left;
+	private BinaryTreeNode 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/group02/562768642/src/com/github/orajavac/coding2017/basic/Iterator.java b/group02/562768642/src/com/github/orajavac/coding2017/basic/Iterator.java
new file mode 100644
index 0000000000..7c7072a614
--- /dev/null
+++ b/group02/562768642/src/com/github/orajavac/coding2017/basic/Iterator.java
@@ -0,0 +1,7 @@
+package com.github.orajavac.coding2017.basic;
+
+public interface Iterator {
+	public boolean hasNext();
+	public Object next();
+
+}
diff --git a/group02/562768642/src/com/github/orajavac/coding2017/basic/LinkedList.java b/group02/562768642/src/com/github/orajavac/coding2017/basic/LinkedList.java
new file mode 100644
index 0000000000..da145e33fb
--- /dev/null
+++ b/group02/562768642/src/com/github/orajavac/coding2017/basic/LinkedList.java
@@ -0,0 +1,110 @@
+package com.github.orajavac.coding2017.basic;
+
+public class LinkedList implements List,Iterator {
+	
+private Node head;
+
+private Node current;
+	
+	private int size=0;
+	
+	public void add(Object o){
+		Node n = new Node();
+		n.next=this.head;
+		n.data=o;
+		this.head=n;
+	}
+	public void add(int index , Object o){
+		
+	}
+	public Object get(int index){
+		Node c = this.head;
+		int i=0;
+		while(c!=null){
+			i++;
+			if (index==i){
+				return c.data;
+			}
+			c=c.next;
+		}
+		return null;
+	}
+	public Object remove(int index){
+		return null;
+	}
+	
+	public int size(){
+		size=0;
+		Node c = this.head;
+		while(c!=null){
+			size++;
+			c=c.next;
+		}
+		return size;
+	}
+	
+	public void addFirst(Object o){
+		if (this.head==null){
+			this.head = new Node();
+			this.head.data=o;
+		}
+	}
+	public void addLast(Object o){
+		add(o);
+	}
+	public Object removeFirst(){
+		int s=size();
+		int index=0;
+		Node c = this.head;
+		while(c!=null){
+			index=s--;
+			if (index==2){
+				System.out.println(c.next.data);
+				
+				break;
+			}
+			c=c.next;
+		}
+		return null;
+	}
+	public Object removeLast(){
+		Node e = this.head.next;
+		this.head=null;
+		this.head=e;
+		return null;
+	}
+	
+	public void listNode(){
+		Node c = this.head;
+		while(c!=null){
+			System.out.print(c.data+ " -> ");
+			c=c.next;
+		}
+		System.out.println();
+	}
+	public Iterator iterator(){
+		LinkedList l = new LinkedList();
+		l.head=this.head;
+		return l;
+	}
+	
+	public boolean hasNext(){
+		current = head;
+		if (current!=null){
+			head = current.next;
+			return true;
+		}
+		return false;
+	}
+	
+	public Object next(){
+		return current.data;
+	}
+	
+	
+	private static  class Node{
+		Object data;
+		Node next;
+		
+	}
+}
diff --git a/group02/562768642/src/com/github/orajavac/coding2017/basic/List.java b/group02/562768642/src/com/github/orajavac/coding2017/basic/List.java
new file mode 100644
index 0000000000..129333b4da
--- /dev/null
+++ b/group02/562768642/src/com/github/orajavac/coding2017/basic/List.java
@@ -0,0 +1,9 @@
+package com.github.orajavac.coding2017.basic;
+
+public interface List {
+	public void add(Object o);
+	public void add(int index, Object o);
+	public Object get(int index);
+	public Object remove(int index);
+	public int size();
+}
diff --git a/group02/562768642/src/com/github/orajavac/coding2017/basic/Queue.java b/group02/562768642/src/com/github/orajavac/coding2017/basic/Queue.java
new file mode 100644
index 0000000000..772806e391
--- /dev/null
+++ b/group02/562768642/src/com/github/orajavac/coding2017/basic/Queue.java
@@ -0,0 +1,34 @@
+package com.github.orajavac.coding2017.basic;
+
+public class Queue {
+	
+private ArrayList elementData = new ArrayList();
+	
+	public void enQueue(Object o){
+		elementData.add(o);
+	}
+	
+	public Object deQueue(){
+		Object obj = elementData.get(0);
+		elementData.remove(0);
+		return obj;
+	}
+	
+	public ArrayList getElementData() {
+		return elementData;
+	}
+
+	public void setElementData(ArrayList elementData) {
+		this.elementData = elementData;
+	}
+
+	public boolean isEmpty(){
+		if (elementData.size()>0)
+			return true;
+		return false;
+	}
+	
+	public int size(){
+		return elementData.size();
+	}
+}
diff --git a/group02/562768642/src/com/github/orajavac/coding2017/basic/Stack.java b/group02/562768642/src/com/github/orajavac/coding2017/basic/Stack.java
new file mode 100644
index 0000000000..62d9f2e278
--- /dev/null
+++ b/group02/562768642/src/com/github/orajavac/coding2017/basic/Stack.java
@@ -0,0 +1,49 @@
+package com.github.orajavac.coding2017.basic;
+
+public class Stack {
+	private ArrayList elementData = new ArrayList();
+	
+	public void push(Object o){		
+		elementData.add(o);
+	}
+	
+	public Object pop(){
+		int s=elementData.size();
+		Object obj = null;
+		for (int i=s-1;i>=0;i--){
+			if(elementData.get(i)!=null){
+				obj = elementData.get(i);
+				elementData.remove(i);
+				break;
+			}
+		}
+		return obj;
+	}
+	
+	public Object peek(){
+		int s=elementData.size();
+		Object obj = null;
+		for (int i=s-1;i>=0;i--){
+			if(elementData.get(i)!=null){
+				obj = elementData.get(i);
+				break;
+			}
+		}
+		return obj;
+	}
+	public boolean isEmpty(){
+		if (elementData.size()>0)
+			return true;
+		return false;
+	}
+	public int size(){
+		return elementData.size();
+	}
+	public ArrayList getElementData() {
+		return elementData;
+	}
+
+	public void setElementData(ArrayList elementData) {
+		this.elementData = elementData;
+	}
+}

From 6799d3d7749065d184a28c6434f3d4a6dffa4e52 Mon Sep 17 00:00:00 2001
From: orajavac <oraclegit@126.com>
Date: Mon, 27 Feb 2017 09:57:47 +0800
Subject: [PATCH 2/3] 123

---
 .../src/com/github/orajavac/coding2017/basic/ArrayList.java      | 1 +
 1 file changed, 1 insertion(+)

diff --git a/group02/562768642/src/com/github/orajavac/coding2017/basic/ArrayList.java b/group02/562768642/src/com/github/orajavac/coding2017/basic/ArrayList.java
index cc5bbc8adc..167a28045d 100644
--- a/group02/562768642/src/com/github/orajavac/coding2017/basic/ArrayList.java
+++ b/group02/562768642/src/com/github/orajavac/coding2017/basic/ArrayList.java
@@ -8,6 +8,7 @@ public class ArrayList implements List,Iterator{
 	
 	private Object[] elementData = new Object[2];
 	
+	//S
 	public void add(Object o){
 		size=size();
 		if (size == elementData.length)

From d54fe1ea448dc43f593987b3daa97ac1783e0306 Mon Sep 17 00:00:00 2001
From: orajavac <oraclegit@126.com>
Date: Mon, 27 Feb 2017 10:07:09 +0800
Subject: [PATCH 3/3] 999

---
 .../src/com/github/orajavac/coding2017/basic/ArrayList.java     | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/group02/562768642/src/com/github/orajavac/coding2017/basic/ArrayList.java b/group02/562768642/src/com/github/orajavac/coding2017/basic/ArrayList.java
index 167a28045d..73ac68069d 100644
--- a/group02/562768642/src/com/github/orajavac/coding2017/basic/ArrayList.java
+++ b/group02/562768642/src/com/github/orajavac/coding2017/basic/ArrayList.java
@@ -8,7 +8,7 @@ public class ArrayList implements List,Iterator{
 	
 	private Object[] elementData = new Object[2];
 	
-	//S
+	//SS
 	public void add(Object o){
 		size=size();
 		if (size == elementData.length)
