From 8ed4ddefb57c6bef6c6329c5372642d1666f29d4 Mon Sep 17 00:00:00 2001 From: "mwu@xtremeprog.com" Date: Fri, 10 Mar 2017 22:01:43 +0800 Subject: [PATCH 01/28] =?UTF-8?q?arraylist=E7=9A=84=E8=87=AA=E6=88=91?= =?UTF-8?q?=E5=AE=9E=E7=8E=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- group26/mahone2017/mahone/.classpath | 22 ++++ group26/mahone2017/mahone/.project | 23 ++++ .../org.eclipse.core.resources.prefs | 4 + .../.settings/org.eclipse.jdt.core.prefs | 5 + .../.settings/org.eclipse.m2e.core.prefs | 4 + group26/mahone2017/mahone/pom.xml | 25 ++++ .../main/java/com/coding/basic/ArrayList.java | 77 +++++++++++ .../java/com/coding/basic/BinaryTreeNode.java | 32 +++++ .../main/java/com/coding/basic/Iterator.java | 7 + .../java/com/coding/basic/LinkedList.java | 122 ++++++++++++++++++ .../src/main/java/com/coding/basic/List.java | 9 ++ .../src/main/java/com/coding/basic/Queue.java | 19 +++ .../src/main/java/com/coding/basic/Stack.java | 22 ++++ .../src/main/java/study/mahone/App.java | 13 ++ .../src/test/java/study/mahone/AppTest.java | 38 ++++++ 15 files changed, 422 insertions(+) create mode 100644 group26/mahone2017/mahone/.classpath create mode 100644 group26/mahone2017/mahone/.project create mode 100644 group26/mahone2017/mahone/.settings/org.eclipse.core.resources.prefs create mode 100644 group26/mahone2017/mahone/.settings/org.eclipse.jdt.core.prefs create mode 100644 group26/mahone2017/mahone/.settings/org.eclipse.m2e.core.prefs create mode 100644 group26/mahone2017/mahone/pom.xml create mode 100644 group26/mahone2017/mahone/src/main/java/com/coding/basic/ArrayList.java create mode 100644 group26/mahone2017/mahone/src/main/java/com/coding/basic/BinaryTreeNode.java create mode 100644 group26/mahone2017/mahone/src/main/java/com/coding/basic/Iterator.java create mode 100644 group26/mahone2017/mahone/src/main/java/com/coding/basic/LinkedList.java create mode 100644 group26/mahone2017/mahone/src/main/java/com/coding/basic/List.java create mode 100644 group26/mahone2017/mahone/src/main/java/com/coding/basic/Queue.java create mode 100644 group26/mahone2017/mahone/src/main/java/com/coding/basic/Stack.java create mode 100644 group26/mahone2017/mahone/src/main/java/study/mahone/App.java create mode 100644 group26/mahone2017/mahone/src/test/java/study/mahone/AppTest.java diff --git a/group26/mahone2017/mahone/.classpath b/group26/mahone2017/mahone/.classpath new file mode 100644 index 0000000000..6908d0b2ae --- /dev/null +++ b/group26/mahone2017/mahone/.classpath @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + + + + + + + + diff --git a/group26/mahone2017/mahone/.project b/group26/mahone2017/mahone/.project new file mode 100644 index 0000000000..d392a9a466 --- /dev/null +++ b/group26/mahone2017/mahone/.project @@ -0,0 +1,23 @@ + + + mahone + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.m2e.core.maven2Builder + + + + + + org.eclipse.jdt.core.javanature + org.eclipse.m2e.core.maven2Nature + + diff --git a/group26/mahone2017/mahone/.settings/org.eclipse.core.resources.prefs b/group26/mahone2017/mahone/.settings/org.eclipse.core.resources.prefs new file mode 100644 index 0000000000..f9fe34593f --- /dev/null +++ b/group26/mahone2017/mahone/.settings/org.eclipse.core.resources.prefs @@ -0,0 +1,4 @@ +eclipse.preferences.version=1 +encoding//src/main/java=UTF-8 +encoding//src/test/java=UTF-8 +encoding/=UTF-8 diff --git a/group26/mahone2017/mahone/.settings/org.eclipse.jdt.core.prefs b/group26/mahone2017/mahone/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000000..abec6ca389 --- /dev/null +++ b/group26/mahone2017/mahone/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,5 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5 +org.eclipse.jdt.core.compiler.compliance=1.5 +org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning +org.eclipse.jdt.core.compiler.source=1.5 diff --git a/group26/mahone2017/mahone/.settings/org.eclipse.m2e.core.prefs b/group26/mahone2017/mahone/.settings/org.eclipse.m2e.core.prefs new file mode 100644 index 0000000000..f897a7f1cb --- /dev/null +++ b/group26/mahone2017/mahone/.settings/org.eclipse.m2e.core.prefs @@ -0,0 +1,4 @@ +activeProfiles= +eclipse.preferences.version=1 +resolveWorkspaceProjects=true +version=1 diff --git a/group26/mahone2017/mahone/pom.xml b/group26/mahone2017/mahone/pom.xml new file mode 100644 index 0000000000..c93c90b55d --- /dev/null +++ b/group26/mahone2017/mahone/pom.xml @@ -0,0 +1,25 @@ + + 4.0.0 + + study + mahone + 0.0.1-SNAPSHOT + jar + + mahone + http://maven.apache.org + + + UTF-8 + + + + + junit + junit + 3.8.1 + test + + + diff --git a/group26/mahone2017/mahone/src/main/java/com/coding/basic/ArrayList.java b/group26/mahone2017/mahone/src/main/java/com/coding/basic/ArrayList.java new file mode 100644 index 0000000000..613513b9a6 --- /dev/null +++ b/group26/mahone2017/mahone/src/main/java/com/coding/basic/ArrayList.java @@ -0,0 +1,77 @@ +package com.coding.basic; + +/** + * + * @author Mahone Wu + * @data:2017-03-10 + * @description:ArrayList的自我实现 + * @version:1.0.0 + */ + +public class ArrayList implements List { + + //数组存储数据大小 + private int size = 0; + + //数组 + private Object[] elementData = new Object[100]; + + /** + * 新增元素 + */ + public void add(Object o){ + elementData[size] = o; + size++; + } + + /** + * 指定位置新增数据 + */ + public void add(int index, Object o){ + //保存现在该位置有的元素 + Object temp =elementData[index]; + + //如果当前存放数据等于初始化数组大小,则数组需要进行扩容操作 + if(elementData.length == size){ + //TODO + } + //如果没有超过大小,则把从插入开始点的数据都往后移一位 + for (int i =size;i>index;i--){ + elementData[i] = elementData[i-1]; + } + //将现在赋值的数据放到该位置 + elementData[index] = o; + size++; + } + + /** + * 获取数据 + */ + public Object get(int index){ + if(index > elementData.length){ + return null; + } + return elementData[index]; + } + + //返回要删除的数据 + public Object remove(int index){ + //要被删除的数据 + Object data = elementData[index]; + for (int i =index;i7->10 , 逆置后变为 10->7->3 + */ + public void reverse(){ + + } + + /** + * 删除一个单链表的前半部分 + * 例如:list = 2->5->7->8 , 删除以后的值为 7->8 + * 如果list = 2->5->7->8->10 ,删除以后的值为7,8,10 + + */ + public void removeFirstHalf(){ + + } + + /** + * 从第i个元素开始, 删除length 个元素 , 注意i从0开始 + * @param i + * @param length + */ + public void remove(int i, int length){ + + } + /** + * 假定当前链表和listB均包含已升序排列的整数 + * 从当前链表中取出那些listB所指定的元素 + * 例如当前链表 = 11->101->201->301->401->501->601->701 + * listB = 1->3->4->6 + * 返回的结果应该是[101,301,401,601] + * @param list + */ + public int[] getElements(LinkedList list){ + return null; + } + + /** + * 已知链表中的元素以值递增有序排列,并以单链表作存储结构。 + * 从当前链表中中删除在listB中出现的元素 + + * @param list + */ + + public void subtract(LinkedList list){ + + } + + /** + * 已知当前链表中的元素以值递增有序排列,并以单链表作存储结构。 + * 删除表中所有值相同的多余元素(使得操作后的线性表中所有元素的值均不相同) + */ + public void removeDuplicateValues(){ + + } + + /** + * 已知链表中的元素以值递增有序排列,并以单链表作存储结构。 + * 试写一高效的算法,删除表中所有值大于min且小于max的元素(若表中存在这样的元素) + * @param min + * @param max + */ + public void removeRange(int min, int max){ + + } + + /** + * 假设当前链表和参数list指定的链表均以元素依值递增有序排列(同一表中的元素值各不相同) + * 现要求生成新链表C,其元素为当前链表和list中元素的交集,且表C中的元素有依值递增有序排列 + * @param list + */ + public LinkedList intersection( LinkedList list){ + return null; + } +} diff --git a/group26/mahone2017/mahone/src/main/java/com/coding/basic/List.java b/group26/mahone2017/mahone/src/main/java/com/coding/basic/List.java new file mode 100644 index 0000000000..396b1f6416 --- /dev/null +++ b/group26/mahone2017/mahone/src/main/java/com/coding/basic/List.java @@ -0,0 +1,9 @@ +package com.coding.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/group26/mahone2017/mahone/src/main/java/com/coding/basic/Queue.java b/group26/mahone2017/mahone/src/main/java/com/coding/basic/Queue.java new file mode 100644 index 0000000000..08d2d86b14 --- /dev/null +++ b/group26/mahone2017/mahone/src/main/java/com/coding/basic/Queue.java @@ -0,0 +1,19 @@ +package com.coding.basic; + +public class Queue { + + public void enQueue(Object o){ + } + + public Object deQueue(){ + return null; + } + + public boolean isEmpty(){ + return false; + } + + public int size(){ + return -1; + } +} diff --git a/group26/mahone2017/mahone/src/main/java/com/coding/basic/Stack.java b/group26/mahone2017/mahone/src/main/java/com/coding/basic/Stack.java new file mode 100644 index 0000000000..4bfe28057f --- /dev/null +++ b/group26/mahone2017/mahone/src/main/java/com/coding/basic/Stack.java @@ -0,0 +1,22 @@ +package com.coding.basic; + +public class Stack { + private ArrayList elementData = new ArrayList(); + + public void push(Object o){ + } + + public Object pop(){ + return null; + } + + public Object peek(){ + return null; + } + public boolean isEmpty(){ + return false; + } + public int size(){ + return -1; + } +} diff --git a/group26/mahone2017/mahone/src/main/java/study/mahone/App.java b/group26/mahone2017/mahone/src/main/java/study/mahone/App.java new file mode 100644 index 0000000000..dea63bd7b5 --- /dev/null +++ b/group26/mahone2017/mahone/src/main/java/study/mahone/App.java @@ -0,0 +1,13 @@ +package study.mahone; + +/** + * Hello world! + * + */ +public class App +{ + public static void main( String[] args ) + { + System.out.println( "Hello World!" ); + } +} diff --git a/group26/mahone2017/mahone/src/test/java/study/mahone/AppTest.java b/group26/mahone2017/mahone/src/test/java/study/mahone/AppTest.java new file mode 100644 index 0000000000..99142c8e03 --- /dev/null +++ b/group26/mahone2017/mahone/src/test/java/study/mahone/AppTest.java @@ -0,0 +1,38 @@ +package study.mahone; + +import junit.framework.Test; +import junit.framework.TestCase; +import junit.framework.TestSuite; + +/** + * Unit test for simple App. + */ +public class AppTest + extends TestCase +{ + /** + * Create the test case + * + * @param testName name of the test case + */ + public AppTest( String testName ) + { + super( testName ); + } + + /** + * @return the suite of tests being tested + */ + public static Test suite() + { + return new TestSuite( AppTest.class ); + } + + /** + * Rigourous Test :-) + */ + public void testApp() + { + assertTrue( true ); + } +} From afe888bb28fb69e90c49dba5efbf10cbc409a1c1 Mon Sep 17 00:00:00 2001 From: "mwu@xtremeprog.com" Date: Fri, 10 Mar 2017 22:10:59 +0800 Subject: [PATCH 02/28] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E5=BF=BD=E8=A7=86?= =?UTF-8?q?=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.gitignore b/.gitignore index 6945ca9d30..4f78db6dbb 100644 --- a/.gitignore +++ b/.gitignore @@ -23,4 +23,8 @@ rebel.* .rebel.* target +*.DS_Store +liuxin/.DS_Store +liuxin/src/.DS_Store + From 8744a431ea514a9e852abd7bd0ed29b9db2d1d41 Mon Sep 17 00:00:00 2001 From: "mwu@xtremeprog.com" Date: Fri, 10 Mar 2017 22:13:37 +0800 Subject: [PATCH 03/28] =?UTF-8?q?=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mahone/src/main/java/com/coding/basic/ArrayList.java | 1 + 1 file changed, 1 insertion(+) diff --git a/group26/mahone2017/mahone/src/main/java/com/coding/basic/ArrayList.java b/group26/mahone2017/mahone/src/main/java/com/coding/basic/ArrayList.java index 613513b9a6..36955853aa 100644 --- a/group26/mahone2017/mahone/src/main/java/com/coding/basic/ArrayList.java +++ b/group26/mahone2017/mahone/src/main/java/com/coding/basic/ArrayList.java @@ -54,6 +54,7 @@ public Object get(int index){ return elementData[index]; } + //返回要删除的数据 public Object remove(int index){ //要被删除的数据 From 951a824ef566e3d13e4119fc55b2a7280e727c67 Mon Sep 17 00:00:00 2001 From: "mwu@xtremeprog.com" Date: Fri, 10 Mar 2017 22:15:16 +0800 Subject: [PATCH 04/28] hah --- .../mahone/src/main/java/com/coding/basic/ArrayList.java | 1 - 1 file changed, 1 deletion(-) diff --git a/group26/mahone2017/mahone/src/main/java/com/coding/basic/ArrayList.java b/group26/mahone2017/mahone/src/main/java/com/coding/basic/ArrayList.java index 36955853aa..613513b9a6 100644 --- a/group26/mahone2017/mahone/src/main/java/com/coding/basic/ArrayList.java +++ b/group26/mahone2017/mahone/src/main/java/com/coding/basic/ArrayList.java @@ -54,7 +54,6 @@ public Object get(int index){ return elementData[index]; } - //返回要删除的数据 public Object remove(int index){ //要被删除的数据 From 60cface7d22b5fac678e431505aaba0fefd35d9e Mon Sep 17 00:00:00 2001 From: "mwu@xtremeprog.com" Date: Fri, 10 Mar 2017 22:18:04 +0800 Subject: [PATCH 05/28] 123 --- .../mahone/src/main/java/com/coding/basic/ArrayList.java | 1 + 1 file changed, 1 insertion(+) diff --git a/group26/mahone2017/mahone/src/main/java/com/coding/basic/ArrayList.java b/group26/mahone2017/mahone/src/main/java/com/coding/basic/ArrayList.java index 613513b9a6..36955853aa 100644 --- a/group26/mahone2017/mahone/src/main/java/com/coding/basic/ArrayList.java +++ b/group26/mahone2017/mahone/src/main/java/com/coding/basic/ArrayList.java @@ -54,6 +54,7 @@ public Object get(int index){ return elementData[index]; } + //返回要删除的数据 public Object remove(int index){ //要被删除的数据 From 36bbee70c12de122d264556d2b1374b2315ede9b Mon Sep 17 00:00:00 2001 From: "mwu@xtremeprog.com" Date: Fri, 10 Mar 2017 22:22:09 +0800 Subject: [PATCH 06/28] 123 --- .../mahone/src/main/java/com/coding/basic/ArrayList.java | 1 - 1 file changed, 1 deletion(-) diff --git a/group26/mahone2017/mahone/src/main/java/com/coding/basic/ArrayList.java b/group26/mahone2017/mahone/src/main/java/com/coding/basic/ArrayList.java index 36955853aa..613513b9a6 100644 --- a/group26/mahone2017/mahone/src/main/java/com/coding/basic/ArrayList.java +++ b/group26/mahone2017/mahone/src/main/java/com/coding/basic/ArrayList.java @@ -54,7 +54,6 @@ public Object get(int index){ return elementData[index]; } - //返回要删除的数据 public Object remove(int index){ //要被删除的数据 From dcc67bfecbfca2b73d5fa05aa4c9d946161b99e4 Mon Sep 17 00:00:00 2001 From: "mwu@xtremeprog.com" Date: Sat, 11 Mar 2017 11:15:53 +0800 Subject: [PATCH 07/28] =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- group26/mahone2017/123.txt | 0 group26/mahone2017/mahone/.classpath | 22 ---- group26/mahone2017/mahone/.project | 23 ---- .../org.eclipse.core.resources.prefs | 4 - .../.settings/org.eclipse.jdt.core.prefs | 5 - .../.settings/org.eclipse.m2e.core.prefs | 4 - group26/mahone2017/mahone/pom.xml | 25 ---- .../main/java/com/coding/basic/ArrayList.java | 77 ----------- .../java/com/coding/basic/BinaryTreeNode.java | 32 ----- .../main/java/com/coding/basic/Iterator.java | 7 - .../java/com/coding/basic/LinkedList.java | 122 ------------------ .../src/main/java/com/coding/basic/List.java | 9 -- .../src/main/java/com/coding/basic/Queue.java | 19 --- .../src/main/java/com/coding/basic/Stack.java | 22 ---- .../src/main/java/study/mahone/App.java | 13 -- .../src/test/java/study/mahone/AppTest.java | 38 ------ 16 files changed, 422 deletions(-) delete mode 100644 group26/mahone2017/123.txt delete mode 100644 group26/mahone2017/mahone/.classpath delete mode 100644 group26/mahone2017/mahone/.project delete mode 100644 group26/mahone2017/mahone/.settings/org.eclipse.core.resources.prefs delete mode 100644 group26/mahone2017/mahone/.settings/org.eclipse.jdt.core.prefs delete mode 100644 group26/mahone2017/mahone/.settings/org.eclipse.m2e.core.prefs delete mode 100644 group26/mahone2017/mahone/pom.xml delete mode 100644 group26/mahone2017/mahone/src/main/java/com/coding/basic/ArrayList.java delete mode 100644 group26/mahone2017/mahone/src/main/java/com/coding/basic/BinaryTreeNode.java delete mode 100644 group26/mahone2017/mahone/src/main/java/com/coding/basic/Iterator.java delete mode 100644 group26/mahone2017/mahone/src/main/java/com/coding/basic/LinkedList.java delete mode 100644 group26/mahone2017/mahone/src/main/java/com/coding/basic/List.java delete mode 100644 group26/mahone2017/mahone/src/main/java/com/coding/basic/Queue.java delete mode 100644 group26/mahone2017/mahone/src/main/java/com/coding/basic/Stack.java delete mode 100644 group26/mahone2017/mahone/src/main/java/study/mahone/App.java delete mode 100644 group26/mahone2017/mahone/src/test/java/study/mahone/AppTest.java diff --git a/group26/mahone2017/123.txt b/group26/mahone2017/123.txt deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/group26/mahone2017/mahone/.classpath b/group26/mahone2017/mahone/.classpath deleted file mode 100644 index 6908d0b2ae..0000000000 --- a/group26/mahone2017/mahone/.classpath +++ /dev/null @@ -1,22 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - diff --git a/group26/mahone2017/mahone/.project b/group26/mahone2017/mahone/.project deleted file mode 100644 index d392a9a466..0000000000 --- a/group26/mahone2017/mahone/.project +++ /dev/null @@ -1,23 +0,0 @@ - - - mahone - - - - - - org.eclipse.jdt.core.javabuilder - - - - - org.eclipse.m2e.core.maven2Builder - - - - - - org.eclipse.jdt.core.javanature - org.eclipse.m2e.core.maven2Nature - - diff --git a/group26/mahone2017/mahone/.settings/org.eclipse.core.resources.prefs b/group26/mahone2017/mahone/.settings/org.eclipse.core.resources.prefs deleted file mode 100644 index f9fe34593f..0000000000 --- a/group26/mahone2017/mahone/.settings/org.eclipse.core.resources.prefs +++ /dev/null @@ -1,4 +0,0 @@ -eclipse.preferences.version=1 -encoding//src/main/java=UTF-8 -encoding//src/test/java=UTF-8 -encoding/=UTF-8 diff --git a/group26/mahone2017/mahone/.settings/org.eclipse.jdt.core.prefs b/group26/mahone2017/mahone/.settings/org.eclipse.jdt.core.prefs deleted file mode 100644 index abec6ca389..0000000000 --- a/group26/mahone2017/mahone/.settings/org.eclipse.jdt.core.prefs +++ /dev/null @@ -1,5 +0,0 @@ -eclipse.preferences.version=1 -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5 -org.eclipse.jdt.core.compiler.compliance=1.5 -org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning -org.eclipse.jdt.core.compiler.source=1.5 diff --git a/group26/mahone2017/mahone/.settings/org.eclipse.m2e.core.prefs b/group26/mahone2017/mahone/.settings/org.eclipse.m2e.core.prefs deleted file mode 100644 index f897a7f1cb..0000000000 --- a/group26/mahone2017/mahone/.settings/org.eclipse.m2e.core.prefs +++ /dev/null @@ -1,4 +0,0 @@ -activeProfiles= -eclipse.preferences.version=1 -resolveWorkspaceProjects=true -version=1 diff --git a/group26/mahone2017/mahone/pom.xml b/group26/mahone2017/mahone/pom.xml deleted file mode 100644 index c93c90b55d..0000000000 --- a/group26/mahone2017/mahone/pom.xml +++ /dev/null @@ -1,25 +0,0 @@ - - 4.0.0 - - study - mahone - 0.0.1-SNAPSHOT - jar - - mahone - http://maven.apache.org - - - UTF-8 - - - - - junit - junit - 3.8.1 - test - - - diff --git a/group26/mahone2017/mahone/src/main/java/com/coding/basic/ArrayList.java b/group26/mahone2017/mahone/src/main/java/com/coding/basic/ArrayList.java deleted file mode 100644 index 613513b9a6..0000000000 --- a/group26/mahone2017/mahone/src/main/java/com/coding/basic/ArrayList.java +++ /dev/null @@ -1,77 +0,0 @@ -package com.coding.basic; - -/** - * - * @author Mahone Wu - * @data:2017-03-10 - * @description:ArrayList的自我实现 - * @version:1.0.0 - */ - -public class ArrayList implements List { - - //数组存储数据大小 - private int size = 0; - - //数组 - private Object[] elementData = new Object[100]; - - /** - * 新增元素 - */ - public void add(Object o){ - elementData[size] = o; - size++; - } - - /** - * 指定位置新增数据 - */ - public void add(int index, Object o){ - //保存现在该位置有的元素 - Object temp =elementData[index]; - - //如果当前存放数据等于初始化数组大小,则数组需要进行扩容操作 - if(elementData.length == size){ - //TODO - } - //如果没有超过大小,则把从插入开始点的数据都往后移一位 - for (int i =size;i>index;i--){ - elementData[i] = elementData[i-1]; - } - //将现在赋值的数据放到该位置 - elementData[index] = o; - size++; - } - - /** - * 获取数据 - */ - public Object get(int index){ - if(index > elementData.length){ - return null; - } - return elementData[index]; - } - - //返回要删除的数据 - public Object remove(int index){ - //要被删除的数据 - Object data = elementData[index]; - for (int i =index;i7->10 , 逆置后变为 10->7->3 - */ - public void reverse(){ - - } - - /** - * 删除一个单链表的前半部分 - * 例如:list = 2->5->7->8 , 删除以后的值为 7->8 - * 如果list = 2->5->7->8->10 ,删除以后的值为7,8,10 - - */ - public void removeFirstHalf(){ - - } - - /** - * 从第i个元素开始, 删除length 个元素 , 注意i从0开始 - * @param i - * @param length - */ - public void remove(int i, int length){ - - } - /** - * 假定当前链表和listB均包含已升序排列的整数 - * 从当前链表中取出那些listB所指定的元素 - * 例如当前链表 = 11->101->201->301->401->501->601->701 - * listB = 1->3->4->6 - * 返回的结果应该是[101,301,401,601] - * @param list - */ - public int[] getElements(LinkedList list){ - return null; - } - - /** - * 已知链表中的元素以值递增有序排列,并以单链表作存储结构。 - * 从当前链表中中删除在listB中出现的元素 - - * @param list - */ - - public void subtract(LinkedList list){ - - } - - /** - * 已知当前链表中的元素以值递增有序排列,并以单链表作存储结构。 - * 删除表中所有值相同的多余元素(使得操作后的线性表中所有元素的值均不相同) - */ - public void removeDuplicateValues(){ - - } - - /** - * 已知链表中的元素以值递增有序排列,并以单链表作存储结构。 - * 试写一高效的算法,删除表中所有值大于min且小于max的元素(若表中存在这样的元素) - * @param min - * @param max - */ - public void removeRange(int min, int max){ - - } - - /** - * 假设当前链表和参数list指定的链表均以元素依值递增有序排列(同一表中的元素值各不相同) - * 现要求生成新链表C,其元素为当前链表和list中元素的交集,且表C中的元素有依值递增有序排列 - * @param list - */ - public LinkedList intersection( LinkedList list){ - return null; - } -} diff --git a/group26/mahone2017/mahone/src/main/java/com/coding/basic/List.java b/group26/mahone2017/mahone/src/main/java/com/coding/basic/List.java deleted file mode 100644 index 396b1f6416..0000000000 --- a/group26/mahone2017/mahone/src/main/java/com/coding/basic/List.java +++ /dev/null @@ -1,9 +0,0 @@ -package com.coding.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/group26/mahone2017/mahone/src/main/java/com/coding/basic/Queue.java b/group26/mahone2017/mahone/src/main/java/com/coding/basic/Queue.java deleted file mode 100644 index 08d2d86b14..0000000000 --- a/group26/mahone2017/mahone/src/main/java/com/coding/basic/Queue.java +++ /dev/null @@ -1,19 +0,0 @@ -package com.coding.basic; - -public class Queue { - - public void enQueue(Object o){ - } - - public Object deQueue(){ - return null; - } - - public boolean isEmpty(){ - return false; - } - - public int size(){ - return -1; - } -} diff --git a/group26/mahone2017/mahone/src/main/java/com/coding/basic/Stack.java b/group26/mahone2017/mahone/src/main/java/com/coding/basic/Stack.java deleted file mode 100644 index 4bfe28057f..0000000000 --- a/group26/mahone2017/mahone/src/main/java/com/coding/basic/Stack.java +++ /dev/null @@ -1,22 +0,0 @@ -package com.coding.basic; - -public class Stack { - private ArrayList elementData = new ArrayList(); - - public void push(Object o){ - } - - public Object pop(){ - return null; - } - - public Object peek(){ - return null; - } - public boolean isEmpty(){ - return false; - } - public int size(){ - return -1; - } -} diff --git a/group26/mahone2017/mahone/src/main/java/study/mahone/App.java b/group26/mahone2017/mahone/src/main/java/study/mahone/App.java deleted file mode 100644 index dea63bd7b5..0000000000 --- a/group26/mahone2017/mahone/src/main/java/study/mahone/App.java +++ /dev/null @@ -1,13 +0,0 @@ -package study.mahone; - -/** - * Hello world! - * - */ -public class App -{ - public static void main( String[] args ) - { - System.out.println( "Hello World!" ); - } -} diff --git a/group26/mahone2017/mahone/src/test/java/study/mahone/AppTest.java b/group26/mahone2017/mahone/src/test/java/study/mahone/AppTest.java deleted file mode 100644 index 99142c8e03..0000000000 --- a/group26/mahone2017/mahone/src/test/java/study/mahone/AppTest.java +++ /dev/null @@ -1,38 +0,0 @@ -package study.mahone; - -import junit.framework.Test; -import junit.framework.TestCase; -import junit.framework.TestSuite; - -/** - * Unit test for simple App. - */ -public class AppTest - extends TestCase -{ - /** - * Create the test case - * - * @param testName name of the test case - */ - public AppTest( String testName ) - { - super( testName ); - } - - /** - * @return the suite of tests being tested - */ - public static Test suite() - { - return new TestSuite( AppTest.class ); - } - - /** - * Rigourous Test :-) - */ - public void testApp() - { - assertTrue( true ); - } -} From f5d41e6ce80444bcad7f61b0902110de462a2c85 Mon Sep 17 00:00:00 2001 From: "mwu@xtremeprog.com" Date: Sat, 11 Mar 2017 11:29:17 +0800 Subject: [PATCH 08/28] =?UTF-8?q?=E5=8F=98=E5=8A=A8=E7=9B=AE=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- group26/2070509107/.classpath | 22 +++ group26/2070509107/.project | 23 +++ .../main/java/com/coding/basic/ArrayList.java | 91 ++++++++++++ .../java/com/coding/basic/BinaryTreeNode.java | 32 +++++ .../main/java/com/coding/basic/Iterator.java | 7 + .../java/com/coding/basic/LinkedList.java | 131 ++++++++++++++++++ .../src/main/java/com/coding/basic/List.java | 9 ++ .../src/main/java/com/coding/basic/Queue.java | 20 +++ .../src/main/java/com/coding/basic/Stack.java | 64 +++++++++ .../src/main/java/com/coding/basic/Test.java | 9 ++ .../src/test/java/study/mahone/AppTest.java | 38 +++++ 11 files changed, 446 insertions(+) create mode 100644 group26/2070509107/.classpath create mode 100644 group26/2070509107/.project create mode 100644 group26/2070509107/src/main/java/com/coding/basic/ArrayList.java create mode 100644 group26/2070509107/src/main/java/com/coding/basic/BinaryTreeNode.java create mode 100644 group26/2070509107/src/main/java/com/coding/basic/Iterator.java create mode 100644 group26/2070509107/src/main/java/com/coding/basic/LinkedList.java create mode 100644 group26/2070509107/src/main/java/com/coding/basic/List.java create mode 100644 group26/2070509107/src/main/java/com/coding/basic/Queue.java create mode 100644 group26/2070509107/src/main/java/com/coding/basic/Stack.java create mode 100644 group26/2070509107/src/main/java/com/coding/basic/Test.java create mode 100644 group26/2070509107/src/test/java/study/mahone/AppTest.java diff --git a/group26/2070509107/.classpath b/group26/2070509107/.classpath new file mode 100644 index 0000000000..6908d0b2ae --- /dev/null +++ b/group26/2070509107/.classpath @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + + + + + + + + diff --git a/group26/2070509107/.project b/group26/2070509107/.project new file mode 100644 index 0000000000..d392a9a466 --- /dev/null +++ b/group26/2070509107/.project @@ -0,0 +1,23 @@ + + + mahone + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.m2e.core.maven2Builder + + + + + + org.eclipse.jdt.core.javanature + org.eclipse.m2e.core.maven2Nature + + diff --git a/group26/2070509107/src/main/java/com/coding/basic/ArrayList.java b/group26/2070509107/src/main/java/com/coding/basic/ArrayList.java new file mode 100644 index 0000000000..b59af322f0 --- /dev/null +++ b/group26/2070509107/src/main/java/com/coding/basic/ArrayList.java @@ -0,0 +1,91 @@ +package com.coding.basic; + +/** + * + * @author Mahone Wu + * @data:2017-03-10 + * @description:ArrayList的自我实现 + * @version:1.0.0 + */ + +public class ArrayList implements List { + + //数组存储数据大小 + private int size = 0; + + //数组 + private Object[] elementData = new Object[100]; + + /** + * 新增元素 + */ + public void add(Object o){ + elementData[size] = o; + size++; + } + + /** + * 指定位置新增数据 + */ + public void add(int index, Object o){ + //保存现在该位置有的元素 + Object temp =elementData[index]; + + //如果当前存放数据等于初始化数组大小,则数组需要进行扩容操作 + if(elementData.length == size){ + //TODO + } + //如果没有超过大小,则把从插入开始点的数据都往后移一位 + for (int i =size;i>index;i--){ + elementData[i] = elementData[i-1]; + } + //将现在赋值的数据放到该位置 + elementData[index] = o; + size++; + } + + /** + * 获取数据 + */ + public Object get(int index){ + if(index > elementData.length){ + return null; + } + return elementData[index]; + } + + //返回要删除的数据 + public Object remove(int index){ + //要被删除的数据 + Object data = elementData[index]; + for (int i =index;i7->10 , 逆置后变为 10->7->3 + */ + public void reverse(){ + + } + + /** + * 删除一个单链表的前半部分 + * 例如:list = 2->5->7->8 , 删除以后的值为 7->8 + * 如果list = 2->5->7->8->10 ,删除以后的值为7,8,10 + + */ + public void removeFirstHalf(){ + + } + + /** + * 从第i个元素开始, 删除length 个元素 , 注意i从0开始 + * @param i + * @param length + */ + public void remove(int i, int length){ + + } + /** + * 假定当前链表和listB均包含已升序排列的整数 + * 从当前链表中取出那些listB所指定的元素 + * 例如当前链表 = 11->101->201->301->401->501->601->701 + * listB = 1->3->4->6 + * 返回的结果应该是[101,301,401,601] + * @param list + */ + public int[] getElements(LinkedList list){ + return null; + } + + /** + * 已知链表中的元素以值递增有序排列,并以单链表作存储结构。 + * 从当前链表中中删除在listB中出现的元素 + + * @param list + */ + + public void subtract(LinkedList list){ + + } + + /** + * 已知当前链表中的元素以值递增有序排列,并以单链表作存储结构。 + * 删除表中所有值相同的多余元素(使得操作后的线性表中所有元素的值均不相同) + */ + public void removeDuplicateValues(){ + + } + + /** + * 已知链表中的元素以值递增有序排列,并以单链表作存储结构。 + * 试写一高效的算法,删除表中所有值大于min且小于max的元素(若表中存在这样的元素) + * @param min + * @param max + */ + public void removeRange(int min, int max){ + + } + + /** + * 假设当前链表和参数list指定的链表均以元素依值递增有序排列(同一表中的元素值各不相同) + * 现要求生成新链表C,其元素为当前链表和list中元素的交集,且表C中的元素有依值递增有序排列 + * @param list + */ + public LinkedList intersection( LinkedList list){ + return null; + } +} diff --git a/group26/2070509107/src/main/java/com/coding/basic/List.java b/group26/2070509107/src/main/java/com/coding/basic/List.java new file mode 100644 index 0000000000..396b1f6416 --- /dev/null +++ b/group26/2070509107/src/main/java/com/coding/basic/List.java @@ -0,0 +1,9 @@ +package com.coding.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/group26/2070509107/src/main/java/com/coding/basic/Queue.java b/group26/2070509107/src/main/java/com/coding/basic/Queue.java new file mode 100644 index 0000000000..2fb7620fc4 --- /dev/null +++ b/group26/2070509107/src/main/java/com/coding/basic/Queue.java @@ -0,0 +1,20 @@ +package com.coding.basic; + +public class Queue { + + public void enQueue(Object o){ + + } + + public Object deQueue(){ + return null; + } + + public boolean isEmpty(){ + return false; + } + + public int size(){ + return -1; + } +} diff --git a/group26/2070509107/src/main/java/com/coding/basic/Stack.java b/group26/2070509107/src/main/java/com/coding/basic/Stack.java new file mode 100644 index 0000000000..ffbd6a8148 --- /dev/null +++ b/group26/2070509107/src/main/java/com/coding/basic/Stack.java @@ -0,0 +1,64 @@ +package com.coding.basic; + +/** + * + * @author wuhao + * @date:2017-03-11 + * @description:栈的实现,栈是先进后出; + * @version:1.0.0 + * + */ +public class Stack { + + private ArrayList elementData = new ArrayList(); + + /** + * 存放元素 + * @param o + */ + public void push(Object o){ + elementData.add(o); + } + + /** + * 弹出元素,从最末尾弹出 + * @return + */ + public Object pop(){ + if(elementData.size()==0){ + return null; + } + return elementData.remove(elementData.size()-1); + } + + /** + * 获取栈定元素 + * @return + */ + public Object peek(){ + if(elementData.size()==0){ + return null; + } + return elementData.get(elementData.size()); + } + + /** + * 判断是否为空 + * @return + */ + public boolean isEmpty(){ + if(0 == elementData.size()){ + return false; + } + return true; + } + + /** + * 栈大小 + * @return + */ + public int size(){ + return elementData.size(); + } + +} diff --git a/group26/2070509107/src/main/java/com/coding/basic/Test.java b/group26/2070509107/src/main/java/com/coding/basic/Test.java new file mode 100644 index 0000000000..cfbfce7bb7 --- /dev/null +++ b/group26/2070509107/src/main/java/com/coding/basic/Test.java @@ -0,0 +1,9 @@ +package com.coding.basic; + +public class Test { + + public static void main(String[] args) { + + } + +} diff --git a/group26/2070509107/src/test/java/study/mahone/AppTest.java b/group26/2070509107/src/test/java/study/mahone/AppTest.java new file mode 100644 index 0000000000..99142c8e03 --- /dev/null +++ b/group26/2070509107/src/test/java/study/mahone/AppTest.java @@ -0,0 +1,38 @@ +package study.mahone; + +import junit.framework.Test; +import junit.framework.TestCase; +import junit.framework.TestSuite; + +/** + * Unit test for simple App. + */ +public class AppTest + extends TestCase +{ + /** + * Create the test case + * + * @param testName name of the test case + */ + public AppTest( String testName ) + { + super( testName ); + } + + /** + * @return the suite of tests being tested + */ + public static Test suite() + { + return new TestSuite( AppTest.class ); + } + + /** + * Rigourous Test :-) + */ + public void testApp() + { + assertTrue( true ); + } +} From b4387e45eda467a45bf86271523208b793489a56 Mon Sep 17 00:00:00 2001 From: "mwu@xtremeprog.com" Date: Sat, 11 Mar 2017 11:33:13 +0800 Subject: [PATCH 09/28] =?UTF-8?q?=E5=BF=BD=E8=A7=86=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- group26/2070509107/.gitignore | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 group26/2070509107/.gitignore diff --git a/group26/2070509107/.gitignore b/group26/2070509107/.gitignore new file mode 100644 index 0000000000..32868bd20c --- /dev/null +++ b/group26/2070509107/.gitignore @@ -0,0 +1,2 @@ +.classpath +.project From 8407f1d22fd2d516c1659d79eee38cc4b24f95cc Mon Sep 17 00:00:00 2001 From: "mwu@xtremeprog.com" Date: Sat, 11 Mar 2017 11:35:08 +0800 Subject: [PATCH 10/28] 123 --- group26/{2070509107 => 123}/.gitignore | 0 .../main/java/com/coding/basic/ArrayList.java | 0 .../java/com/coding/basic/BinaryTreeNode.java | 0 .../main/java/com/coding/basic/Iterator.java | 0 .../java/com/coding/basic/LinkedList.java | 0 .../src/main/java/com/coding/basic/List.java | 0 .../src/main/java/com/coding/basic/Queue.java | 0 .../src/main/java/com/coding/basic/Stack.java | 0 .../src/main/java/com/coding/basic/Test.java | 0 .../src/test/java/study/mahone/AppTest.java | 0 group26/2070509107/.classpath | 22 ------------------ group26/2070509107/.project | 23 ------------------- 12 files changed, 45 deletions(-) rename group26/{2070509107 => 123}/.gitignore (100%) rename group26/{2070509107 => 123}/src/main/java/com/coding/basic/ArrayList.java (100%) rename group26/{2070509107 => 123}/src/main/java/com/coding/basic/BinaryTreeNode.java (100%) rename group26/{2070509107 => 123}/src/main/java/com/coding/basic/Iterator.java (100%) rename group26/{2070509107 => 123}/src/main/java/com/coding/basic/LinkedList.java (100%) rename group26/{2070509107 => 123}/src/main/java/com/coding/basic/List.java (100%) rename group26/{2070509107 => 123}/src/main/java/com/coding/basic/Queue.java (100%) rename group26/{2070509107 => 123}/src/main/java/com/coding/basic/Stack.java (100%) rename group26/{2070509107 => 123}/src/main/java/com/coding/basic/Test.java (100%) rename group26/{2070509107 => 123}/src/test/java/study/mahone/AppTest.java (100%) delete mode 100644 group26/2070509107/.classpath delete mode 100644 group26/2070509107/.project diff --git a/group26/2070509107/.gitignore b/group26/123/.gitignore similarity index 100% rename from group26/2070509107/.gitignore rename to group26/123/.gitignore diff --git a/group26/2070509107/src/main/java/com/coding/basic/ArrayList.java b/group26/123/src/main/java/com/coding/basic/ArrayList.java similarity index 100% rename from group26/2070509107/src/main/java/com/coding/basic/ArrayList.java rename to group26/123/src/main/java/com/coding/basic/ArrayList.java diff --git a/group26/2070509107/src/main/java/com/coding/basic/BinaryTreeNode.java b/group26/123/src/main/java/com/coding/basic/BinaryTreeNode.java similarity index 100% rename from group26/2070509107/src/main/java/com/coding/basic/BinaryTreeNode.java rename to group26/123/src/main/java/com/coding/basic/BinaryTreeNode.java diff --git a/group26/2070509107/src/main/java/com/coding/basic/Iterator.java b/group26/123/src/main/java/com/coding/basic/Iterator.java similarity index 100% rename from group26/2070509107/src/main/java/com/coding/basic/Iterator.java rename to group26/123/src/main/java/com/coding/basic/Iterator.java diff --git a/group26/2070509107/src/main/java/com/coding/basic/LinkedList.java b/group26/123/src/main/java/com/coding/basic/LinkedList.java similarity index 100% rename from group26/2070509107/src/main/java/com/coding/basic/LinkedList.java rename to group26/123/src/main/java/com/coding/basic/LinkedList.java diff --git a/group26/2070509107/src/main/java/com/coding/basic/List.java b/group26/123/src/main/java/com/coding/basic/List.java similarity index 100% rename from group26/2070509107/src/main/java/com/coding/basic/List.java rename to group26/123/src/main/java/com/coding/basic/List.java diff --git a/group26/2070509107/src/main/java/com/coding/basic/Queue.java b/group26/123/src/main/java/com/coding/basic/Queue.java similarity index 100% rename from group26/2070509107/src/main/java/com/coding/basic/Queue.java rename to group26/123/src/main/java/com/coding/basic/Queue.java diff --git a/group26/2070509107/src/main/java/com/coding/basic/Stack.java b/group26/123/src/main/java/com/coding/basic/Stack.java similarity index 100% rename from group26/2070509107/src/main/java/com/coding/basic/Stack.java rename to group26/123/src/main/java/com/coding/basic/Stack.java diff --git a/group26/2070509107/src/main/java/com/coding/basic/Test.java b/group26/123/src/main/java/com/coding/basic/Test.java similarity index 100% rename from group26/2070509107/src/main/java/com/coding/basic/Test.java rename to group26/123/src/main/java/com/coding/basic/Test.java diff --git a/group26/2070509107/src/test/java/study/mahone/AppTest.java b/group26/123/src/test/java/study/mahone/AppTest.java similarity index 100% rename from group26/2070509107/src/test/java/study/mahone/AppTest.java rename to group26/123/src/test/java/study/mahone/AppTest.java diff --git a/group26/2070509107/.classpath b/group26/2070509107/.classpath deleted file mode 100644 index 6908d0b2ae..0000000000 --- a/group26/2070509107/.classpath +++ /dev/null @@ -1,22 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - diff --git a/group26/2070509107/.project b/group26/2070509107/.project deleted file mode 100644 index d392a9a466..0000000000 --- a/group26/2070509107/.project +++ /dev/null @@ -1,23 +0,0 @@ - - - mahone - - - - - - org.eclipse.jdt.core.javabuilder - - - - - org.eclipse.m2e.core.maven2Builder - - - - - - org.eclipse.jdt.core.javanature - org.eclipse.m2e.core.maven2Nature - - From ee6a8d35465408d88d52fc463d0d3c58ad231d5b Mon Sep 17 00:00:00 2001 From: "mwu@xtremeprog.com" Date: Sat, 11 Mar 2017 11:36:10 +0800 Subject: [PATCH 11/28] =?UTF-8?q?=E6=AD=A3=E6=98=AF=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- group26/{123 => 2070509107}/.gitignore | 0 .../src/main/java/com/coding/basic/ArrayList.java | 0 .../src/main/java/com/coding/basic/BinaryTreeNode.java | 0 .../src/main/java/com/coding/basic/Iterator.java | 0 .../src/main/java/com/coding/basic/LinkedList.java | 0 .../{123 => 2070509107}/src/main/java/com/coding/basic/List.java | 0 .../{123 => 2070509107}/src/main/java/com/coding/basic/Queue.java | 0 .../{123 => 2070509107}/src/main/java/com/coding/basic/Stack.java | 0 .../{123 => 2070509107}/src/main/java/com/coding/basic/Test.java | 0 .../{123 => 2070509107}/src/test/java/study/mahone/AppTest.java | 0 10 files changed, 0 insertions(+), 0 deletions(-) rename group26/{123 => 2070509107}/.gitignore (100%) rename group26/{123 => 2070509107}/src/main/java/com/coding/basic/ArrayList.java (100%) rename group26/{123 => 2070509107}/src/main/java/com/coding/basic/BinaryTreeNode.java (100%) rename group26/{123 => 2070509107}/src/main/java/com/coding/basic/Iterator.java (100%) rename group26/{123 => 2070509107}/src/main/java/com/coding/basic/LinkedList.java (100%) rename group26/{123 => 2070509107}/src/main/java/com/coding/basic/List.java (100%) rename group26/{123 => 2070509107}/src/main/java/com/coding/basic/Queue.java (100%) rename group26/{123 => 2070509107}/src/main/java/com/coding/basic/Stack.java (100%) rename group26/{123 => 2070509107}/src/main/java/com/coding/basic/Test.java (100%) rename group26/{123 => 2070509107}/src/test/java/study/mahone/AppTest.java (100%) diff --git a/group26/123/.gitignore b/group26/2070509107/.gitignore similarity index 100% rename from group26/123/.gitignore rename to group26/2070509107/.gitignore diff --git a/group26/123/src/main/java/com/coding/basic/ArrayList.java b/group26/2070509107/src/main/java/com/coding/basic/ArrayList.java similarity index 100% rename from group26/123/src/main/java/com/coding/basic/ArrayList.java rename to group26/2070509107/src/main/java/com/coding/basic/ArrayList.java diff --git a/group26/123/src/main/java/com/coding/basic/BinaryTreeNode.java b/group26/2070509107/src/main/java/com/coding/basic/BinaryTreeNode.java similarity index 100% rename from group26/123/src/main/java/com/coding/basic/BinaryTreeNode.java rename to group26/2070509107/src/main/java/com/coding/basic/BinaryTreeNode.java diff --git a/group26/123/src/main/java/com/coding/basic/Iterator.java b/group26/2070509107/src/main/java/com/coding/basic/Iterator.java similarity index 100% rename from group26/123/src/main/java/com/coding/basic/Iterator.java rename to group26/2070509107/src/main/java/com/coding/basic/Iterator.java diff --git a/group26/123/src/main/java/com/coding/basic/LinkedList.java b/group26/2070509107/src/main/java/com/coding/basic/LinkedList.java similarity index 100% rename from group26/123/src/main/java/com/coding/basic/LinkedList.java rename to group26/2070509107/src/main/java/com/coding/basic/LinkedList.java diff --git a/group26/123/src/main/java/com/coding/basic/List.java b/group26/2070509107/src/main/java/com/coding/basic/List.java similarity index 100% rename from group26/123/src/main/java/com/coding/basic/List.java rename to group26/2070509107/src/main/java/com/coding/basic/List.java diff --git a/group26/123/src/main/java/com/coding/basic/Queue.java b/group26/2070509107/src/main/java/com/coding/basic/Queue.java similarity index 100% rename from group26/123/src/main/java/com/coding/basic/Queue.java rename to group26/2070509107/src/main/java/com/coding/basic/Queue.java diff --git a/group26/123/src/main/java/com/coding/basic/Stack.java b/group26/2070509107/src/main/java/com/coding/basic/Stack.java similarity index 100% rename from group26/123/src/main/java/com/coding/basic/Stack.java rename to group26/2070509107/src/main/java/com/coding/basic/Stack.java diff --git a/group26/123/src/main/java/com/coding/basic/Test.java b/group26/2070509107/src/main/java/com/coding/basic/Test.java similarity index 100% rename from group26/123/src/main/java/com/coding/basic/Test.java rename to group26/2070509107/src/main/java/com/coding/basic/Test.java diff --git a/group26/123/src/test/java/study/mahone/AppTest.java b/group26/2070509107/src/test/java/study/mahone/AppTest.java similarity index 100% rename from group26/123/src/test/java/study/mahone/AppTest.java rename to group26/2070509107/src/test/java/study/mahone/AppTest.java From f6ecb66f4a8f059bf937992edf0099fb5c51f235 Mon Sep 17 00:00:00 2001 From: "mwu@xtremeprog.com" Date: Sat, 11 Mar 2017 11:37:56 +0800 Subject: [PATCH 12/28] =?UTF-8?q?=E5=88=A0=E9=99=A4=E5=A4=9A=E4=BD=99?= =?UTF-8?q?=E7=9B=AE=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/test/java/study/mahone/AppTest.java | 38 ------------------- 1 file changed, 38 deletions(-) delete mode 100644 group26/2070509107/src/test/java/study/mahone/AppTest.java diff --git a/group26/2070509107/src/test/java/study/mahone/AppTest.java b/group26/2070509107/src/test/java/study/mahone/AppTest.java deleted file mode 100644 index 99142c8e03..0000000000 --- a/group26/2070509107/src/test/java/study/mahone/AppTest.java +++ /dev/null @@ -1,38 +0,0 @@ -package study.mahone; - -import junit.framework.Test; -import junit.framework.TestCase; -import junit.framework.TestSuite; - -/** - * Unit test for simple App. - */ -public class AppTest - extends TestCase -{ - /** - * Create the test case - * - * @param testName name of the test case - */ - public AppTest( String testName ) - { - super( testName ); - } - - /** - * @return the suite of tests being tested - */ - public static Test suite() - { - return new TestSuite( AppTest.class ); - } - - /** - * Rigourous Test :-) - */ - public void testApp() - { - assertTrue( true ); - } -} From a8c6e9c64f3909f0a5197b5cab236b42d9ad32d2 Mon Sep 17 00:00:00 2001 From: "mwu@xtremeprog.com" Date: Sat, 11 Mar 2017 11:55:33 +0800 Subject: [PATCH 13/28] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E7=9B=AE=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/basic/collections/ArrayList.java | 90 ++++++++++++ .../src/basic/collections/BinaryTreeNode.java | 39 ++++++ .../src/basic/collections/Iterator.java | 7 + .../src/basic/collections/LinkedList.java | 131 ++++++++++++++++++ .../src/basic/collections/List.java | 9 ++ .../src/basic/collections/Queue.java | 20 +++ .../src/basic/collections/Stack.java | 64 +++++++++ .../src/basic/collections/Test.java | 14 ++ .../src/basic/collections/package-info.java | 8 ++ .../main/java/com/coding/basic/ArrayList.java | 3 +- .../java/com/coding/basic/BinaryTreeNode.java | 7 + .../src/main/java/com/coding/basic/Test.java | 11 +- 12 files changed, 398 insertions(+), 5 deletions(-) create mode 100644 group26/2070509107/src/basic/collections/ArrayList.java create mode 100644 group26/2070509107/src/basic/collections/BinaryTreeNode.java create mode 100644 group26/2070509107/src/basic/collections/Iterator.java create mode 100644 group26/2070509107/src/basic/collections/LinkedList.java create mode 100644 group26/2070509107/src/basic/collections/List.java create mode 100644 group26/2070509107/src/basic/collections/Queue.java create mode 100644 group26/2070509107/src/basic/collections/Stack.java create mode 100644 group26/2070509107/src/basic/collections/Test.java create mode 100644 group26/2070509107/src/basic/collections/package-info.java diff --git a/group26/2070509107/src/basic/collections/ArrayList.java b/group26/2070509107/src/basic/collections/ArrayList.java new file mode 100644 index 0000000000..12a622d7f3 --- /dev/null +++ b/group26/2070509107/src/basic/collections/ArrayList.java @@ -0,0 +1,90 @@ +package collections; + +/** + * + * @author Mahone Wu + * @data:2017-03-10 + * @description:ArrayList的自我实现 + * @version:1.0.0 + */ + +public class ArrayList implements List { + + //数组存储数据大小 + private int size = 0; + + //数组 + private Object[] elementData = new Object[5]; + + /** + * 新增元素 + */ + public void add(Object o){ + elementData[size] = o; + size++; + } + + /** + * 指定位置新增数据 + */ + public void add(int index, Object o){ + //保存现在该位置有的元素 + Object temp =elementData[index]; + + //如果当前存放数据等于初始化数组大小,则数组需要进行扩容操作 + if(elementData.length == size){ + //TODO + } + //如果没有超过大小,则把从插入开始点的数据都往后移一位 + for (int i =size;i>index;i--){ + elementData[i] = elementData[i-1]; + } + //将现在赋值的数据放到该位置 + elementData[index] = o; + size++; + } + + /** + * 获取数据 + */ + public Object get(int index){ + if(index > elementData.length){ + return null; + } + return elementData[index]; + } + + //返回要删除的数据 + public Object remove(int index){ + //要被删除的数据 + Object data = elementData[index]; + for (int i =index;i7->10 , 逆置后变为 10->7->3 + */ + public void reverse(){ + + } + + /** + * 删除一个单链表的前半部分 + * 例如:list = 2->5->7->8 , 删除以后的值为 7->8 + * 如果list = 2->5->7->8->10 ,删除以后的值为7,8,10 + + */ + public void removeFirstHalf(){ + + } + + /** + * 从第i个元素开始, 删除length 个元素 , 注意i从0开始 + * @param i + * @param length + */ + public void remove(int i, int length){ + + } + /** + * 假定当前链表和listB均包含已升序排列的整数 + * 从当前链表中取出那些listB所指定的元素 + * 例如当前链表 = 11->101->201->301->401->501->601->701 + * listB = 1->3->4->6 + * 返回的结果应该是[101,301,401,601] + * @param list + */ + public int[] getElements(LinkedList list){ + return null; + } + + /** + * 已知链表中的元素以值递增有序排列,并以单链表作存储结构。 + * 从当前链表中中删除在listB中出现的元素 + + * @param list + */ + + public void subtract(LinkedList list){ + + } + + /** + * 已知当前链表中的元素以值递增有序排列,并以单链表作存储结构。 + * 删除表中所有值相同的多余元素(使得操作后的线性表中所有元素的值均不相同) + */ + public void removeDuplicateValues(){ + + } + + /** + * 已知链表中的元素以值递增有序排列,并以单链表作存储结构。 + * 试写一高效的算法,删除表中所有值大于min且小于max的元素(若表中存在这样的元素) + * @param min + * @param max + */ + public void removeRange(int min, int max){ + + } + + /** + * 假设当前链表和参数list指定的链表均以元素依值递增有序排列(同一表中的元素值各不相同) + * 现要求生成新链表C,其元素为当前链表和list中元素的交集,且表C中的元素有依值递增有序排列 + * @param list + */ + public LinkedList intersection( LinkedList list){ + return null; + } +} diff --git a/group26/2070509107/src/basic/collections/List.java b/group26/2070509107/src/basic/collections/List.java new file mode 100644 index 0000000000..5cc26ff49f --- /dev/null +++ b/group26/2070509107/src/basic/collections/List.java @@ -0,0 +1,9 @@ +package collections; + +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/group26/2070509107/src/basic/collections/Queue.java b/group26/2070509107/src/basic/collections/Queue.java new file mode 100644 index 0000000000..96f22cffd5 --- /dev/null +++ b/group26/2070509107/src/basic/collections/Queue.java @@ -0,0 +1,20 @@ +package collections; + +public class Queue { + + public void enQueue(Object o){ + + } + + public Object deQueue(){ + return null; + } + + public boolean isEmpty(){ + return false; + } + + public int size(){ + return -1; + } +} diff --git a/group26/2070509107/src/basic/collections/Stack.java b/group26/2070509107/src/basic/collections/Stack.java new file mode 100644 index 0000000000..7edb4a6553 --- /dev/null +++ b/group26/2070509107/src/basic/collections/Stack.java @@ -0,0 +1,64 @@ +package collections; + +/** + * + * @author wuhao + * @date:2017-03-11 + * @description:栈的实现,栈是先进后出; + * @version:1.0.0 + * + */ +public class Stack { + + private ArrayList elementData = new ArrayList(); + + /** + * 存放元素 + * @param o + */ + public void push(Object o){ + elementData.add(o); + } + + /** + * 弹出元素,从最末尾弹出 + * @return + */ + public Object pop(){ + if(elementData.size()==0){ + return null; + } + return elementData.remove(elementData.size()-1); + } + + /** + * 获取栈定元素 + * @return + */ + public Object peek(){ + if(elementData.size()==0){ + return null; + } + return elementData.get(elementData.size()); + } + + /** + * 判断是否为空 + * @return + */ + public boolean isEmpty(){ + if(0 == elementData.size()){ + return false; + } + return true; + } + + /** + * 栈大小 + * @return + */ + public int size(){ + return elementData.size(); + } + +} diff --git a/group26/2070509107/src/basic/collections/Test.java b/group26/2070509107/src/basic/collections/Test.java new file mode 100644 index 0000000000..f1ed1a5e73 --- /dev/null +++ b/group26/2070509107/src/basic/collections/Test.java @@ -0,0 +1,14 @@ +package collections; + +public class Test { + public static void main(String[] args) { + List list =new ArrayList(); + list.add(1); + list.add(1); + list.add(1); + list.add(1); + list.add(1); + list.add(1); + System.out.println(list.size()); + } +} diff --git a/group26/2070509107/src/basic/collections/package-info.java b/group26/2070509107/src/basic/collections/package-info.java new file mode 100644 index 0000000000..6228dce816 --- /dev/null +++ b/group26/2070509107/src/basic/collections/package-info.java @@ -0,0 +1,8 @@ +/** + * + */ +/** + * @author wuhao + * + */ +package collections; \ No newline at end of file diff --git a/group26/2070509107/src/main/java/com/coding/basic/ArrayList.java b/group26/2070509107/src/main/java/com/coding/basic/ArrayList.java index b59af322f0..8a527fc8db 100644 --- a/group26/2070509107/src/main/java/com/coding/basic/ArrayList.java +++ b/group26/2070509107/src/main/java/com/coding/basic/ArrayList.java @@ -14,7 +14,7 @@ public class ArrayList implements List { private int size = 0; //数组 - private Object[] elementData = new Object[100]; + private Object[] elementData = new Object[5]; /** * 新增元素 @@ -79,7 +79,6 @@ public Iterator iterator(){ if(hasNext(current)){ //return elementData[current+1]; } - return null; } diff --git a/group26/2070509107/src/main/java/com/coding/basic/BinaryTreeNode.java b/group26/2070509107/src/main/java/com/coding/basic/BinaryTreeNode.java index 266eff3d56..e3c6553d59 100644 --- a/group26/2070509107/src/main/java/com/coding/basic/BinaryTreeNode.java +++ b/group26/2070509107/src/main/java/com/coding/basic/BinaryTreeNode.java @@ -1,5 +1,12 @@ package com.coding.basic; +/** + * + * @author Mahone Wu + * @data:2017-03-10 + * @description:BinaryTreeNode的自我实现 + * @version:1.0.0 + */ public class BinaryTreeNode { private Object data; diff --git a/group26/2070509107/src/main/java/com/coding/basic/Test.java b/group26/2070509107/src/main/java/com/coding/basic/Test.java index cfbfce7bb7..66c3594f62 100644 --- a/group26/2070509107/src/main/java/com/coding/basic/Test.java +++ b/group26/2070509107/src/main/java/com/coding/basic/Test.java @@ -1,9 +1,14 @@ package com.coding.basic; public class Test { - public static void main(String[] args) { - + List list =new ArrayList(); + list.add(1); + list.add(1); + list.add(1); + list.add(1); + list.add(1); + list.add(1); + System.out.println(list.size()); } - } From 9c7c32f3364c246b1e28897c7c8ff2ebb06ead03 Mon Sep 17 00:00:00 2001 From: "mwu@xtremeprog.com" Date: Sat, 11 Mar 2017 12:08:26 +0800 Subject: [PATCH 14/28] =?UTF-8?q?arraylist=E5=92=8Cstack?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- group26/2070509107/.gitignore | 5 +- .../src/basic/collections/ArrayList.java | 81 +++++------ .../src/basic/collections/BinaryTreeNode.java | 20 +-- .../src/basic/collections/Iterator.java | 1 + .../src/basic/collections/LinkedList.java | 130 ++++++++--------- .../src/basic/collections/List.java | 4 + .../src/basic/collections/Queue.java | 18 +-- .../src/basic/collections/Stack.java | 37 ++--- .../src/basic/collections/Test.java | 3 +- .../src/basic/collections/package-info.java | 8 -- .../main/java/com/coding/basic/ArrayList.java | 90 ------------ .../java/com/coding/basic/BinaryTreeNode.java | 39 ------ .../main/java/com/coding/basic/Iterator.java | 7 - .../java/com/coding/basic/LinkedList.java | 131 ------------------ .../src/main/java/com/coding/basic/List.java | 9 -- .../src/main/java/com/coding/basic/Queue.java | 20 --- .../src/main/java/com/coding/basic/Stack.java | 64 --------- .../src/main/java/com/coding/basic/Test.java | 14 -- 18 files changed, 160 insertions(+), 521 deletions(-) delete mode 100644 group26/2070509107/src/basic/collections/package-info.java delete mode 100644 group26/2070509107/src/main/java/com/coding/basic/ArrayList.java delete mode 100644 group26/2070509107/src/main/java/com/coding/basic/BinaryTreeNode.java delete mode 100644 group26/2070509107/src/main/java/com/coding/basic/Iterator.java delete mode 100644 group26/2070509107/src/main/java/com/coding/basic/LinkedList.java delete mode 100644 group26/2070509107/src/main/java/com/coding/basic/List.java delete mode 100644 group26/2070509107/src/main/java/com/coding/basic/Queue.java delete mode 100644 group26/2070509107/src/main/java/com/coding/basic/Stack.java delete mode 100644 group26/2070509107/src/main/java/com/coding/basic/Test.java diff --git a/group26/2070509107/.gitignore b/group26/2070509107/.gitignore index 32868bd20c..68dd6977c1 100644 --- a/group26/2070509107/.gitignore +++ b/group26/2070509107/.gitignore @@ -1,2 +1,5 @@ -.classpath .project +.settings +pom.xml +./target +.classpath diff --git a/group26/2070509107/src/basic/collections/ArrayList.java b/group26/2070509107/src/basic/collections/ArrayList.java index 12a622d7f3..233b8f1795 100644 --- a/group26/2070509107/src/basic/collections/ArrayList.java +++ b/group26/2070509107/src/basic/collections/ArrayList.java @@ -4,87 +4,88 @@ * * @author Mahone Wu * @data:2017-03-10 - * @description:ArrayList的自我实现 - * @version:1.0.0 + * @description:ArrayList的自我实现 @version:1.0.0 */ public class ArrayList implements List { - - //数组存储数据大小 + + // 数组存储数据大小 private int size = 0; - //数组 - private Object[] elementData = new Object[5]; - + int cap = 5; + + // 数组 + private Object[] elementData = new Object[cap]; + /** * 新增元素 */ - public void add(Object o){ + public void add(Object o) { elementData[size] = o; size++; } - + /** * 指定位置新增数据 */ - public void add(int index, Object o){ - //保存现在该位置有的元素 - Object temp =elementData[index]; - - //如果当前存放数据等于初始化数组大小,则数组需要进行扩容操作 - if(elementData.length == size){ - //TODO + public void add(int index, Object o) { + // 保存现在该位置有的元素 + Object temp = elementData[index]; + + // 如果当前存放数据等于初始化数组大小,则数组需要进行扩容操作 + if (elementData.length == size) { + // TODO } - //如果没有超过大小,则把从插入开始点的数据都往后移一位 - for (int i =size;i>index;i--){ - elementData[i] = elementData[i-1]; + // 如果没有超过大小,则把从插入开始点的数据都往后移一位 + for (int i = size; i > index; i--) { + elementData[i] = elementData[i - 1]; } - //将现在赋值的数据放到该位置 + // 将现在赋值的数据放到该位置 elementData[index] = o; size++; } - + /** * 获取数据 */ - public Object get(int index){ - if(index > elementData.length){ + public Object get(int index) { + if (index > elementData.length) { return null; } return elementData[index]; } - - //返回要删除的数据 - public Object remove(int index){ - //要被删除的数据 + + // 返回要删除的数据 + public Object remove(int index) { + // 要被删除的数据 Object data = elementData[index]; - for (int i =index;i7->10 , 逆置后变为 10->7->3 + * 把该链表逆置 例如链表为 3->7->10 , 逆置后变为 10->7->3 */ - public void reverse(){ - + public void reverse() { + } - - /** - * 删除一个单链表的前半部分 - * 例如:list = 2->5->7->8 , 删除以后的值为 7->8 - * 如果list = 2->5->7->8->10 ,删除以后的值为7,8,10 + /** + * 删除一个单链表的前半部分 例如:list = 2->5->7->8 , 删除以后的值为 7->8 如果list = 2->5->7->8->10 + * ,删除以后的值为7,8,10 + * */ - public void removeFirstHalf(){ - + public void removeFirstHalf() { + } - + /** * 从第i个元素开始, 删除length 个元素 , 注意i从0开始 + * * @param i * @param length */ - public void remove(int i, int length){ - + public void remove(int i, int length) { + } + /** - * 假定当前链表和listB均包含已升序排列的整数 - * 从当前链表中取出那些listB所指定的元素 - * 例如当前链表 = 11->101->201->301->401->501->601->701 - * listB = 1->3->4->6 - * 返回的结果应该是[101,301,401,601] + * 假定当前链表和listB均包含已升序排列的整数 从当前链表中取出那些listB所指定的元素 例如当前链表 = + * 11->101->201->301->401->501->601->701 listB = 1->3->4->6 + * 返回的结果应该是[101,301,401,601] + * * @param list */ - public int[] getElements(LinkedList list){ + public int[] getElements(LinkedList list) { return null; } - - /** - * 已知链表中的元素以值递增有序排列,并以单链表作存储结构。 - * 从当前链表中中删除在listB中出现的元素 + /** + * 已知链表中的元素以值递增有序排列,并以单链表作存储结构。 从当前链表中中删除在listB中出现的元素 + * * @param list */ - - public void subtract(LinkedList list){ - + + public void subtract(LinkedList list) { + } - + /** - * 已知当前链表中的元素以值递增有序排列,并以单链表作存储结构。 - * 删除表中所有值相同的多余元素(使得操作后的线性表中所有元素的值均不相同) + * 已知当前链表中的元素以值递增有序排列,并以单链表作存储结构。 删除表中所有值相同的多余元素(使得操作后的线性表中所有元素的值均不相同) */ - public void removeDuplicateValues(){ - + public void removeDuplicateValues() { + } - + /** - * 已知链表中的元素以值递增有序排列,并以单链表作存储结构。 - * 试写一高效的算法,删除表中所有值大于min且小于max的元素(若表中存在这样的元素) + * 已知链表中的元素以值递增有序排列,并以单链表作存储结构。 试写一高效的算法,删除表中所有值大于min且小于max的元素(若表中存在这样的元素) + * * @param min * @param max */ - public void removeRange(int min, int max){ - + public void removeRange(int min, int max) { + } - + /** * 假设当前链表和参数list指定的链表均以元素依值递增有序排列(同一表中的元素值各不相同) * 现要求生成新链表C,其元素为当前链表和list中元素的交集,且表C中的元素有依值递增有序排列 + * * @param list */ - public LinkedList intersection( LinkedList list){ + public LinkedList intersection(LinkedList list) { return null; } } diff --git a/group26/2070509107/src/basic/collections/List.java b/group26/2070509107/src/basic/collections/List.java index 5cc26ff49f..c4401a476d 100644 --- a/group26/2070509107/src/basic/collections/List.java +++ b/group26/2070509107/src/basic/collections/List.java @@ -2,8 +2,12 @@ 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/group26/2070509107/src/basic/collections/Queue.java b/group26/2070509107/src/basic/collections/Queue.java index 96f22cffd5..49c916dbb6 100644 --- a/group26/2070509107/src/basic/collections/Queue.java +++ b/group26/2070509107/src/basic/collections/Queue.java @@ -1,20 +1,20 @@ package collections; public class Queue { - - public void enQueue(Object o){ - + + public void enQueue(Object o) { + } - - public Object deQueue(){ + + public Object deQueue() { return null; } - - public boolean isEmpty(){ + + public boolean isEmpty() { return false; } - - public int size(){ + + public int size() { return -1; } } diff --git a/group26/2070509107/src/basic/collections/Stack.java b/group26/2070509107/src/basic/collections/Stack.java index 7edb4a6553..bec13a4191 100644 --- a/group26/2070509107/src/basic/collections/Stack.java +++ b/group26/2070509107/src/basic/collections/Stack.java @@ -9,56 +9,61 @@ * */ public class Stack { - + private ArrayList elementData = new ArrayList(); - + /** * 存放元素 + * * @param o */ - public void push(Object o){ + public void push(Object o) { elementData.add(o); } - + /** * 弹出元素,从最末尾弹出 + * * @return */ - public Object pop(){ - if(elementData.size()==0){ + public Object pop() { + if (elementData.size() == 0) { return null; } - return elementData.remove(elementData.size()-1); + return elementData.remove(elementData.size() - 1); } - + /** * 获取栈定元素 + * * @return */ - public Object peek(){ - if(elementData.size()==0){ + public Object peek() { + if (elementData.size() == 0) { return null; } return elementData.get(elementData.size()); } - + /** * 判断是否为空 + * * @return */ - public boolean isEmpty(){ - if(0 == elementData.size()){ + public boolean isEmpty() { + if (0 == elementData.size()) { return false; } return true; } - + /** * 栈大小 + * * @return */ - public int size(){ + public int size() { return elementData.size(); } - + } diff --git a/group26/2070509107/src/basic/collections/Test.java b/group26/2070509107/src/basic/collections/Test.java index f1ed1a5e73..0cc5316cfa 100644 --- a/group26/2070509107/src/basic/collections/Test.java +++ b/group26/2070509107/src/basic/collections/Test.java @@ -2,8 +2,7 @@ public class Test { public static void main(String[] args) { - List list =new ArrayList(); - list.add(1); + List list = new ArrayList(); list.add(1); list.add(1); list.add(1); diff --git a/group26/2070509107/src/basic/collections/package-info.java b/group26/2070509107/src/basic/collections/package-info.java deleted file mode 100644 index 6228dce816..0000000000 --- a/group26/2070509107/src/basic/collections/package-info.java +++ /dev/null @@ -1,8 +0,0 @@ -/** - * - */ -/** - * @author wuhao - * - */ -package collections; \ No newline at end of file diff --git a/group26/2070509107/src/main/java/com/coding/basic/ArrayList.java b/group26/2070509107/src/main/java/com/coding/basic/ArrayList.java deleted file mode 100644 index 8a527fc8db..0000000000 --- a/group26/2070509107/src/main/java/com/coding/basic/ArrayList.java +++ /dev/null @@ -1,90 +0,0 @@ -package com.coding.basic; - -/** - * - * @author Mahone Wu - * @data:2017-03-10 - * @description:ArrayList的自我实现 - * @version:1.0.0 - */ - -public class ArrayList implements List { - - //数组存储数据大小 - private int size = 0; - - //数组 - private Object[] elementData = new Object[5]; - - /** - * 新增元素 - */ - public void add(Object o){ - elementData[size] = o; - size++; - } - - /** - * 指定位置新增数据 - */ - public void add(int index, Object o){ - //保存现在该位置有的元素 - Object temp =elementData[index]; - - //如果当前存放数据等于初始化数组大小,则数组需要进行扩容操作 - if(elementData.length == size){ - //TODO - } - //如果没有超过大小,则把从插入开始点的数据都往后移一位 - for (int i =size;i>index;i--){ - elementData[i] = elementData[i-1]; - } - //将现在赋值的数据放到该位置 - elementData[index] = o; - size++; - } - - /** - * 获取数据 - */ - public Object get(int index){ - if(index > elementData.length){ - return null; - } - return elementData[index]; - } - - //返回要删除的数据 - public Object remove(int index){ - //要被删除的数据 - Object data = elementData[index]; - for (int i =index;i7->10 , 逆置后变为 10->7->3 - */ - public void reverse(){ - - } - - /** - * 删除一个单链表的前半部分 - * 例如:list = 2->5->7->8 , 删除以后的值为 7->8 - * 如果list = 2->5->7->8->10 ,删除以后的值为7,8,10 - - */ - public void removeFirstHalf(){ - - } - - /** - * 从第i个元素开始, 删除length 个元素 , 注意i从0开始 - * @param i - * @param length - */ - public void remove(int i, int length){ - - } - /** - * 假定当前链表和listB均包含已升序排列的整数 - * 从当前链表中取出那些listB所指定的元素 - * 例如当前链表 = 11->101->201->301->401->501->601->701 - * listB = 1->3->4->6 - * 返回的结果应该是[101,301,401,601] - * @param list - */ - public int[] getElements(LinkedList list){ - return null; - } - - /** - * 已知链表中的元素以值递增有序排列,并以单链表作存储结构。 - * 从当前链表中中删除在listB中出现的元素 - - * @param list - */ - - public void subtract(LinkedList list){ - - } - - /** - * 已知当前链表中的元素以值递增有序排列,并以单链表作存储结构。 - * 删除表中所有值相同的多余元素(使得操作后的线性表中所有元素的值均不相同) - */ - public void removeDuplicateValues(){ - - } - - /** - * 已知链表中的元素以值递增有序排列,并以单链表作存储结构。 - * 试写一高效的算法,删除表中所有值大于min且小于max的元素(若表中存在这样的元素) - * @param min - * @param max - */ - public void removeRange(int min, int max){ - - } - - /** - * 假设当前链表和参数list指定的链表均以元素依值递增有序排列(同一表中的元素值各不相同) - * 现要求生成新链表C,其元素为当前链表和list中元素的交集,且表C中的元素有依值递增有序排列 - * @param list - */ - public LinkedList intersection( LinkedList list){ - return null; - } -} diff --git a/group26/2070509107/src/main/java/com/coding/basic/List.java b/group26/2070509107/src/main/java/com/coding/basic/List.java deleted file mode 100644 index 396b1f6416..0000000000 --- a/group26/2070509107/src/main/java/com/coding/basic/List.java +++ /dev/null @@ -1,9 +0,0 @@ -package com.coding.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/group26/2070509107/src/main/java/com/coding/basic/Queue.java b/group26/2070509107/src/main/java/com/coding/basic/Queue.java deleted file mode 100644 index 2fb7620fc4..0000000000 --- a/group26/2070509107/src/main/java/com/coding/basic/Queue.java +++ /dev/null @@ -1,20 +0,0 @@ -package com.coding.basic; - -public class Queue { - - public void enQueue(Object o){ - - } - - public Object deQueue(){ - return null; - } - - public boolean isEmpty(){ - return false; - } - - public int size(){ - return -1; - } -} diff --git a/group26/2070509107/src/main/java/com/coding/basic/Stack.java b/group26/2070509107/src/main/java/com/coding/basic/Stack.java deleted file mode 100644 index ffbd6a8148..0000000000 --- a/group26/2070509107/src/main/java/com/coding/basic/Stack.java +++ /dev/null @@ -1,64 +0,0 @@ -package com.coding.basic; - -/** - * - * @author wuhao - * @date:2017-03-11 - * @description:栈的实现,栈是先进后出; - * @version:1.0.0 - * - */ -public class Stack { - - private ArrayList elementData = new ArrayList(); - - /** - * 存放元素 - * @param o - */ - public void push(Object o){ - elementData.add(o); - } - - /** - * 弹出元素,从最末尾弹出 - * @return - */ - public Object pop(){ - if(elementData.size()==0){ - return null; - } - return elementData.remove(elementData.size()-1); - } - - /** - * 获取栈定元素 - * @return - */ - public Object peek(){ - if(elementData.size()==0){ - return null; - } - return elementData.get(elementData.size()); - } - - /** - * 判断是否为空 - * @return - */ - public boolean isEmpty(){ - if(0 == elementData.size()){ - return false; - } - return true; - } - - /** - * 栈大小 - * @return - */ - public int size(){ - return elementData.size(); - } - -} diff --git a/group26/2070509107/src/main/java/com/coding/basic/Test.java b/group26/2070509107/src/main/java/com/coding/basic/Test.java deleted file mode 100644 index 66c3594f62..0000000000 --- a/group26/2070509107/src/main/java/com/coding/basic/Test.java +++ /dev/null @@ -1,14 +0,0 @@ -package com.coding.basic; - -public class Test { - public static void main(String[] args) { - List list =new ArrayList(); - list.add(1); - list.add(1); - list.add(1); - list.add(1); - list.add(1); - list.add(1); - System.out.println(list.size()); - } -} From 83a0020c9d6c0d0dac47f8808d04435e7beb035b Mon Sep 17 00:00:00 2001 From: MAC Date: Sat, 11 Mar 2017 19:42:32 +0800 Subject: [PATCH 15/28] supple commit readme --- ...73\204\346\203\205\345\206\265\347\273\237\350\256\241.md" | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git "a/group26/26\347\273\204\346\203\205\345\206\265\347\273\237\350\256\241.md" "b/group26/26\347\273\204\346\203\205\345\206\265\347\273\237\350\256\241.md" index 8700b37aaf..b56980dad6 100644 --- "a/group26/26\347\273\204\346\203\205\345\206\265\347\273\237\350\256\241.md" +++ "b/group26/26\347\273\204\346\203\205\345\206\265\347\273\237\350\256\241.md" @@ -4,7 +4,7 @@ | | 文章1 | | | | | | | | | | | JEE-逆水百川 | 已完成 | 完成90% | | | | | | | | | | | 百度 www.baidu.com | | | | | | | | | | -| | | | | | | | | | | | -| | | | | | | | | | | | +| jiaxun1990 | 已完成 | | | | | | | | | | +| | https://goo.gl/Wvz3Od | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | \ No newline at end of file From b64f399b593157906f3d895ecdf708fff74d959b Mon Sep 17 00:00:00 2001 From: BlindingDark <844620174@qq.com> Date: Sat, 11 Mar 2017 23:13:44 +0800 Subject: [PATCH 16/28] =?UTF-8?q?ArrayList=20TestArrayList=20=E7=AD=89?= =?UTF-8?q?=E5=AE=9E=E7=8E=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../1515345281/src/Collection/ArrayList.java | 1 - .../1515345281/src/Collection/LinkedList.java | 397 +++++++++--------- .../src/Collection/TestCollection.java | 1 + .../homework/first/Collection/ArrayList.java | 102 +++++ .../first/Collection/BinaryTreeNode.java | 35 ++ .../homework/first/Collection/Iterator.java | 10 + .../homework/first/Collection/LinkedList.java | 134 ++++++ .../homework/first/Collection/List.java | 10 + .../homework/first/Collection/Queue.java | 19 + .../homework/first/Collection/Stack.java | 22 + .../first/Collection/TestCollection.java | 41 ++ .../src/zhuakuang/homework/first/Main.java | 7 - 12 files changed, 580 insertions(+), 199 deletions(-) create mode 100644 group26/zhuakuang2017/src/zhuakuang/homework/first/Collection/ArrayList.java create mode 100644 group26/zhuakuang2017/src/zhuakuang/homework/first/Collection/BinaryTreeNode.java create mode 100644 group26/zhuakuang2017/src/zhuakuang/homework/first/Collection/Iterator.java create mode 100644 group26/zhuakuang2017/src/zhuakuang/homework/first/Collection/LinkedList.java create mode 100644 group26/zhuakuang2017/src/zhuakuang/homework/first/Collection/List.java create mode 100644 group26/zhuakuang2017/src/zhuakuang/homework/first/Collection/Queue.java create mode 100644 group26/zhuakuang2017/src/zhuakuang/homework/first/Collection/Stack.java create mode 100644 group26/zhuakuang2017/src/zhuakuang/homework/first/Collection/TestCollection.java delete mode 100644 group26/zhuakuang2017/src/zhuakuang/homework/first/Main.java diff --git a/group26/1515345281/src/Collection/ArrayList.java b/group26/1515345281/src/Collection/ArrayList.java index 017fac67e2..fb15e957f2 100644 --- a/group26/1515345281/src/Collection/ArrayList.java +++ b/group26/1515345281/src/Collection/ArrayList.java @@ -1,7 +1,6 @@ package Collection; public class ArrayList implements List { - private int size = 0; private Object[] elementData = new Object[100]; diff --git a/group26/1515345281/src/Collection/LinkedList.java b/group26/1515345281/src/Collection/LinkedList.java index 8a689e187a..3d4a4d496d 100644 --- a/group26/1515345281/src/Collection/LinkedList.java +++ b/group26/1515345281/src/Collection/LinkedList.java @@ -1,195 +1,210 @@ package Collection; public class LinkedList implements List { - - private int theSize=0;//表示该链表的长度 - private Node beginMarker;//链表的头元素 - private Node endMarker;//链表的尾元素 - - //链表的构造方法 - public LinkedList () { - beginMarker = new Node(null, null, null); - endMarker = new Node(null, beginMarker, null); - beginMarker.next=endMarker; - } - - public void add(Object o){ - add(size(),o); - } - public void add(int index , Object o){ - addBefore(getNode(index),o); - } - public Object get(int index){ - return getNode(index).data; - } - public Object remove(int index){ - return remove(getNode(index)); - } - - public int size(){ - return theSize; - } - - public void addFirst(Object o){ - addBefore(getNode(0),o); - } - public void addLast(Object o){ - addBefore(getNode(theSize),o); - } - public Object removeFirst(){ - return remove(getNode(0)); - } - public Object removeLast(){ - return remove(getNode(theSize-1)); - } - public Iterator iterator(){ - return new Itr(); - } - - private class Itr implements Iterator{ - - private Node cursor=beginMarker.next; - @Override - public boolean hasNext() { - - return cursor!=endMarker; - } - - @Override - public Object next() { - - Object o=cursor.data; - cursor=cursor.next; - - return o; - } - - } - private Object remove(Node node) { - node.prev.next=node.next; - node.next.prev=node.prev; - theSize--; - return node.data; - } - - private Node getNode(int index){ - Node p; - if(index<0 || index>size()){ - throw new IndexOutOfBoundsException(); - } - if(index==-1){ - return beginMarker; - }else if(index==theSize){ - return endMarker; - } - if(indexindex;i--){ - p=p.prev; - } - } - return p; - } - - private void addBefore(Node node,Object o){ - Node newNode=new Node(o,node.prev,node); - newNode.prev.next=newNode; - node.prev=newNode; - theSize++; - //nodeCount++; - } - - private static class Node{ - public Object data; - public Node next; - public Node prev; - public Node(Object data,Node prev,Node next){ - this.data=data; - this.prev=prev; - this.next=next; - } - } - - - //以下不用实现 - /** - * 把该链表逆置 - * 例如链表为 3->7->10 , 逆置后变为 10->7->3 - */ - public void reverse(){ - - } - - /** - * 删除一个单链表的前半部分 - * 例如:list = 2->5->7->8 , 删除以后的值为 7->8 - * 如果list = 2->5->7->8->10 ,删除以后的值为7,8,10 - - */ - public void removeFirstHalf(){ - - } - - /** - * 从第i个元素开始, 删除length 个元素 , 注意i从0开始 - * @param i - * @param length - */ - public void remove(int i, int length){ - - } - /** - * 假定当前链表和listB均包含已升序排列的整数 - * 从当前链表中取出那些listB所指定的元素 - * 例如当前链表 = 11->101->201->301->401->501->601->701 - * listB = 1->3->4->6 - * 返回的结果应该是[101,301,401,601] - * @param list - */ - public int[] getElements(LinkedList list){ - return null; - } - - /** - * 已知链表中的元素以值递增有序排列,并以单链表作存储结构。 - * 从当前链表中中删除在listB中出现的元素 - - * @param list - */ - - public void subtract(LinkedList list){ - - } - - /** - * 已知当前链表中的元素以值递增有序排列,并以单链表作存储结构。 - * 删除表中所有值相同的多余元素(使得操作后的线性表中所有元素的值均不相同) - */ - public void removeDuplicateValues(){ - - } - - /** - * 已知链表中的元素以值递增有序排列,并以单链表作存储结构。 - * 试写一高效的算法,删除表中所有值大于min且小于max的元素(若表中存在这样的元素) - * @param min - * @param max - */ - public void removeRange(int min, int max){ - - } - - /** - * 假设当前链表和参数list指定的链表均以元素依值递增有序排列(同一表中的元素值各不相同) - * 现要求生成新链表C,其元素为当前链表和list中元素的交集,且表C中的元素有依值递增有序排列 - * @param list - */ - public LinkedList intersection( LinkedList list){ - return null; - } + + private int theSize = 0;//表示该链表的长度 + private Node beginMarker;//链表的头元素 + private Node endMarker;//链表的尾元素 + + //链表的构造方法 + public LinkedList() { + beginMarker = new Node(null, null, null); + endMarker = new Node(null, beginMarker, null); + beginMarker.next = endMarker; + } + + public void add(Object o) { + add(size(), o); + } + + public void add(int index, Object o) { + addBefore(getNode(index), o); + } + + public Object get(int index) { + return getNode(index).data; + } + + public Object remove(int index) { + return remove(getNode(index)); + } + + public int size() { + return theSize; + } + + public void addFirst(Object o) { + addBefore(getNode(0), o); + } + + public void addLast(Object o) { + addBefore(getNode(theSize), o); + } + + public Object removeFirst() { + return remove(getNode(0)); + } + + public Object removeLast() { + return remove(getNode(theSize - 1)); + } + + public Iterator iterator() { + return new Itr(); + } + + private class Itr implements Iterator { + + private Node cursor = beginMarker.next; + + @Override + public boolean hasNext() { + + return cursor != endMarker; + } + + @Override + public Object next() { + + Object o = cursor.data; + cursor = cursor.next; + + return o; + } + + } + + private Object remove(Node node) { + node.prev.next = node.next; + node.next.prev = node.prev; + theSize--; + return node.data; + } + + private Node getNode(int index) { + Node p; + if (index < 0 || index > size()) { + throw new IndexOutOfBoundsException(); + } + if (index == -1) { + return beginMarker; + } else if (index == theSize) { + return endMarker; + } + if (index < size() / 2) { + p = beginMarker.next; + for (int i = 0; i < index; i++) { + p = p.next; + } + } else { + p = endMarker.prev; + for (int i = size() - 1; i > index; i--) { + p = p.prev; + } + } + return p; + } + + private void addBefore(Node node, Object o) { + Node newNode = new Node(o, node.prev, node); + newNode.prev.next = newNode; + node.prev = newNode; + theSize++; + //nodeCount++; + } + + private static class Node { + public Object data; + public Node next; + public Node prev; + + public Node(Object data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + } + + + //以下不用实现 + + /** + * 把该链表逆置 + * 例如链表为 3->7->10 , 逆置后变为 10->7->3 + */ + public void reverse() { + + } + + /** + * 删除一个单链表的前半部分 + * 例如:list = 2->5->7->8 , 删除以后的值为 7->8 + * 如果list = 2->5->7->8->10 ,删除以后的值为7,8,10 + */ + public void removeFirstHalf() { + + } + + /** + * 从第i个元素开始, 删除length 个元素 , 注意i从0开始 + * + * @param i + * @param length + */ + public void remove(int i, int length) { + + } + + /** + * 假定当前链表和listB均包含已升序排列的整数 + * 从当前链表中取出那些listB所指定的元素 + * 例如当前链表 = 11->101->201->301->401->501->601->701 + * listB = 1->3->4->6 + * 返回的结果应该是[101,301,401,601] + * + * @param list + */ + public int[] getElements(LinkedList list) { + return null; + } + + /** + * 已知链表中的元素以值递增有序排列,并以单链表作存储结构。 + * 从当前链表中中删除在listB中出现的元素 + * + * @param list + */ + + public void subtract(LinkedList list) { + + } + + /** + * 已知当前链表中的元素以值递增有序排列,并以单链表作存储结构。 + * 删除表中所有值相同的多余元素(使得操作后的线性表中所有元素的值均不相同) + */ + public void removeDuplicateValues() { + + } + + /** + * 已知链表中的元素以值递增有序排列,并以单链表作存储结构。 + * 试写一高效的算法,删除表中所有值大于min且小于max的元素(若表中存在这样的元素) + * + * @param min + * @param max + */ + public void removeRange(int min, int max) { + + } + + /** + * 假设当前链表和参数list指定的链表均以元素依值递增有序排列(同一表中的元素值各不相同) + * 现要求生成新链表C,其元素为当前链表和list中元素的交集,且表C中的元素有依值递增有序排列 + * + * @param list + */ + public LinkedList intersection(LinkedList list) { + return null; + } } diff --git a/group26/1515345281/src/Collection/TestCollection.java b/group26/1515345281/src/Collection/TestCollection.java index 797ce419b5..9105cbe23b 100644 --- a/group26/1515345281/src/Collection/TestCollection.java +++ b/group26/1515345281/src/Collection/TestCollection.java @@ -2,6 +2,7 @@ import org.junit.Test; + public class TestCollection { @Test diff --git a/group26/zhuakuang2017/src/zhuakuang/homework/first/Collection/ArrayList.java b/group26/zhuakuang2017/src/zhuakuang/homework/first/Collection/ArrayList.java new file mode 100644 index 0000000000..13c251ffe9 --- /dev/null +++ b/group26/zhuakuang2017/src/zhuakuang/homework/first/Collection/ArrayList.java @@ -0,0 +1,102 @@ +package zhuakuang.homework.first.Collection; + +import java.util.Arrays; + +public class ArrayList implements List, Iterable { + + private int size = 0; + + private Object[] elementData = new Object[10]; + + public void add(Object o) { + ensureCapacity(size + 1); + elementData[size] = o; + size++; + } + + /** + * 插入 + * + * @param index + * @param o + */ + public void add(int index, Object o) { + if (index > size || index < 0) { + throw new IndexOutOfBoundsException("index" + index + "越界"); + } + ensureCapacity(size + 1); + System.arraycopy(elementData, index, elementData, index + 1, + size - index); + elementData[index] = o; + size++; + } + + public Object get(int index) { + checkIndex(index); + return elementData[index]; + } + + public Object remove(int index) { + checkIndex(index); + Object oldValue = elementData[index]; + + int numMoved = size - index - 1; + if (numMoved > 0) { + System.arraycopy(elementData, index + 1, elementData, index, + numMoved); + } + elementData[--size] = null;// GC + return oldValue; + } + + private void checkIndex(int index) { + if (index >= size || index < 0) { + throw new IndexOutOfBoundsException("index" + index + "越界"); + } + } + + public int size() { + return size; + } + + public Iterator iterator() { + return new Itr(); + } + + private class Itr implements Iterator { + int cursor = 0; + + @Override + public boolean hasNext() { + if (cursor < size) { + return true; + }// + return false; + } + + @Override + public Object next() { + int nowCursor = cursor; + cursor++; + return elementData[nowCursor]; + } + } + + + public void ensureCapacity(int minCapacity) { + int oldCapacity = elementData.length; + if (minCapacity > oldCapacity) { + int newCapacity = (oldCapacity * 3) / 2 + 1; // oldCapacity 的 1.5 倍(取整)+ 1 + if (newCapacity < minCapacity) { + newCapacity = minCapacity; + } + // Arrays.copyOf 功能:把一个数组复制到另一个数组,返回值就是另一个数组。 + // 第一参数是被拷贝参数,第二个参数是返回的新数组的长度。 + // 如果新数组的长度超过原数组的长度,则保留数组默认值。 + // 如果新数组的长度小于原数组的长度,则多出的部分不保留。 + elementData = Arrays.copyOf(elementData, newCapacity); + } + } + + +} diff --git a/group26/zhuakuang2017/src/zhuakuang/homework/first/Collection/BinaryTreeNode.java b/group26/zhuakuang2017/src/zhuakuang/homework/first/Collection/BinaryTreeNode.java new file mode 100644 index 0000000000..974f6418fb --- /dev/null +++ b/group26/zhuakuang2017/src/zhuakuang/homework/first/Collection/BinaryTreeNode.java @@ -0,0 +1,35 @@ +package zhuakuang.homework.first.Collection; + +/** + * 二叉树 + */ +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/group26/zhuakuang2017/src/zhuakuang/homework/first/Collection/Iterator.java b/group26/zhuakuang2017/src/zhuakuang/homework/first/Collection/Iterator.java new file mode 100644 index 0000000000..0f806b8788 --- /dev/null +++ b/group26/zhuakuang2017/src/zhuakuang/homework/first/Collection/Iterator.java @@ -0,0 +1,10 @@ +package zhuakuang.homework.first.Collection; + +public interface Iterator extends java.util.Iterator { + public boolean hasNext(); + public Object next(); + + + //void remove(); + +} diff --git a/group26/zhuakuang2017/src/zhuakuang/homework/first/Collection/LinkedList.java b/group26/zhuakuang2017/src/zhuakuang/homework/first/Collection/LinkedList.java new file mode 100644 index 0000000000..692951f698 --- /dev/null +++ b/group26/zhuakuang2017/src/zhuakuang/homework/first/Collection/LinkedList.java @@ -0,0 +1,134 @@ +package zhuakuang.homework.first.Collection; + +public class LinkedList implements List { + + private Node head; + private Node tail; + + public void add(Object o) { + + } + + public void add(int index, Object o) { + + } + + public Object get(int index) { + return null; + } + + public Object remove(int index) { + return null; + } + + public int size() { + return -1; + } + + public void addFirst(Object o) { + + } + + public void addLast(Object o) { + + } + + public Object removeFirst() { + return null; + } + + public Object removeLast() { + return null; + } + + public Iterator iterator() { + return null; + } + + + private static class Node { + Object data; + Node next; + + } + + /** + * 把该链表逆置 + * 例如链表为 3->7->10 , 逆置后变为 10->7->3 + */ + public void reverse() { + + } + + /** + * 删除一个单链表的前半部分 + * 例如:list = 2->5->7->8 , 删除以后的值为 7->8 + * 如果list = 2->5->7->8->10 ,删除以后的值为7,8,10 + */ + public void removeFirstHalf() { + + } + + /** + * 从第i个元素开始, 删除length 个元素 , 注意i从0开始 + * + * @param i + * @param length + */ + public void remove(int i, int length) { + + } + + /** + * 假定当前链表和listB均包含已升序排列的整数 + * 从当前链表中取出那些listB所指定的元素 + * 例如当前链表 = 11->101->201->301->401->501->601->701 + * listB = 1->3->4->6 + * 返回的结果应该是[101,301,401,601] + * + * @param list + */ + public int[] getElements(LinkedList list) { + return null; + } + + /** + * 已知链表中的元素以值递增有序排列,并以单链表作存储结构。 + * 从当前链表中中删除在listB中出现的元素 + * + * @param list + */ + + public void subtract(LinkedList list) { + + } + + /** + * 已知当前链表中的元素以值递增有序排列,并以单链表作存储结构。 + * 删除表中所有值相同的多余元素(使得操作后的线性表中所有元素的值均不相同) + */ + public void removeDuplicateValues() { + + } + + /** + * 已知链表中的元素以值递增有序排列,并以单链表作存储结构。 + * 试写一高效的算法,删除表中所有值大于min且小于max的元素(若表中存在这样的元素) + * + * @param min + * @param max + */ + public void removeRange(int min, int max) { + + } + + /** + * 假设当前链表和参数list指定的链表均以元素依值递增有序排列(同一表中的元素值各不相同) + * 现要求生成新链表C,其元素为当前链表和list中元素的交集,且表C中的元素有依值递增有序排列 + * + * @param list + */ + public LinkedList intersection(LinkedList list) { + return null; + } +} diff --git a/group26/zhuakuang2017/src/zhuakuang/homework/first/Collection/List.java b/group26/zhuakuang2017/src/zhuakuang/homework/first/Collection/List.java new file mode 100644 index 0000000000..26b05377a6 --- /dev/null +++ b/group26/zhuakuang2017/src/zhuakuang/homework/first/Collection/List.java @@ -0,0 +1,10 @@ +package zhuakuang.homework.first.Collection; + +public interface List extends Iterable { + 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(); + Iterator iterator(); +} diff --git a/group26/zhuakuang2017/src/zhuakuang/homework/first/Collection/Queue.java b/group26/zhuakuang2017/src/zhuakuang/homework/first/Collection/Queue.java new file mode 100644 index 0000000000..7a1c8681a5 --- /dev/null +++ b/group26/zhuakuang2017/src/zhuakuang/homework/first/Collection/Queue.java @@ -0,0 +1,19 @@ +package zhuakuang.homework.first.Collection; + +public class Queue { + + public void enQueue(Object o) { + } + + public Object deQueue() { + return null; + } + + public boolean isEmpty() { + return false; + } + + public int size() { + return -1; + } +} diff --git a/group26/zhuakuang2017/src/zhuakuang/homework/first/Collection/Stack.java b/group26/zhuakuang2017/src/zhuakuang/homework/first/Collection/Stack.java new file mode 100644 index 0000000000..ed39665be1 --- /dev/null +++ b/group26/zhuakuang2017/src/zhuakuang/homework/first/Collection/Stack.java @@ -0,0 +1,22 @@ +package zhuakuang.homework.first.Collection; +import java.util.ArrayList; +public class Stack { + private ArrayList elementData = new ArrayList(); + + public void push(Object o){ + } + + public Object pop(){ + return null; + } + + public Object peek(){ + return null; + } + public boolean isEmpty(){ + return false; + } + public int size(){ + return -1; + } +} diff --git a/group26/zhuakuang2017/src/zhuakuang/homework/first/Collection/TestCollection.java b/group26/zhuakuang2017/src/zhuakuang/homework/first/Collection/TestCollection.java new file mode 100644 index 0000000000..9e953df486 --- /dev/null +++ b/group26/zhuakuang2017/src/zhuakuang/homework/first/Collection/TestCollection.java @@ -0,0 +1,41 @@ +package zhuakuang.homework.first.Collection; + +import org.junit.Test; + +import static org.junit.Assert.assertEquals; + +/** + * Created by BlindingDark on 2017/3/11 0011. + */ +public class TestCollection { + @Test + public void arrayListTest() {//分开测试每一个方法 List test + ArrayList myArrayList = new ArrayList(); + + myArrayList.add("1"); + myArrayList.add("2"); + myArrayList.add("3"); + myArrayList.add("4"); + myArrayList.add("5"); + myArrayList.add("6"); + myArrayList.add("7"); + myArrayList.add("8"); + myArrayList.add("9"); + myArrayList.add("10"); + myArrayList.add("11"); + myArrayList.add("12"); + + myArrayList.add(2, "2.5"); + myArrayList.remove(1); + + String first = String.valueOf(Integer.valueOf((String) myArrayList.get(2)) - 2); + String[] strs = {first, "2.5", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12"}; + + Iterator itr = myArrayList.iterator(); + while (itr.hasNext()) { + for (int i = 0; i < myArrayList.size(); i++) { + assertEquals(strs[i], itr.next()); + } + } + } +} diff --git a/group26/zhuakuang2017/src/zhuakuang/homework/first/Main.java b/group26/zhuakuang2017/src/zhuakuang/homework/first/Main.java deleted file mode 100644 index 9f3d7e846c..0000000000 --- a/group26/zhuakuang2017/src/zhuakuang/homework/first/Main.java +++ /dev/null @@ -1,7 +0,0 @@ -package zhuakuang.homework.first; - -public class Main { - public static void main(String[] args) { - System.out.println(1); - } -} From 087b58bdd364aa0d2cb9fc2afd1412688deb92fe Mon Sep 17 00:00:00 2001 From: "mwu@xtremeprog.com" Date: Sun, 12 Mar 2017 19:48:46 +0800 Subject: [PATCH 17/28] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E4=BD=9C=E4=B8=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/basic/collections/ArrayList.java | 3 +- .../src/basic/collections/LinkedList.java | 77 +++++++++++++++++-- 2 files changed, 71 insertions(+), 9 deletions(-) diff --git a/group26/2070509107/src/basic/collections/ArrayList.java b/group26/2070509107/src/basic/collections/ArrayList.java index 233b8f1795..8ba213409e 100644 --- a/group26/2070509107/src/basic/collections/ArrayList.java +++ b/group26/2070509107/src/basic/collections/ArrayList.java @@ -4,7 +4,8 @@ * * @author Mahone Wu * @data:2017-03-10 - * @description:ArrayList的自我实现 @version:1.0.0 + * @description:ArrayList的自我实现,暂时没有自动扩展 + * @version:1.0.0 */ public class ArrayList implements List { diff --git a/group26/2070509107/src/basic/collections/LinkedList.java b/group26/2070509107/src/basic/collections/LinkedList.java index 248617d05a..e9eb46d34f 100644 --- a/group26/2070509107/src/basic/collections/LinkedList.java +++ b/group26/2070509107/src/basic/collections/LinkedList.java @@ -1,5 +1,6 @@ package collections; + /** * * @author Mahone Wu @@ -9,18 +10,40 @@ */ public class LinkedList implements List { + //定义头节点 private Node head; + + //最后一个节点 + private Node last; + + //链表大小 + private int size; + /** + * 添加元素 + */ public void add(Object o) { - while (head.next == null) { - - } + addLast(o); } + /** + * 指定位置添加元素 + */ public void add(int index, Object o) { - + if(!(index >= 0 && index <= size)){ + //超出索引范围 + } + Node currentNode =null; + + } + + + + /** + * 获取指定元素 + */ public Object get(int index) { return null; } @@ -30,15 +53,35 @@ public Object remove(int index) { } public int size() { - return -1; + return size; } public void addFirst(Object o) { - + Node fistNode = head; + Node newNode = new Node(null, o, head); + head = newNode; + if(null == fistNode){ + last = newNode; + }else{//将之前的头节点的前一个指向现在的头节点 + fistNode.prev = newNode; + } + size++; } + /** + * 向尾添加元素 + * @param o + */ public void addLast(Object o) { - + Node lastNode = last; + Node newNode = new Node(lastNode, o, null); + last = newNode;//将新增的节点设置为最后一个节点 + if(null == lastNode){//如果之前最后一个节点为空,则代表这是第一次增加节点,进行头节点设置 + head = newNode; + }else{ + lastNode.next = newNode; + } + size++; } public Object removeFirst() { @@ -53,12 +96,30 @@ public Iterator iterator() { return null; } + //参照LinkedList源码实现 private static class Node { Object data; + Node prev; Node next; - + + Node(Node prev,Object object,Node next){ + this.prev = prev; + this.data = object; + this.next = next; + } } + /** + * 查找指定位置的Node节点 + * @param index + * @return + */ + Node findNode(int index){ + Node currentNode = head; + + + } + /** * 把该链表逆置 例如链表为 3->7->10 , 逆置后变为 10->7->3 */ From 07f53625983861140af787dca93c2d6c3e0cf71e Mon Sep 17 00:00:00 2001 From: BlindingDark <844620174@qq.com> Date: Mon, 13 Mar 2017 00:54:51 +0800 Subject: [PATCH 18/28] =?UTF-8?q?26=E7=BB=84=E6=8F=90=E4=BA=A4=E7=AC=AC?= =?UTF-8?q?=E4=B8=80=E6=AC=A1=E4=BD=9C=E4=B8=9A=20=E7=BB=9F=E8=AE=A1?= =?UTF-8?q?=E6=83=85=E5=86=B5=E9=99=84=E5=9C=A826=E7=BB=84=E7=9B=AE?= =?UTF-8?q?=E5=BD=95=E4=B8=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...05\345\206\265\347\273\237\350\256\241.md" | 28 ++++++++++++------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git "a/group26/26\347\273\204\346\203\205\345\206\265\347\273\237\350\256\241.md" "b/group26/26\347\273\204\346\203\205\345\206\265\347\273\237\350\256\241.md" index b56980dad6..a1f2d56510 100644 --- "a/group26/26\347\273\204\346\203\205\345\206\265\347\273\237\350\256\241.md" +++ "b/group26/26\347\273\204\346\203\205\345\206\265\347\273\237\350\256\241.md" @@ -1,10 +1,18 @@ -| | | | | | | | | | | | -| -------- | ---------------- | ----- | --------- | ---- | ---- | ---- | ---- | ---- | ---- | ---- | -| 抓狂 | 作业1 | 作业2 | 作业3完成100% | | | | | | | | -| | 文章1 | | | | | | | | | | -| JEE-逆水百川 | 已完成 | 完成90% | | | | | | | | | -| | 百度 www.baidu.com | | | | | | | | | | -| jiaxun1990 | 已完成 | | | | | | | | | | -| | https://goo.gl/Wvz3Od | | | | | | | | | | -| | | | | | | | | | | | -| | | | | | | | | | | | \ No newline at end of file +| | | | | | | +| -------------------- | :-------------------: | ---- | ---- | ---- | ---- | +| 抓狂 | 作业1 | | | | | +| | 文章1 | | | | | +| 723161901 | 已完成 | | | | | +| | | | | | | +| jiaxun1990(89460886) | 已完成 | | | | | +| | https://goo.gl/Wvz3Od | | | | | +| 1515345281 | 已完成 | | | | | +| | | | | | | +| 2070509107 | 已完成 | | | | | +| | | | | | | +| lizhy2017 | 部分完成 | | | | | +| | | | | | | +| | | | | | | +| | | | | | | +| | | | | | | +| | | | | | | \ No newline at end of file From b95cb325808d8ce6cf735e177e39cffd05517ae6 Mon Sep 17 00:00:00 2001 From: zhangrui <2411685663@qq.com> Date: Mon, 13 Mar 2017 10:46:46 +0800 Subject: [PATCH 19/28] =?UTF-8?q?=E6=B5=8B=E8=AF=95=E7=9B=AE=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/nishuibaichuan/homework/first/List.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 group26/2411685663/src/nishuibaichuan/homework/first/List.java diff --git a/group26/2411685663/src/nishuibaichuan/homework/first/List.java b/group26/2411685663/src/nishuibaichuan/homework/first/List.java new file mode 100644 index 0000000000..cfab8e3522 --- /dev/null +++ b/group26/2411685663/src/nishuibaichuan/homework/first/List.java @@ -0,0 +1,13 @@ +package JEE_2411685663; + +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(); +} From fdb9d8948576a6bb13b6640b7f3fc7e7ce78857b Mon Sep 17 00:00:00 2001 From: zhangrui <2411685663@qq.com> Date: Mon, 13 Mar 2017 10:52:57 +0800 Subject: [PATCH 20/28] ArrayList --- .../homework/first/ArrayList.java | 123 +++++++++++++++++ .../homework/first/BinaryTreeNode.java | 37 ++++++ .../homework/first/Iterator.java | 9 ++ .../homework/first/LinkedList.java | 125 ++++++++++++++++++ .../nishuibaichuan/homework/first/List.java | 2 +- .../nishuibaichuan/homework/first/Queue.java | 19 +++ .../nishuibaichuan/homework/first/Stack.java | 24 ++++ .../homework/first/TestArrayList.java | 48 +++++++ ...05\345\206\265\347\273\237\350\256\241.md" | 4 +- 9 files changed, 388 insertions(+), 3 deletions(-) create mode 100644 group26/2411685663/src/nishuibaichuan/homework/first/ArrayList.java create mode 100644 group26/2411685663/src/nishuibaichuan/homework/first/BinaryTreeNode.java create mode 100644 group26/2411685663/src/nishuibaichuan/homework/first/Iterator.java create mode 100644 group26/2411685663/src/nishuibaichuan/homework/first/LinkedList.java create mode 100644 group26/2411685663/src/nishuibaichuan/homework/first/Queue.java create mode 100644 group26/2411685663/src/nishuibaichuan/homework/first/Stack.java create mode 100644 group26/2411685663/src/nishuibaichuan/homework/first/TestArrayList.java diff --git a/group26/2411685663/src/nishuibaichuan/homework/first/ArrayList.java b/group26/2411685663/src/nishuibaichuan/homework/first/ArrayList.java new file mode 100644 index 0000000000..efa9ee9bd1 --- /dev/null +++ b/group26/2411685663/src/nishuibaichuan/homework/first/ArrayList.java @@ -0,0 +1,123 @@ +package JEE_2411685663; + +import java.util.Arrays; +import java.util.NoSuchElementException; + +public class ArrayList implements List { + + private static int size = 0; //全局静态变量 + + private Object[] elementData = new Object[100]; + + public void add(Object o) { + isCapacity(size + 1);//判断是否扩容 + elementData[size++] = o; + } + + public void add(int index, Object o) { + checkRangeForAdd(index);//判断下标是否越界 + isCapacity(size + 1); + //使用arraycopy将index下标以后元素后移动 (size - index)长度 + System.arraycopy(elementData, index, elementData, index + 1, size - index); + elementData[index] = o; + size++; + } + + public Object get(int index) { + checkRangeForAdd(index); + return (Object)elementData[index]; + } + + public Object remove(int index) { + checkRangeForAdd(index); + Object oldValue = get(index); + int numMoved = size - index - 1; + if (numMoved > 0) + System.arraycopy(elementData, index+1, elementData, index, + numMoved); + elementData[--size] = null; // index后面数据依次往前移动,将最后一个位置赋值为0,让gc来回收空间。 + return oldValue; + } + + public int size() { + return size; + } + + /** + * 迭代器 + * @return + */ + public Iterator iterator() { + return new SubIterator(this); + } + + private static class SubIterator implements Iterator{ + + private ArrayList arrayList; + private static int ret = 0; + + private SubIterator(){} + + private SubIterator(ArrayList arrayList){ + this.arrayList = arrayList ; + } + + public boolean hasNext() { + return ret != size; + } + + public Object next() { + if (ret > size) { + throw new NoSuchElementException();//没有这样的元素异常 + } + return arrayList.elementData[ret++]; + } + + public void remove() { + arrayList.remove(ret--); + } + + } + + /** + * 下标是否越界 + * @param index + */ + public void checkRangeForAdd(int index){ + if (index < 0 || index > size) { + throw new ArrayIndexOutOfBoundsException("index下标越界" + ", Size: " + size + + ",Index: " + index); + } + } + + /** + * 是否扩容 + */ + public void isCapacity(int size){ + if (size > 100) { + Capacity(size); + } + /** + * size小于0主要是因为当size超过Integer.MAX_VALUE就会变成负数。 + */ + if (size < 0) { + throw new ArrayIndexOutOfBoundsException("数组长度溢出"); + } + } + + public void Capacity(int capacity){ + int newLength = elementData.length + 1000;//再原来基础上扩容1000 + if (newLength - capacity < 0) { + newLength = capacity; //得到最大长度 + } + /** + * 保留了数组的头部信息在数组中,因此实际存放数据的大小就是整数的最大值 - 8 + * 很难执行下面的判断 + */ + if (newLength > Integer.MAX_VALUE - 8) { + newLength = capacity > Integer.MAX_VALUE - 8 ? Integer.MAX_VALUE : Integer.MAX_VALUE - 8; + } + elementData = Arrays.copyOf(elementData, newLength);//获取扩容后的数组 + } + +} diff --git a/group26/2411685663/src/nishuibaichuan/homework/first/BinaryTreeNode.java b/group26/2411685663/src/nishuibaichuan/homework/first/BinaryTreeNode.java new file mode 100644 index 0000000000..17984ab8d1 --- /dev/null +++ b/group26/2411685663/src/nishuibaichuan/homework/first/BinaryTreeNode.java @@ -0,0 +1,37 @@ +package nishuibaichuan.homework.first; + +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/group26/2411685663/src/nishuibaichuan/homework/first/Iterator.java b/group26/2411685663/src/nishuibaichuan/homework/first/Iterator.java new file mode 100644 index 0000000000..a0d81a47ba --- /dev/null +++ b/group26/2411685663/src/nishuibaichuan/homework/first/Iterator.java @@ -0,0 +1,9 @@ +package nishuibaichuan.homework.first; + +public interface Iterator { + public boolean hasNext(); + + public Object next(); + + public void remove(); +} diff --git a/group26/2411685663/src/nishuibaichuan/homework/first/LinkedList.java b/group26/2411685663/src/nishuibaichuan/homework/first/LinkedList.java new file mode 100644 index 0000000000..bf38c91470 --- /dev/null +++ b/group26/2411685663/src/nishuibaichuan/homework/first/LinkedList.java @@ -0,0 +1,125 @@ +package nishuibaichuan.homework.first; + +public class LinkedList implements List { + + private Node head; + + public void add(Object o) { + + } + + public void add(int index, Object o) { + + } + + public Object get(int index) { + return null; + } + + public Object remove(int index) { + return null; + } + + public int size() { + return -1; + } + + public void addFirst(Object o) { + + } + + public void addLast(Object o) { + + } + + public Object removeFirst() { + return null; + } + + public Object removeLast() { + return null; + } + + public Iterator iterator() { + return null; + } + + private static class Node { + Object data; + Node next; + + } + + /** + * 把该链表逆置 例如链表为 3->7->10 , 逆置后变为 10->7->3 + */ + public void reverse() { + + } + + /** + * 删除一个单链表的前半部分 例如:list = 2->5->7->8 , 删除以后的值为 7->8 如果list = 2->5->7->8->10 + * ,删除以后的值为7,8,10 + */ + public void removeFirstHalf() { + + } + + /** + * 从第i个元素开始, 删除length 个元素 , 注意i从0开始 + * + * @param i + * @param length + */ + public void remove(int i, int length) { + + } + + /** + * 假定当前链表和list均包含已升序排列的整数 从当前链表中取出那些list所指定的元素 例如当前链表 = + * 11->101->201->301->401->501->601->701 listB = 1->3->4->6 + * 返回的结果应该是[101,301,401,601] + * + * @param list + */ + public static int[] getElements(LinkedList list) { + return null; + } + + /** + * 已知链表中的元素以值递增有序排列,并以单链表作存储结构。 从当前链表中中删除在list中出现的元素 + * + * @param list + */ + + public void subtract(LinkedList list) { + + } + + /** + * 已知当前链表中的元素以值递增有序排列,并以单链表作存储结构。 删除表中所有值相同的多余元素(使得操作后的线性表中所有元素的值均不相同) + */ + public void removeDuplicateValues() { + + } + + /** + * 已知链表中的元素以值递增有序排列,并以单链表作存储结构。 试写一高效的算法,删除表中所有值大于min且小于max的元素(若表中存在这样的元素) + * + * @param min + * @param max + */ + public void removeRange(int min, int max) { + + } + + /** + * 假设当前链表和参数list指定的链表均以元素依值递增有序排列(同一表中的元素值各不相同) + * 现要求生成新链表C,其元素为当前链表和list中元素的交集,且表C中的元素有依值递增有序排列 + * + * @param list + */ + public LinkedList intersection(LinkedList list) { + return null; + } +} diff --git a/group26/2411685663/src/nishuibaichuan/homework/first/List.java b/group26/2411685663/src/nishuibaichuan/homework/first/List.java index cfab8e3522..ca9279d5fc 100644 --- a/group26/2411685663/src/nishuibaichuan/homework/first/List.java +++ b/group26/2411685663/src/nishuibaichuan/homework/first/List.java @@ -1,4 +1,4 @@ -package JEE_2411685663; +package nishuibaichuan.homework.first; public interface List { public void add(Object o); diff --git a/group26/2411685663/src/nishuibaichuan/homework/first/Queue.java b/group26/2411685663/src/nishuibaichuan/homework/first/Queue.java new file mode 100644 index 0000000000..cf7798678d --- /dev/null +++ b/group26/2411685663/src/nishuibaichuan/homework/first/Queue.java @@ -0,0 +1,19 @@ +package nishuibaichuan.homework.first; + +public class Queue { + + public void enQueue(Object o) { + } + + public Object deQueue() { + return null; + } + + public boolean isEmpty() { + return false; + } + + public int size() { + return -1; + } +} diff --git a/group26/2411685663/src/nishuibaichuan/homework/first/Stack.java b/group26/2411685663/src/nishuibaichuan/homework/first/Stack.java new file mode 100644 index 0000000000..8d9a2f8a0a --- /dev/null +++ b/group26/2411685663/src/nishuibaichuan/homework/first/Stack.java @@ -0,0 +1,24 @@ +package nishuibaichuan.homework.first; + +public class Stack { + private ArrayList elementData = new ArrayList(); + + public void push(Object o) { + } + + public Object pop() { + return null; + } + + public Object peek() { + return null; + } + + public boolean isEmpty() { + return false; + } + + public int size() { + return -1; + } +} diff --git a/group26/2411685663/src/nishuibaichuan/homework/first/TestArrayList.java b/group26/2411685663/src/nishuibaichuan/homework/first/TestArrayList.java new file mode 100644 index 0000000000..b992de37ee --- /dev/null +++ b/group26/2411685663/src/nishuibaichuan/homework/first/TestArrayList.java @@ -0,0 +1,48 @@ +package nishuibaichuan.homework.first; + +import static org.junit.Assert.*; + +import org.junit.Assert; +import org.junit.Test; + +/** + * @Desc: () + * @date: 2017年3月12日 下午7:00:22 + * @email:2411685663@qq.com + */ +@SuppressWarnings("unused") +public class TestArrayList { + + private ArrayList arrayList = new ArrayList(); + + @Test + public void testAll() { + arrayList.add(0); + arrayList.add(1); + arrayList.add(2); + arrayList.add(3); + arrayList.add(4); + arrayList.add(5); + arrayList.add(6); + + Assert.assertEquals(arrayList.size(), 7); + Assert.assertEquals(arrayList.get(1), 1); + System.out.println(arrayList.get(3)); + + arrayList.add(0, 100); + Assert.assertEquals(arrayList.size(), 8); + Assert.assertEquals(arrayList.get(0), 100); + + arrayList.remove(0); + Assert.assertEquals(arrayList.size(), 7); + Assert.assertEquals(arrayList.get(0), 0); + + Iterator iterator = arrayList.iterator(); + while(iterator.hasNext()){ + iterator.next(); + iterator.remove(); + } + Assert.assertEquals(arrayList.size(), 0); + } + +} diff --git "a/group26/26\347\273\204\346\203\205\345\206\265\347\273\237\350\256\241.md" "b/group26/26\347\273\204\346\203\205\345\206\265\347\273\237\350\256\241.md" index 8700b37aaf..d88dfe6cb5 100644 --- "a/group26/26\347\273\204\346\203\205\345\206\265\347\273\237\350\256\241.md" +++ "b/group26/26\347\273\204\346\203\205\345\206\265\347\273\237\350\256\241.md" @@ -2,8 +2,8 @@ | -------- | ---------------- | ----- | --------- | ---- | ---- | ---- | ---- | ---- | ---- | ---- | | 抓狂 | 作业1 | 作业2 | 作业3完成100% | | | | | | | | | | 文章1 | | | | | | | | | | -| JEE-逆水百川 | 已完成 | 完成90% | | | | | | | | | -| | 百度 www.baidu.com | | | | | | | | | | +| JEE-逆水百川 | 完成65% | 完成90% | | | | | | | | | +| | http://blog.csdn.net/u012759397/article/details/61618612 | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | From c574fdb81dc51260f86cb82677b885e41b72cc8d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?JEE-=E9=80=86=E6=B0=B4=E7=99=BE=E5=B7=9D?= <2411685663@qq.com> Date: Mon, 13 Mar 2017 11:34:37 +0800 Subject: [PATCH 21/28] =?UTF-8?q?Update=2026=E7=BB=84=E6=83=85=E5=86=B5?= =?UTF-8?q?=E7=BB=9F=E8=AE=A1.md?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...05\345\206\265\347\273\237\350\256\241.md" | 28 ++++++++++++------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git "a/group26/26\347\273\204\346\203\205\345\206\265\347\273\237\350\256\241.md" "b/group26/26\347\273\204\346\203\205\345\206\265\347\273\237\350\256\241.md" index d88dfe6cb5..fd3298e6ca 100644 --- "a/group26/26\347\273\204\346\203\205\345\206\265\347\273\237\350\256\241.md" +++ "b/group26/26\347\273\204\346\203\205\345\206\265\347\273\237\350\256\241.md" @@ -1,10 +1,18 @@ -| | | | | | | | | | | | -| -------- | ---------------- | ----- | --------- | ---- | ---- | ---- | ---- | ---- | ---- | ---- | -| 抓狂 | 作业1 | 作业2 | 作业3完成100% | | | | | | | | -| | 文章1 | | | | | | | | | | -| JEE-逆水百川 | 完成65% | 完成90% | | | | | | | | | -| | http://blog.csdn.net/u012759397/article/details/61618612 | | | | | | | | | | -| | | | | | | | | | | | -| | | | | | | | | | | | -| | | | | | | | | | | | -| | | | | | | | | | | | \ No newline at end of file +| | | | | | | +| -------------------- | :-------------------: | ---- | ---- | ---- | ---- | +| 抓狂 | 作业1 | | | | | +| | 文章1 | | | | | +| 723161901 | 已完成 | | | | | +| | | | | | | +| jiaxun1990(89460886) | 已完成 | | | | | +| | https://goo.gl/Wvz3Od | | | | | +| 1515345281 | 已完成 | | | | | +| | | | | | | +| 2070509107 | 已完成 | | | | | +| | | | | | | +| lizhy2017 | 部分完成 | | | | | +| | | | | | | +| | | | | | | +| | | | | | | +| | | | | | | +| | | | | | | From b50c6404def0fd74b1cd3875e53ec164ead5c8f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?JEE-=E9=80=86=E6=B0=B4=E7=99=BE=E5=B7=9D?= <2411685663@qq.com> Date: Mon, 13 Mar 2017 11:36:09 +0800 Subject: [PATCH 22/28] Update .gitignore --- .gitignore | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.gitignore b/.gitignore index 6945ca9d30..77cdfba900 100644 --- a/.gitignore +++ b/.gitignore @@ -23,4 +23,7 @@ rebel.* .rebel.* target +*.DS_Store +liuxin/.DS_Store +liuxin/src/.DS_Store From 3448ce80d88fb88f7e34cfc3fd71ef1ddaca7cd3 Mon Sep 17 00:00:00 2001 From: zhangrui <2411685663@qq.com> Date: Mon, 13 Mar 2017 11:42:34 +0800 Subject: [PATCH 23/28] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E4=BD=9C=E4=B8=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...73\204\346\203\205\345\206\265\347\273\237\350\256\241.md" | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git "a/group26/26\347\273\204\346\203\205\345\206\265\347\273\237\350\256\241.md" "b/group26/26\347\273\204\346\203\205\345\206\265\347\273\237\350\256\241.md" index fd3298e6ca..a5099325ea 100644 --- "a/group26/26\347\273\204\346\203\205\345\206\265\347\273\237\350\256\241.md" +++ "b/group26/26\347\273\204\346\203\205\345\206\265\347\273\237\350\256\241.md" @@ -12,7 +12,7 @@ | | | | | | | | lizhy2017 | 部分完成 | | | | | | | | | | | | -| | | | | | | -| | | | | | | +| | 部分完成 | | | | | +| JEE-逆水百川 |http://blog.csdn.net/u012759397/article/details/61618612 | | | | | | | | | | | | | | | | | | | From 22607df9d3ab4ef80e4bdd3daf4da635204a1ca2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?JEE-=E9=80=86=E6=B0=B4=E7=99=BE=E5=B7=9D?= <2411685663@qq.com> Date: Mon, 13 Mar 2017 11:42:06 +0800 Subject: [PATCH 24/28] =?UTF-8?q?Update=2026=E7=BB=84=E6=83=85=E5=86=B5?= =?UTF-8?q?=E7=BB=9F=E8=AE=A1.md?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...73\204\346\203\205\345\206\265\347\273\237\350\256\241.md" | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git "a/group26/26\347\273\204\346\203\205\345\206\265\347\273\237\350\256\241.md" "b/group26/26\347\273\204\346\203\205\345\206\265\347\273\237\350\256\241.md" index a5099325ea..1623bc989e 100644 --- "a/group26/26\347\273\204\346\203\205\345\206\265\347\273\237\350\256\241.md" +++ "b/group26/26\347\273\204\346\203\205\345\206\265\347\273\237\350\256\241.md" @@ -12,7 +12,7 @@ | | | | | | | | lizhy2017 | 部分完成 | | | | | | | | | | | | -| | 部分完成 | | | | | -| JEE-逆水百川 |http://blog.csdn.net/u012759397/article/details/61618612 | | | | | +| JEE-逆水百川 | 部分完成 | | | | | +| |http://blog.csdn.net/u012759397/article/details/61618612 | | | | | | | | | | | | | | | | | | | From dea086c376f4e54d7b670fa173817439127e644d Mon Sep 17 00:00:00 2001 From: zhangrui <2411685663@qq.com> Date: Mon, 13 Mar 2017 12:00:53 +0800 Subject: [PATCH 25/28] =?UTF-8?q?=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...3\204\346\203\205\345\206\265\347\273\237\350\256\241.md" | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git "a/group26/26\347\273\204\346\203\205\345\206\265\347\273\237\350\256\241.md" "b/group26/26\347\273\204\346\203\205\345\206\265\347\273\237\350\256\241.md" index 1623bc989e..7e2b56b991 100644 --- "a/group26/26\347\273\204\346\203\205\345\206\265\347\273\237\350\256\241.md" +++ "b/group26/26\347\273\204\346\203\205\345\206\265\347\273\237\350\256\241.md" @@ -12,7 +12,4 @@ | | | | | | | | lizhy2017 | 部分完成 | | | | | | | | | | | | -| JEE-逆水百川 | 部分完成 | | | | | -| |http://blog.csdn.net/u012759397/article/details/61618612 | | | | | -| | | | | | | -| | | | | | | + From b8faf31b098d0b545300e84ffa1790d83b13ad96 Mon Sep 17 00:00:00 2001 From: zhangrui <2411685663@qq.com> Date: Mon, 13 Mar 2017 12:11:22 +0800 Subject: [PATCH 26/28] =?UTF-8?q?=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...\273\204\346\203\205\345\206\265\347\273\237\350\256\241.md" | 2 ++ 1 file changed, 2 insertions(+) diff --git "a/group26/26\347\273\204\346\203\205\345\206\265\347\273\237\350\256\241.md" "b/group26/26\347\273\204\346\203\205\345\206\265\347\273\237\350\256\241.md" index 7e2b56b991..f755900ff2 100644 --- "a/group26/26\347\273\204\346\203\205\345\206\265\347\273\237\350\256\241.md" +++ "b/group26/26\347\273\204\346\203\205\345\206\265\347\273\237\350\256\241.md" @@ -12,4 +12,6 @@ | | | | | | | | lizhy2017 | 部分完成 | | | | | | | | | | | | +| JEE-逆水百川 | 部分完成 | | | | | +| |http://blog.csdn.net/u012759397/article/details/61618612 | | | | | From 72aed923554cc1bb6a5ec971242eec0be51de08d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?JEE-=E9=80=86=E6=B0=B4=E7=99=BE=E5=B7=9D?= <2411685663@qq.com> Date: Mon, 13 Mar 2017 12:36:21 +0800 Subject: [PATCH 27/28] =?UTF-8?q?Update=2026=E7=BB=84=E6=83=85=E5=86=B5?= =?UTF-8?q?=E7=BB=9F=E8=AE=A1.md?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...204\346\203\205\345\206\265\347\273\237\350\256\241.md" | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git "a/group26/26\347\273\204\346\203\205\345\206\265\347\273\237\350\256\241.md" "b/group26/26\347\273\204\346\203\205\345\206\265\347\273\237\350\256\241.md" index f755900ff2..fd3298e6ca 100644 --- "a/group26/26\347\273\204\346\203\205\345\206\265\347\273\237\350\256\241.md" +++ "b/group26/26\347\273\204\346\203\205\345\206\265\347\273\237\350\256\241.md" @@ -12,6 +12,7 @@ | | | | | | | | lizhy2017 | 部分完成 | | | | | | | | | | | | -| JEE-逆水百川 | 部分完成 | | | | | -| |http://blog.csdn.net/u012759397/article/details/61618612 | | | | | - +| | | | | | | +| | | | | | | +| | | | | | | +| | | | | | | From d0b066bfa08662d64be53b0b20add9f87fadd49e Mon Sep 17 00:00:00 2001 From: BlindingDark <844620174@qq.com> Date: Mon, 13 Mar 2017 13:07:47 +0800 Subject: [PATCH 28/28] =?UTF-8?q?JEE-=E9=80=86=E6=B0=B4=E7=99=BE=E5=B7=9D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit JEE-逆水百川 作业进度 --- ...05\345\206\265\347\273\237\350\256\241.md" | 41 +++++++++++-------- 1 file changed, 23 insertions(+), 18 deletions(-) diff --git "a/group26/26\347\273\204\346\203\205\345\206\265\347\273\237\350\256\241.md" "b/group26/26\347\273\204\346\203\205\345\206\265\347\273\237\350\256\241.md" index a1f2d56510..a38b933f0f 100644 --- "a/group26/26\347\273\204\346\203\205\345\206\265\347\273\237\350\256\241.md" +++ "b/group26/26\347\273\204\346\203\205\345\206\265\347\273\237\350\256\241.md" @@ -1,18 +1,23 @@ -| | | | | | | -| -------------------- | :-------------------: | ---- | ---- | ---- | ---- | -| 抓狂 | 作业1 | | | | | -| | 文章1 | | | | | -| 723161901 | 已完成 | | | | | -| | | | | | | -| jiaxun1990(89460886) | 已完成 | | | | | -| | https://goo.gl/Wvz3Od | | | | | -| 1515345281 | 已完成 | | | | | -| | | | | | | -| 2070509107 | 已完成 | | | | | -| | | | | | | -| lizhy2017 | 部分完成 | | | | | -| | | | | | | -| | | | | | | -| | | | | | | -| | | | | | | -| | | | | | | \ No newline at end of file +| | | | | | | +| -------------------- | :--------------------------------------: | ---- | ---- | ---- | ---- | +| 抓狂 | 作业1 | | | | | +| | 文章1 | | | | | +| 723161901 | 已完成 | | | | | +| | | | | | | +| jiaxun1990(89460886) | 已完成 | | | | | +| | https://goo.gl/Wvz3Od | | | | | +| 1515345281 | 已完成 | | | | | +| | | | | | | +| 2070509107 | 已完成 | | | | | +| | | | | | | +| lizhy2017 | 部分完成 | | | | | +| | | | | | | +| JEE-逆水百川 | 部分完成 | | | | | +| | http://blog.csdn.net/u012759397/article/details/61618612 | | | | | +| | | | | | | +| | | | | | | +| | | | | | | +| | | | | | | +| | | | | | | +| | | | | | | +| | | | | | | \ No newline at end of file