From dcb33754833838bb5c403b731d2ca6faa8084076 Mon Sep 17 00:00:00 2001
From: fzon0902 <815591664@qq.com>
Date: Sat, 11 Mar 2017 22:27:12 +0800
Subject: [PATCH] =?UTF-8?q?=E8=83=A1=E9=AB=98=E6=B8=85=E7=9A=84=E4=BD=9C?=
=?UTF-8?q?=E4=B8=9A?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
group27/815591664/2017Learning/.classpath | 7 +
group27/815591664/2017Learning/.gitignore | 1 +
group27/815591664/2017Learning/.project | 17 +
.../org.eclipse.core.resources.prefs | 2 +
.../src/com/coderising/array/ArrayUtil.java | 348 ++++++++++++++++++
.../coderising/litestruts/LoginAction.java | 39 ++
.../src/com/coderising/litestruts/Struts.java | 34 ++
.../com/coderising/litestruts/StrutsTest.java | 43 +++
.../src/com/coderising/litestruts/View.java | 23 ++
.../src/com/coderising/litestruts/struts.xml | 11 +
.../src/com/coding/basic/ArrayList.java | 146 ++++++++
.../src/com/coding/basic/BinaryTree.java | 35 ++
.../src/com/coding/basic/BinaryTreeNode.java | 43 +++
.../src/com/coding/basic/Iterator.java | 9 +
.../src/com/coding/basic/LinkedList.java | 236 ++++++++++++
.../src/com/coding/basic/List.java | 9 +
.../src/com/coding/basic/Queue.java | 27 ++
.../src/com/coding/basic/Stack.java | 29 ++
18 files changed, 1059 insertions(+)
create mode 100644 group27/815591664/2017Learning/.classpath
create mode 100644 group27/815591664/2017Learning/.gitignore
create mode 100644 group27/815591664/2017Learning/.project
create mode 100644 group27/815591664/2017Learning/.settings/org.eclipse.core.resources.prefs
create mode 100644 group27/815591664/2017Learning/src/com/coderising/array/ArrayUtil.java
create mode 100644 group27/815591664/2017Learning/src/com/coderising/litestruts/LoginAction.java
create mode 100644 group27/815591664/2017Learning/src/com/coderising/litestruts/Struts.java
create mode 100644 group27/815591664/2017Learning/src/com/coderising/litestruts/StrutsTest.java
create mode 100644 group27/815591664/2017Learning/src/com/coderising/litestruts/View.java
create mode 100644 group27/815591664/2017Learning/src/com/coderising/litestruts/struts.xml
create mode 100644 group27/815591664/2017Learning/src/com/coding/basic/ArrayList.java
create mode 100644 group27/815591664/2017Learning/src/com/coding/basic/BinaryTree.java
create mode 100644 group27/815591664/2017Learning/src/com/coding/basic/BinaryTreeNode.java
create mode 100644 group27/815591664/2017Learning/src/com/coding/basic/Iterator.java
create mode 100644 group27/815591664/2017Learning/src/com/coding/basic/LinkedList.java
create mode 100644 group27/815591664/2017Learning/src/com/coding/basic/List.java
create mode 100644 group27/815591664/2017Learning/src/com/coding/basic/Queue.java
create mode 100644 group27/815591664/2017Learning/src/com/coding/basic/Stack.java
diff --git a/group27/815591664/2017Learning/.classpath b/group27/815591664/2017Learning/.classpath
new file mode 100644
index 0000000000..3e0fb272a8
--- /dev/null
+++ b/group27/815591664/2017Learning/.classpath
@@ -0,0 +1,7 @@
+
+
+
+
+
+
+
diff --git a/group27/815591664/2017Learning/.gitignore b/group27/815591664/2017Learning/.gitignore
new file mode 100644
index 0000000000..ae3c172604
--- /dev/null
+++ b/group27/815591664/2017Learning/.gitignore
@@ -0,0 +1 @@
+/bin/
diff --git a/group27/815591664/2017Learning/.project b/group27/815591664/2017Learning/.project
new file mode 100644
index 0000000000..fab8d7f04c
--- /dev/null
+++ b/group27/815591664/2017Learning/.project
@@ -0,0 +1,17 @@
+
+
+ 2017Learning
+
+
+
+
+
+ org.eclipse.jdt.core.javabuilder
+
+
+
+
+
+ org.eclipse.jdt.core.javanature
+
+
diff --git a/group27/815591664/2017Learning/.settings/org.eclipse.core.resources.prefs b/group27/815591664/2017Learning/.settings/org.eclipse.core.resources.prefs
new file mode 100644
index 0000000000..3af089907a
--- /dev/null
+++ b/group27/815591664/2017Learning/.settings/org.eclipse.core.resources.prefs
@@ -0,0 +1,2 @@
+eclipse.preferences.version=1
+encoding//src/com/coderising/array/ArrayUtil.java=UTF-8
diff --git a/group27/815591664/2017Learning/src/com/coderising/array/ArrayUtil.java b/group27/815591664/2017Learning/src/com/coderising/array/ArrayUtil.java
new file mode 100644
index 0000000000..7c30103d89
--- /dev/null
+++ b/group27/815591664/2017Learning/src/com/coderising/array/ArrayUtil.java
@@ -0,0 +1,348 @@
+package com.coderising.array;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+
+import java.util.List;
+
+
+public class ArrayUtil {
+
+ /**
+ * 给定一个整形数组a , 对该数组的值进行置换
+ 例如: a = [7, 9 , 30, 3] , 置换后为 [3, 30, 9,7]
+ 如果 a = [7, 9, 30, 3, 4] , 置换后为 [4,3, 30 , 9,7]
+ * @param origin
+ * @return
+ */
+
+ public static void main(String[] args) {
+ int[] a = {7, 9, 30, 3, 4};
+ reverseArray(a);
+ System.out.println(Arrays.toString(a));
+
+
+ int oldArr[]={1,3,4,5,0,0,6,6,0,5,4,7,6,7,0,5,0} ;
+ System.out.println(Arrays.toString(removeZero(oldArr)));
+
+
+ int[] a1 = {3, 5, 7,8};
+ int[] a2 = {4, 5, 6,7};
+
+ System.out.println(Arrays.toString(merge(a1,a2)));
+
+
+ int[] b = { 2,3,6};
+ System.out.println(Arrays.toString(grow(b,5)));
+
+ System.out.println(genFibonacci(5));
+
+ System.out.println(Arrays.toString(fibonacci(30)));
+
+ System.out.println(Arrays.toString(getPrimes(10000)));
+
+ System.out.println(getFactor(10));
+
+ System.out.println(isPerfectNum(1000));
+
+// System.out.println();
+ System.out.println(Arrays.toString(getPerfectNumbers(100)));
+
+ System.out.println(join(a,"&"));
+
+
+ }
+ public static void reverseArray(int[] origin){
+
+ if(origin.length==0){
+ return;
+
+ }
+ int[] copy = new int[origin.length];
+ System.arraycopy(origin, 0, copy, 0, origin.length);
+
+ for (int i = 0; i < copy.length; i++) {
+
+ origin[i] = copy[copy.length-1-i];
+ }
+
+
+ }
+
+ /**
+ * 现在有如下的一个数组: int oldArr[]={1,3,4,5,0,0,6,6,0,5,4,7,6,7,0,5}
+ * 要求将以上数组中值为0的项去掉,将不为0的值存入一个新的数组,生成的新数组为:
+ * {1,3,4,5,6,6,5,4,7,6,7,5}
+ * @param oldArray
+ * @return
+ */
+
+ public static int[] removeZero(int[] oldArray){
+ int newSize = 0;
+ for (int i = 0; i < oldArray.length; i++) {
+ if(oldArray[i]!=0){
+ newSize++;
+ }
+ }
+ int index = 0;
+ int[] newArr = new int[newSize];
+ for (int i = 0; i < oldArray.length; i++) {
+ if(oldArray[i]!=0){
+ newArr[index] = oldArray[i];
+ index++;
+ }
+ }
+ return newArr;
+ }
+
+ /**
+ * 给定两个已经排序好的整形数组, a1和a2 , 创建一个新的数组a3, 使得a3 包含a1和a2 的所有元素, 并且仍然是有序的
+ * 例如 a1 = [3, 5, 7,8] a2 = [4, 5, 6,7] 则 a3 为[3,4,5,6,7,8] , 注意: 已经消除了重复
+ * @param array1
+ * @param array2
+ * @return
+ */
+
+ public static int[] merge(int[] array1, int[] array2){
+ Arrays.sort(array1);
+ Arrays.sort(array2);
+
+ int[] newArr = new int[array1.length+array2.length];
+
+ System.arraycopy(array1, 0, newArr, 0,array1.length );
+ System.arraycopy(array2, 0, newArr, array1.length, array2.length);
+ Arrays.sort(newArr);
+ List list = new ArrayList();
+ for(int i=0;i list = new ArrayList();
+ for(int i =0;i list = new ArrayList();
+ for(int i=2;i<=max;i++){
+ if(isPrime(i)){
+ list.add(i);
+ }
+ }
+
+ return listToArray(list);
+
+
+ }
+
+ public static int[] listToArray(List list){
+ if(list == null){
+ return null;
+ }
+
+ int[] arr = new int[list.size()];
+
+ for(int i=0;i list = new ArrayList();
+ for(int i=1;i<=max;i++){
+ if(isPerfectNum(i)){
+ list.add(i);
+ }
+ }
+
+ return listToArray(list);
+ }
+
+
+ public static boolean isPerfectNum(int num){
+ if(num <=1){
+ return false;
+ }
+
+ List factors = getFactor(num);
+ int sum = 0;
+ for (Integer integer : factors) {
+ sum = integer+sum;
+ }
+ if(sum == num){
+ return true;
+ }
+ return false;
+ }
+
+ public static List getFactor(int num){
+ List list = new ArrayList();
+ list.add(1);
+
+
+ for(int i=2;i getFactor(int num){
+ List list = new ArrayList();
+ list.add(1);
+ int temp = num;
+
+ while(!isPrime(temp)){
+ if(temp ==1){
+ break;
+ }
+ for(int i=2;i<=temp;i++){
+ if(temp % i ==0){
+ list.add(i);
+ temp = temp/i;
+ break;
+ }
+ }
+
+ }
+ list.add(temp);
+
+ return list;
+ }*/
+
+ /**
+ * 用seperator 把数组 array给连接起来
+ * 例如array= [3,8,9], seperator = "-"
+ * 则返回值为"3-8-9"
+ * @param array
+ * @param s
+ * @return
+ */
+ public static String join(int[] array, String seperator){
+ StringBuilder sb = new StringBuilder();
+ for (int i : array) {
+ sb.append(i);
+ sb.append(seperator);
+
+ }
+
+ return sb.subSequence(0, sb.length()-1).toString();
+ }
+
+
+}
diff --git a/group27/815591664/2017Learning/src/com/coderising/litestruts/LoginAction.java b/group27/815591664/2017Learning/src/com/coderising/litestruts/LoginAction.java
new file mode 100644
index 0000000000..dcdbe226ed
--- /dev/null
+++ b/group27/815591664/2017Learning/src/com/coderising/litestruts/LoginAction.java
@@ -0,0 +1,39 @@
+package com.coderising.litestruts;
+
+/**
+ * 这是一个用来展示登录的业务类, 其中的用户名和密码都是硬编码的。
+ * @author liuxin
+ *
+ */
+public class LoginAction{
+ private String name ;
+ private String password;
+ private String message;
+
+ public String getName() {
+ return name;
+ }
+
+ public String getPassword() {
+ return password;
+ }
+
+ public String execute(){
+ if("test".equals(name) && "1234".equals(password)){
+ this.message = "login successful";
+ return "success";
+ }
+ this.message = "login failed,please check your user/pwd";
+ return "fail";
+ }
+
+ public void setName(String name){
+ this.name = name;
+ }
+ public void setPassword(String password){
+ this.password = password;
+ }
+ public String getMessage(){
+ return this.message;
+ }
+}
diff --git a/group27/815591664/2017Learning/src/com/coderising/litestruts/Struts.java b/group27/815591664/2017Learning/src/com/coderising/litestruts/Struts.java
new file mode 100644
index 0000000000..85e2e22de3
--- /dev/null
+++ b/group27/815591664/2017Learning/src/com/coderising/litestruts/Struts.java
@@ -0,0 +1,34 @@
+package com.coderising.litestruts;
+
+import java.util.Map;
+
+
+
+public class Struts {
+
+ public static View runAction(String actionName, Map parameters) {
+
+ /*
+
+ 0. 读取配置文件struts.xml
+
+ 1. 根据actionName找到相对应的class , 例如LoginAction, 通过反射实例化(创建对象)
+ 据parameters中的数据,调用对象的setter方法, 例如parameters中的数据是
+ ("name"="test" , "password"="1234") ,
+ 那就应该调用 setName和setPassword方法
+
+ 2. 通过反射调用对象的exectue 方法, 并获得返回值,例如"success"
+
+ 3. 通过反射找到对象的所有getter方法(例如 getMessage),
+ 通过反射来调用, 把值和属性形成一个HashMap , 例如 {"message": "登录成功"} ,
+ 放到View对象的parameters
+
+ 4. 根据struts.xml中的 配置,以及execute的返回值, 确定哪一个jsp,
+ 放到View对象的jsp字段中。
+
+ */
+
+ return null;
+ }
+
+}
diff --git a/group27/815591664/2017Learning/src/com/coderising/litestruts/StrutsTest.java b/group27/815591664/2017Learning/src/com/coderising/litestruts/StrutsTest.java
new file mode 100644
index 0000000000..b8c81faf3c
--- /dev/null
+++ b/group27/815591664/2017Learning/src/com/coderising/litestruts/StrutsTest.java
@@ -0,0 +1,43 @@
+package com.coderising.litestruts;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+
+
+
+
+public class StrutsTest {
+
+ @Test
+ public void testLoginActionSuccess() {
+
+ String actionName = "login";
+
+ Map params = new HashMap();
+ params.put("name","test");
+ params.put("password","1234");
+
+
+ View view = Struts.runAction(actionName,params);
+
+ Assert.assertEquals("/jsp/homepage.jsp", view.getJsp());
+ Assert.assertEquals("login successful", view.getParameters().get("message"));
+ }
+
+ @Test
+ public void testLoginActionFailed() {
+ String actionName = "login";
+ Map params = new HashMap();
+ params.put("name","test");
+ params.put("password","123456"); //密码和预设的不一致
+
+ View view = Struts.runAction(actionName,params);
+
+ Assert.assertEquals("/jsp/showLogin.jsp", view.getJsp());
+ Assert.assertEquals("login failed,please check your user/pwd", view.getParameters().get("message"));
+ }
+}
diff --git a/group27/815591664/2017Learning/src/com/coderising/litestruts/View.java b/group27/815591664/2017Learning/src/com/coderising/litestruts/View.java
new file mode 100644
index 0000000000..07df2a5dab
--- /dev/null
+++ b/group27/815591664/2017Learning/src/com/coderising/litestruts/View.java
@@ -0,0 +1,23 @@
+package com.coderising.litestruts;
+
+import java.util.Map;
+
+public class View {
+ private String jsp;
+ private Map parameters;
+
+ public String getJsp() {
+ return jsp;
+ }
+ public View setJsp(String jsp) {
+ this.jsp = jsp;
+ return this;
+ }
+ public Map getParameters() {
+ return parameters;
+ }
+ public View setParameters(Map parameters) {
+ this.parameters = parameters;
+ return this;
+ }
+}
diff --git a/group27/815591664/2017Learning/src/com/coderising/litestruts/struts.xml b/group27/815591664/2017Learning/src/com/coderising/litestruts/struts.xml
new file mode 100644
index 0000000000..dd598a3664
--- /dev/null
+++ b/group27/815591664/2017Learning/src/com/coderising/litestruts/struts.xml
@@ -0,0 +1,11 @@
+
+
+
+ /jsp/homepage.jsp
+ /jsp/showLogin.jsp
+
+
+ /jsp/welcome.jsp
+ /jsp/error.jsp
+
+
\ No newline at end of file
diff --git a/group27/815591664/2017Learning/src/com/coding/basic/ArrayList.java b/group27/815591664/2017Learning/src/com/coding/basic/ArrayList.java
new file mode 100644
index 0000000000..c983c04968
--- /dev/null
+++ b/group27/815591664/2017Learning/src/com/coding/basic/ArrayList.java
@@ -0,0 +1,146 @@
+package com.coding.basic;
+
+import java.util.Arrays;
+import java.util.LinkedList;
+
+/**
+ * @author hugaoqing
+ * created on 2017-3-8
+ */
+public class ArrayList implements List {
+
+ private int size = 0;
+
+ private Object[] elementData = new Object[100];
+
+
+
+ /*
+ * ��size����������lengthʱ����buffer�������ԭ����
+ *
+ */
+ public void add(Object o){
+ if(elementData.length == size){
+ Object[] buffer = new Object[size+15];
+ System.arraycopy(elementData, 0, buffer, 0, size);
+ elementData = buffer;
+ elementData[size] = o;
+ size++;
+ }else {
+
+ elementData[size] = o;
+ size++;
+ }
+
+ }
+
+
+ /*
+ * ָ��λ������Ԫ��
+ * ��size+1���� lengthҪ�����������ٽ������Ӳ���
+ */
+ public void add(int index, Object o) throws Exception{
+ if(index <0){
+ throw new Exception("��������Ϊ0��");
+
+ }else if(index >= size){
+ throw new Exception("�������ޣ�");
+ }else if(size+1=size){
+ throw new Exception("�������ޣ�");
+ }
+ return elementData[index];
+ }
+
+ public Object remove(int index) throws Exception{
+ if(index>=size){
+ throw new Exception("�������ޣ�");
+ }
+ Object out = elementData[index];
+ Object[] temp = new Object[size-index-1];
+ System.arraycopy(elementData, index+1, temp, 0, size-index-1);
+ System.arraycopy(temp, 0, elementData,index, size-index-1);
+
+ size--;
+ return out;
+ }
+
+ public int size(){
+ return this.size;
+ }
+
+ @Override
+ public String toString() {
+ Object[] objs = new Object[size];
+ System.arraycopy(elementData, 0,objs , 0, size);
+ return Arrays.toString(objs);
+
+ }
+ public Iterator iterator(){
+ return new Iterator() {
+ int cursor = 0;
+ public Object next() throws Exception {
+ cursor++;
+ return get(cursor-1);
+ }
+
+ public boolean hasNext() {
+
+ return this.cursor ll = new LinkedList();
+ ll.add(null);
+
+
+
+ }
+
+
+
+}
diff --git a/group27/815591664/2017Learning/src/com/coding/basic/BinaryTree.java b/group27/815591664/2017Learning/src/com/coding/basic/BinaryTree.java
new file mode 100644
index 0000000000..ed69a3f16c
--- /dev/null
+++ b/group27/815591664/2017Learning/src/com/coding/basic/BinaryTree.java
@@ -0,0 +1,35 @@
+package com.coding.basic;
+
+public class BinaryTree {
+
+ private BinaryTreeNode root;
+
+ public BinaryTreeNode insert(Integer data){
+ BinaryTreeNode node = new BinaryTreeNode(data);
+
+
+ if(this.root==null){
+ root = node;
+ root.setLeft(null);
+ root.setRight(null);
+ }else{
+ BinaryTreeNode curNode = this.root;
+
+ if(data.compareTo(root.getData())>0){
+ while(curNode.getRight()!=null){
+ curNode = curNode.getRight();
+ }
+ curNode = node;
+
+ }else{
+ while(curNode.getLeft()!=null){
+ curNode = curNode.getLeft();
+ }
+ curNode = node;
+ }
+
+ }
+ return null;
+ }
+
+}
diff --git a/group27/815591664/2017Learning/src/com/coding/basic/BinaryTreeNode.java b/group27/815591664/2017Learning/src/com/coding/basic/BinaryTreeNode.java
new file mode 100644
index 0000000000..23e2b871a3
--- /dev/null
+++ b/group27/815591664/2017Learning/src/com/coding/basic/BinaryTreeNode.java
@@ -0,0 +1,43 @@
+package com.coding.basic;
+
+
+
+/**
+ * @author hugaoqing
+ * created on 2017-3-11
+ */
+public class BinaryTreeNode {
+
+ private Integer data;
+ private BinaryTreeNode left;
+ private BinaryTreeNode right;
+
+ public BinaryTreeNode(Integer data) {
+ super();
+ this.data = data;
+ }
+ public Integer getData() {
+ return data;
+ }
+ public void setData(Integer 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){
+ this.data = o;
+ return this;
+ }*/
+
+}
diff --git a/group27/815591664/2017Learning/src/com/coding/basic/Iterator.java b/group27/815591664/2017Learning/src/com/coding/basic/Iterator.java
new file mode 100644
index 0000000000..d4656a7daf
--- /dev/null
+++ b/group27/815591664/2017Learning/src/com/coding/basic/Iterator.java
@@ -0,0 +1,9 @@
+package com.coding.basic;
+
+public interface Iterator {
+ //�ӿ���ij�Ա����Ĭ�϶���final static��
+// int cursor = 0;
+ public boolean hasNext();
+ public Object next() throws Exception;
+
+}
diff --git a/group27/815591664/2017Learning/src/com/coding/basic/LinkedList.java b/group27/815591664/2017Learning/src/com/coding/basic/LinkedList.java
new file mode 100644
index 0000000000..6f2fbf1f5b
--- /dev/null
+++ b/group27/815591664/2017Learning/src/com/coding/basic/LinkedList.java
@@ -0,0 +1,236 @@
+package com.coding.basic;
+
+public class LinkedList implements List {
+
+ private Node head;
+ private Node tail;
+ private int size;
+
+
+ public void add(Object o){
+ this.addLast(o);
+
+ }
+ public void add(int index , Object o) throws Exception{
+ if(index==0){
+ this.addFirst(o);
+ return;
+ }else if(index==size-1){
+ this.addLast(o);
+ return;
+ }else{
+
+
+ Node curNode = this.getNode(index);
+ Node pre = curNode.previous;
+// Node next = curNode.next;
+ //��������
+ Node newNode = new Node(o, pre, curNode);
+ curNode.previous = newNode;
+ pre.next = newNode;
+ }
+ size++;
+
+
+ }
+ private Node getNode(int index) throws Exception{
+ if(index>=size){
+ throw new Exception("�±곬��");
+ }
+ if(index ==0){
+ return head;
+ }else if(index==size-1){
+ return tail;
+
+ }else{
+ Node temp = head;
+ for(int i =1;i<=index;i++){
+ temp = temp.next;
+ }
+ return temp;
+ }
+ }
+ public Object get(int index) throws Exception{
+ if(index>=size){
+ throw new Exception("�±곬��");
+ }
+ if(index ==0){
+ return head.data;
+ }else if(index==size-1){
+ return tail.data;
+
+ }else{
+ Node temp = head;
+ for(int i =1;i<=index;i++){
+ temp = temp.next;
+ }
+ return temp.data;
+ }
+ }
+ public Object remove(int index) throws Exception{
+ if(index>=size){
+ throw new Exception("�±곬��");
+ }
+ Object o = null;
+ if(size == 1){
+ o = head.data;
+ }else{
+ if(index==0){
+
+ Node afterHead = head.next;
+ afterHead.previous = null;
+ head = afterHead;
+ o = head.data;
+
+ }else if(index == size-1){
+ Node beforeTail = tail.previous;
+ beforeTail.next = null;
+ tail = beforeTail;
+ o = tail.data;
+ }else{
+ Node curNode = this.getNode(index);
+ Node pre = curNode.previous;
+ Node next = curNode.next;
+ //�м�������ڶϿ�ָ��
+ Node temp = new Node(next.data, pre, next.next);
+ pre.next = temp;
+ next = temp;
+ o = curNode.data;
+
+ }
+
+
+
+ }
+
+ size--;
+ return o;
+
+
+ }
+
+ public int size(){
+ return this.size;
+ }
+
+ public void addFirst(Object o){
+ Node node = new Node(o, null, head);
+
+ if(head == null){
+ head = node;
+ tail = node;
+ }else{
+ head.previous = node;
+ head = node;
+ }
+ size++;
+
+ }
+ public void addLast(Object o){
+ //�½ڵ��previousָ��ָ��tail
+ Node curNode = new Node(o, tail, null);
+ if(tail==null){
+ //��ǰ����Ϊ��ʱ�����ýڵ����������ͷβ��Ϊ�ýڵ�
+ head = curNode;
+ tail = curNode;
+ }else{
+ //�����������Ϊ��ʱ�������һ���ڵ��nextָ��ָ���¼���Ľڵ㼴��
+ tail.next = curNode;
+ //���¼��������ڵ���Ϊtail
+ tail = curNode;
+
+ }
+ size++;
+
+ }
+ public Object removeFirst() throws Exception{
+ return this.remove(0);
+ }
+ public Object removeLast() throws Exception{
+ return this.remove(size-1);
+ }
+
+ private class Itr implements Iterator{
+ int cursor = 0;
+ public boolean hasNext() {
+ return cursor