From 12c971e71672f1b36040675005cd6a71b80a0755 Mon Sep 17 00:00:00 2001 From: tanghaojie Date: Thu, 23 Feb 2017 13:11:38 +0800 Subject: [PATCH 001/518] create --- group12/495473393/Coding/.gitignore | 1 + .../495473393/Coding/src/Base/ArrayList.java | 32 +++++++++++++ .../Coding/src/Base/BinaryTreeNode.java | 32 +++++++++++++ .../495473393/Coding/src/Base/Iterator.java | 7 +++ .../495473393/Coding/src/Base/LinkedList.java | 46 +++++++++++++++++++ group12/495473393/Coding/src/Base/List.java | 9 ++++ group12/495473393/Coding/src/Base/Queue.java | 19 ++++++++ group12/495473393/Coding/src/Base/Stack.java | 22 +++++++++ 8 files changed, 168 insertions(+) create mode 100644 group12/495473393/Coding/.gitignore create mode 100644 group12/495473393/Coding/src/Base/ArrayList.java create mode 100644 group12/495473393/Coding/src/Base/BinaryTreeNode.java create mode 100644 group12/495473393/Coding/src/Base/Iterator.java create mode 100644 group12/495473393/Coding/src/Base/LinkedList.java create mode 100644 group12/495473393/Coding/src/Base/List.java create mode 100644 group12/495473393/Coding/src/Base/Queue.java create mode 100644 group12/495473393/Coding/src/Base/Stack.java diff --git a/group12/495473393/Coding/.gitignore b/group12/495473393/Coding/.gitignore new file mode 100644 index 0000000000..ae3c172604 --- /dev/null +++ b/group12/495473393/Coding/.gitignore @@ -0,0 +1 @@ +/bin/ diff --git a/group12/495473393/Coding/src/Base/ArrayList.java b/group12/495473393/Coding/src/Base/ArrayList.java new file mode 100644 index 0000000000..0b99f87873 --- /dev/null +++ b/group12/495473393/Coding/src/Base/ArrayList.java @@ -0,0 +1,32 @@ +package Base; + +public class ArrayList implements List { + + private int size = 0; + + private Object[] elementData = new Object[100]; + + 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 Iterator iterator(){ + return null; + } + +} diff --git a/group12/495473393/Coding/src/Base/BinaryTreeNode.java b/group12/495473393/Coding/src/Base/BinaryTreeNode.java new file mode 100644 index 0000000000..875abe8c80 --- /dev/null +++ b/group12/495473393/Coding/src/Base/BinaryTreeNode.java @@ -0,0 +1,32 @@ +package Base; + +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/group12/495473393/Coding/src/Base/Iterator.java b/group12/495473393/Coding/src/Base/Iterator.java new file mode 100644 index 0000000000..19b65c3637 --- /dev/null +++ b/group12/495473393/Coding/src/Base/Iterator.java @@ -0,0 +1,7 @@ +package Base; + +public interface Iterator { + public boolean hasNext(); + public Object next(); + +} diff --git a/group12/495473393/Coding/src/Base/LinkedList.java b/group12/495473393/Coding/src/Base/LinkedList.java new file mode 100644 index 0000000000..0d4ce20167 --- /dev/null +++ b/group12/495473393/Coding/src/Base/LinkedList.java @@ -0,0 +1,46 @@ +package Base; + +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; + + } +} diff --git a/group12/495473393/Coding/src/Base/List.java b/group12/495473393/Coding/src/Base/List.java new file mode 100644 index 0000000000..6c910af600 --- /dev/null +++ b/group12/495473393/Coding/src/Base/List.java @@ -0,0 +1,9 @@ +package Base; + +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/group12/495473393/Coding/src/Base/Queue.java b/group12/495473393/Coding/src/Base/Queue.java new file mode 100644 index 0000000000..9c2948d7e3 --- /dev/null +++ b/group12/495473393/Coding/src/Base/Queue.java @@ -0,0 +1,19 @@ +package Base; + +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/group12/495473393/Coding/src/Base/Stack.java b/group12/495473393/Coding/src/Base/Stack.java new file mode 100644 index 0000000000..8f59343d4b --- /dev/null +++ b/group12/495473393/Coding/src/Base/Stack.java @@ -0,0 +1,22 @@ +package Base; + +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; + } +} From ccf95b4f73d4edee62204968c9e763201cacea19 Mon Sep 17 00:00:00 2001 From: guodongym Date: Thu, 23 Feb 2017 13:28:16 +0800 Subject: [PATCH 002/518] =?UTF-8?q?list=E5=AE=9E=E7=8E=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- group12/377401843/learning_1/.gitignore | 3 + .../com/guodong/datastructure/ArrayList.java | 171 ++++++++++++++++++ .../guodong/datastructure/BinaryTreeNode.java | 32 ++++ .../com/guodong/datastructure/Iterator.java | 7 + .../com/guodong/datastructure/LinkedList.java | 45 +++++ .../src/com/guodong/datastructure/List.java | 14 ++ .../src/com/guodong/datastructure/Queue.java | 19 ++ .../src/com/guodong/datastructure/Stack.java | 22 +++ .../datastructure/test/ArrayListTest.java | 53 ++++++ 9 files changed, 366 insertions(+) create mode 100644 group12/377401843/learning_1/.gitignore create mode 100644 group12/377401843/learning_1/src/com/guodong/datastructure/ArrayList.java create mode 100644 group12/377401843/learning_1/src/com/guodong/datastructure/BinaryTreeNode.java create mode 100644 group12/377401843/learning_1/src/com/guodong/datastructure/Iterator.java create mode 100644 group12/377401843/learning_1/src/com/guodong/datastructure/LinkedList.java create mode 100644 group12/377401843/learning_1/src/com/guodong/datastructure/List.java create mode 100644 group12/377401843/learning_1/src/com/guodong/datastructure/Queue.java create mode 100644 group12/377401843/learning_1/src/com/guodong/datastructure/Stack.java create mode 100644 group12/377401843/learning_1/src/com/guodong/datastructure/test/ArrayListTest.java diff --git a/group12/377401843/learning_1/.gitignore b/group12/377401843/learning_1/.gitignore new file mode 100644 index 0000000000..9c47ca7e58 --- /dev/null +++ b/group12/377401843/learning_1/.gitignore @@ -0,0 +1,3 @@ +/bin/ +/.project +/.classpath diff --git a/group12/377401843/learning_1/src/com/guodong/datastructure/ArrayList.java b/group12/377401843/learning_1/src/com/guodong/datastructure/ArrayList.java new file mode 100644 index 0000000000..a1ee0ee339 --- /dev/null +++ b/group12/377401843/learning_1/src/com/guodong/datastructure/ArrayList.java @@ -0,0 +1,171 @@ +package com.guodong.datastructure; + +import java.util.Arrays; + +public class ArrayList implements List { + + private int size = 0; + + private Object[] elementData = new Object[100]; + + /** + * 按下标顺序新增元素 + * + * @Method add + * @param o + * @see com.guodong.datastructure.List#add(java.lang.Object) + */ + public void add(Object o) { + ensureCapacityInternal(size + 1); + elementData[size] = o; + size++; + } + + /** + * 在指定下标位置插入元素 + * + * @Method add + * @param index + * @param o + * @see com.guodong.datastructure.List#add(int, java.lang.Object) + */ + public void add(int index, Object o) { + checkRangeForAdd(index); + + ensureCapacityInternal(size + 1); + + System.arraycopy(elementData, index, elementData, index + 1, size - index); + + elementData[index] = o; + size++; + } + + /** + * 根据下标获取列表数据 + * + * @Method get + * @param index + * @return + * @see com.guodong.datastructure.List#get(int) + */ + public Object get(int index) { + checkRangeForGetOrRemove(index); + + return elementData[index]; + } + + /** + * 根据下标移除元素,并返回移除的元素值 + * + * @Method remove + * @param index + * @return + * @see com.guodong.datastructure.List#remove(int) + */ + public Object remove(int index) { + checkRangeForGetOrRemove(index); + + Object oldValue = elementData[index]; + + System.arraycopy(elementData, index + 1, elementData, index, size - index -1); + + size--; + elementData[size] = null; + + return oldValue; + } + + /** + * 获得列表长度 + * + * @Method size + * @return + * @see com.guodong.datastructure.List#size() + */ + public int size() { + return size; + } + + /** + * 获取ArrayList的迭代器 + * + * @MethodName iterator + * @author zhaogd + * @date 2017年2月21日 下午8:19:28 + * @return + */ + public Iterator iterator() { + return new ArrayListIterator(); + } + + /** + * 确保数组容量足够,如果不够则扩充数组 + * + * @MethodName ensureCapacityInternal + * @author zhaogd + * @date 2017年2月21日 下午5:06:46 + * @param minCapacity + */ + private void ensureCapacityInternal(int minCapacity) { + if(minCapacity > elementData.length){ + grow(minCapacity); + } + } + + /** + * 数组扩充,每次扩充原数组一半的长度,然后把原数组拷贝到新数组 + * + * @MethodName grow + * @author zhaogd + * @date 2017年2月21日 下午5:20:55 + * @param minCapacity + */ + private void grow(int minCapacity) { + minCapacity = elementData.length + elementData.length / 2; + elementData = Arrays.copyOf(elementData, minCapacity); + } + + /** + * 检查Add方法的下标范围是否合法 + * + * @MethodName checkRangeForAdd + * @author zhaogd + * @date 2017年2月21日 下午7:32:55 + * @param index + */ + private void checkRangeForAdd(int index) { + if(index > size || index < 0){ + throw new IndexOutOfBoundsException("Index:" + index + ",Size:" + size); + } + } + + /** + * 检查Get或者Remove方法的下标范围是否合法 + * + * @MethodName checkRangeForGetOrRemove + * @author zhaogd + * @date 2017年2月21日 下午7:33:21 + * @param index + */ + private void checkRangeForGetOrRemove(int index) { + if(index >= size || index < 0){ + throw new IndexOutOfBoundsException("Index:" + index + ",Size:" + size); + } + } + + + private class ArrayListIterator implements Iterator{ + + private int lastIndex = 0; + + @Override + public boolean hasNext() { + return lastIndex < size; + } + + @Override + public Object next() { + return elementData[lastIndex++]; + } + } +} diff --git a/group12/377401843/learning_1/src/com/guodong/datastructure/BinaryTreeNode.java b/group12/377401843/learning_1/src/com/guodong/datastructure/BinaryTreeNode.java new file mode 100644 index 0000000000..933e72acda --- /dev/null +++ b/group12/377401843/learning_1/src/com/guodong/datastructure/BinaryTreeNode.java @@ -0,0 +1,32 @@ +package com.guodong.datastructure; + +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/group12/377401843/learning_1/src/com/guodong/datastructure/Iterator.java b/group12/377401843/learning_1/src/com/guodong/datastructure/Iterator.java new file mode 100644 index 0000000000..1a9bc5ad8a --- /dev/null +++ b/group12/377401843/learning_1/src/com/guodong/datastructure/Iterator.java @@ -0,0 +1,7 @@ +package com.guodong.datastructure; + +public interface Iterator { + public boolean hasNext(); + public Object next(); + +} diff --git a/group12/377401843/learning_1/src/com/guodong/datastructure/LinkedList.java b/group12/377401843/learning_1/src/com/guodong/datastructure/LinkedList.java new file mode 100644 index 0000000000..fc801505f1 --- /dev/null +++ b/group12/377401843/learning_1/src/com/guodong/datastructure/LinkedList.java @@ -0,0 +1,45 @@ +package com.guodong.datastructure; + +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; + } +} diff --git a/group12/377401843/learning_1/src/com/guodong/datastructure/List.java b/group12/377401843/learning_1/src/com/guodong/datastructure/List.java new file mode 100644 index 0000000000..2471c15d21 --- /dev/null +++ b/group12/377401843/learning_1/src/com/guodong/datastructure/List.java @@ -0,0 +1,14 @@ +package com.guodong.datastructure; + +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/group12/377401843/learning_1/src/com/guodong/datastructure/Queue.java b/group12/377401843/learning_1/src/com/guodong/datastructure/Queue.java new file mode 100644 index 0000000000..d016046bc5 --- /dev/null +++ b/group12/377401843/learning_1/src/com/guodong/datastructure/Queue.java @@ -0,0 +1,19 @@ +package com.guodong.datastructure; + +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/group12/377401843/learning_1/src/com/guodong/datastructure/Stack.java b/group12/377401843/learning_1/src/com/guodong/datastructure/Stack.java new file mode 100644 index 0000000000..a61c7424aa --- /dev/null +++ b/group12/377401843/learning_1/src/com/guodong/datastructure/Stack.java @@ -0,0 +1,22 @@ +package com.guodong.datastructure; + +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/group12/377401843/learning_1/src/com/guodong/datastructure/test/ArrayListTest.java b/group12/377401843/learning_1/src/com/guodong/datastructure/test/ArrayListTest.java new file mode 100644 index 0000000000..e22d84f72c --- /dev/null +++ b/group12/377401843/learning_1/src/com/guodong/datastructure/test/ArrayListTest.java @@ -0,0 +1,53 @@ +package com.guodong.datastructure.test; + +import static org.junit.Assert.*; + + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +import com.guodong.datastructure.ArrayList; + +public class ArrayListTest { + + @Before + public void setUp() throws Exception { + } + + @After + public void tearDown() throws Exception { + } + + @Test + public void testAddObject() { + ArrayList arrayList = new ArrayList(); + arrayList.add(1); + assertEquals(1, arrayList.get(0)); + } + + @Test + public void testAddIntObject() { + fail("Not yet implemented"); + } + + @Test + public void testGet() { + fail("Not yet implemented"); + } + + @Test + public void testRemove() { + fail("Not yet implemented"); + } + + @Test + public void testSize() { + fail("Not yet implemented"); + } + + @Test + public void testIterator() { + fail("Not yet implemented"); + } +} From d7b3f1e246068bbfe6f33d51029767ff74783729 Mon Sep 17 00:00:00 2001 From: livenQiang Date: Thu, 23 Feb 2017 13:36:20 +0800 Subject: [PATCH 003/518] =?UTF-8?q?=E5=AE=8C=E6=88=90=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- group20/286166752/.gitignore | 4 + .../liven/code/dataStructures/ArrayList.java | 86 +++++++++++++++++++ .../liven/code/dataStructures/LinkedList.java | 40 +++++++++ .../wiki/liven/code/dataStructures/List.java | 14 +++ .../wiki/liven/code/dataStructures/Queue.java | 7 ++ .../wiki/liven/code/dataStructures/Stack.java | 7 ++ .../src/wiki/liven/code/test/SomeDemos.java | 15 ++++ 7 files changed, 173 insertions(+) create mode 100644 group20/286166752/.gitignore create mode 100644 group20/286166752/src/wiki/liven/code/dataStructures/ArrayList.java create mode 100644 group20/286166752/src/wiki/liven/code/dataStructures/LinkedList.java create mode 100644 group20/286166752/src/wiki/liven/code/dataStructures/List.java create mode 100644 group20/286166752/src/wiki/liven/code/dataStructures/Queue.java create mode 100644 group20/286166752/src/wiki/liven/code/dataStructures/Stack.java create mode 100644 group20/286166752/src/wiki/liven/code/test/SomeDemos.java diff --git a/group20/286166752/.gitignore b/group20/286166752/.gitignore new file mode 100644 index 0000000000..d120d1749d --- /dev/null +++ b/group20/286166752/.gitignore @@ -0,0 +1,4 @@ +.idea/ +286166752.iml +out/ + diff --git a/group20/286166752/src/wiki/liven/code/dataStructures/ArrayList.java b/group20/286166752/src/wiki/liven/code/dataStructures/ArrayList.java new file mode 100644 index 0000000000..68444b87a9 --- /dev/null +++ b/group20/286166752/src/wiki/liven/code/dataStructures/ArrayList.java @@ -0,0 +1,86 @@ +package wiki.liven.code.dataStructures; + +/** + * Created by leven on 2017/2/21. + */ +public class ArrayList implements List{ + + /** + * 列表中元素的个数 + */ + private int size = 0; + private int maxSize = 100; + /** + * 初始数组 + */ + private Object[] elementData = new Object[maxSize]; + + /** + * 在指定的位置i插入元素O + * 插入元素,判断当前列表中元素的个数, + * 当size==100,则需要扩张数组 + * 当size<100,则使用初始数组完成插入操作 + * 插入操作: + * 从最后一个元素开始,往后移动一位,直到到index为止. + * @param index + * @param o + */ + @Override + public void add(int index, Object o) { + if (size>=maxSize){ + Object[] targt = new Object[++maxSize]; + System.arraycopy(elementData,0,targt,0,maxSize); + for (int j = targt.length;j>=index;j--){ + targt[j-1] = targt[j-2]; + } + targt[index] = o; + size++; + }else if(size=index;j--){ + elementData[j-1] = elementData[j-2]; + } + elementData[index] = o; + size++; + } + } + + /** + * 追加元素 + * @param o + */ + @Override + public void add(Object o) { + if (size>=maxSize){ + Object[] targt = new Object[++maxSize]; + System.arraycopy(elementData,0,targt,0,maxSize); + targt[maxSize-1] = o; + size++; + }else if(sizesize-1;i++){ + elementData[i] = elementData[i+1]; + } + return temp; + } + + @Override + public int size() { + return size; + } + + + + +} diff --git a/group20/286166752/src/wiki/liven/code/dataStructures/LinkedList.java b/group20/286166752/src/wiki/liven/code/dataStructures/LinkedList.java new file mode 100644 index 0000000000..b2cc5f8668 --- /dev/null +++ b/group20/286166752/src/wiki/liven/code/dataStructures/LinkedList.java @@ -0,0 +1,40 @@ +package wiki.liven.code.dataStructures; + +/** + * Created by leven on 2017/2/21. + */ +public class LinkedList implements List{ + + private Node head; + + private static class Node{ + Object data; + Node next; + } + + + @Override + public void add(int index, Object o) { + + } + + @Override + public void add(Object o) { + + } + + @Override + public Object get(int index) { + return null; + } + + @Override + public Object remove(int index) { + return null; + } + + @Override + public int size() { + return 0; + } +} diff --git a/group20/286166752/src/wiki/liven/code/dataStructures/List.java b/group20/286166752/src/wiki/liven/code/dataStructures/List.java new file mode 100644 index 0000000000..2d1840ef0f --- /dev/null +++ b/group20/286166752/src/wiki/liven/code/dataStructures/List.java @@ -0,0 +1,14 @@ +package wiki.liven.code.dataStructures; + +/** + * Created by leven on 2017/2/21. + */ +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/group20/286166752/src/wiki/liven/code/dataStructures/Queue.java b/group20/286166752/src/wiki/liven/code/dataStructures/Queue.java new file mode 100644 index 0000000000..b8c8430daa --- /dev/null +++ b/group20/286166752/src/wiki/liven/code/dataStructures/Queue.java @@ -0,0 +1,7 @@ +package wiki.liven.code.dataStructures; + +/** + * Created by leven on 2017/2/21. + */ +public class Queue { +} diff --git a/group20/286166752/src/wiki/liven/code/dataStructures/Stack.java b/group20/286166752/src/wiki/liven/code/dataStructures/Stack.java new file mode 100644 index 0000000000..59cb18c416 --- /dev/null +++ b/group20/286166752/src/wiki/liven/code/dataStructures/Stack.java @@ -0,0 +1,7 @@ +package wiki.liven.code.dataStructures; + +/** + * Created by leven on 2017/2/21. + */ +public class Stack { +} diff --git a/group20/286166752/src/wiki/liven/code/test/SomeDemos.java b/group20/286166752/src/wiki/liven/code/test/SomeDemos.java new file mode 100644 index 0000000000..90a74edc35 --- /dev/null +++ b/group20/286166752/src/wiki/liven/code/test/SomeDemos.java @@ -0,0 +1,15 @@ +package wiki.liven.code.test; + +/** + * Created by leven on 2017/2/21. + */ +public class SomeDemos { + + public static void main(String[] args){ + int[] a = new int[10]; + a[0] = 4; + System.out.println(a.length); + + } + +} From f21458d3f419f02ec5bb3e17dd2beb0b81ce1fab Mon Sep 17 00:00:00 2001 From: zheng <765324639@qq.com> Date: Thu, 23 Feb 2017 13:38:17 +0800 Subject: [PATCH 004/518] =?UTF-8?q?=E7=AC=AC=E4=B8=80=E5=91=A8=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E7=BB=93=E6=9E=84=E4=BD=9C=E4=B8=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/zavier/week01/basic/ArrayList.java | 85 ++++++++++ .../zavier/week01/basic/BinaryTreeNode.java | 63 ++++++++ .../src/zavier/week01/basic/Iterator.java | 8 + .../src/zavier/week01/basic/LinkedList.java | 148 ++++++++++++++++++ .../src/zavier/week01/basic/List.java | 13 ++ .../src/zavier/week01/basic/Queue.java | 25 +++ .../src/zavier/week01/basic/Stack.java | 33 ++++ .../src/zavier/week01/test/AllTests.java | 12 ++ .../src/zavier/week01/test/ArrayListTest.java | 91 +++++++++++ .../week01/test/BinaryTreeNodeTest.java | 33 ++++ .../zavier/week01/test/LinkedListTest.java | 109 +++++++++++++ .../src/zavier/week01/test/QueueTest.java | 49 ++++++ .../src/zavier/week01/test/StackTest.java | 60 +++++++ 13 files changed, 729 insertions(+) create mode 100644 group01/765324639/src/zavier/week01/basic/ArrayList.java create mode 100644 group01/765324639/src/zavier/week01/basic/BinaryTreeNode.java create mode 100644 group01/765324639/src/zavier/week01/basic/Iterator.java create mode 100644 group01/765324639/src/zavier/week01/basic/LinkedList.java create mode 100644 group01/765324639/src/zavier/week01/basic/List.java create mode 100644 group01/765324639/src/zavier/week01/basic/Queue.java create mode 100644 group01/765324639/src/zavier/week01/basic/Stack.java create mode 100644 group01/765324639/src/zavier/week01/test/AllTests.java create mode 100644 group01/765324639/src/zavier/week01/test/ArrayListTest.java create mode 100644 group01/765324639/src/zavier/week01/test/BinaryTreeNodeTest.java create mode 100644 group01/765324639/src/zavier/week01/test/LinkedListTest.java create mode 100644 group01/765324639/src/zavier/week01/test/QueueTest.java create mode 100644 group01/765324639/src/zavier/week01/test/StackTest.java diff --git a/group01/765324639/src/zavier/week01/basic/ArrayList.java b/group01/765324639/src/zavier/week01/basic/ArrayList.java new file mode 100644 index 0000000000..38e5739fb8 --- /dev/null +++ b/group01/765324639/src/zavier/week01/basic/ArrayList.java @@ -0,0 +1,85 @@ +package zavier.week01.basic; + +import java.util.Arrays; + +public class ArrayList implements List { + + private int size = 0; + + private Object[] elementData = new Object[100]; + + @Override + public void add(Object o) { + ensureCapacity(size + 1); + elementData[size++] = o; + } + + private void ensureCapacity(int size) { + if (size > elementData.length) { + grow(); + } + } + + private void grow() { + elementData = Arrays.copyOf(elementData, size * 2); + } + + @Override + public void add(int index, Object o) { + rangeCheckForAdd(index); + ensureCapacity(size + 1); + System.arraycopy(elementData, index, elementData, index + 1, size - index); + elementData[index] = o; + size++; + } + + private void rangeCheckForAdd(int index) { + if (index < 0 || index > size) { + throw new IndexOutOfBoundsException(); + } + } + + @Override + public Object get(int index) { + rangeCheck(index); + return elementData[index]; + } + + private void rangeCheck(int index) { + if (index >= size || index < 0) { + throw new IndexOutOfBoundsException(); + } + } + + @Override + public Object remove(int index) { + rangeCheck(index); + Object dest = elementData[index]; + System.arraycopy(elementData, index + 1, elementData, index, size - index - 1); + size--; + return dest; + } + + @Override + public int size() { + return size; + } + + public Iterator iterator() { + return new Iterator() { + + private int index = 0; + + @Override + public Object next() { + return elementData[index++]; + } + + @Override + public boolean hasNext() { + return index < size; + } + }; + } + +} diff --git a/group01/765324639/src/zavier/week01/basic/BinaryTreeNode.java b/group01/765324639/src/zavier/week01/basic/BinaryTreeNode.java new file mode 100644 index 0000000000..6ef26e8f9a --- /dev/null +++ b/group01/765324639/src/zavier/week01/basic/BinaryTreeNode.java @@ -0,0 +1,63 @@ +package zavier.week01.basic; + +public class BinaryTreeNode { + + private Integer data; + private BinaryTreeNode left; + private BinaryTreeNode right; + + public BinaryTreeNode(Integer data) { + this.data = data; + } + + public Integer getData() { + return data; + } + + public void setData(Integer data) { + this.data = data; + } + + public BinaryTreeNode getLeft() { + return left; + } + + public void setLeft(BinaryTreeNode left) { + this.left = left; + } + + public BinaryTreeNode getRight() { + return right; + } + + public void setRight(BinaryTreeNode right) { + this.right = right; + } + + public BinaryTreeNode insert(Integer o) { + + if (o > this.data) { + + if (this.getRight() == null) { + BinaryTreeNode node = new BinaryTreeNode(o); + this.setRight(node); + return node; + } else { + return this.getRight().insert(o); + } + + } else { + + if (this.getLeft() == null) { + BinaryTreeNode node = new BinaryTreeNode(o); + this.setLeft(node); + return node; + } else { + return this.getLeft().insert(o); + } + + } + + } + +} diff --git a/group01/765324639/src/zavier/week01/basic/Iterator.java b/group01/765324639/src/zavier/week01/basic/Iterator.java new file mode 100644 index 0000000000..664983e0fd --- /dev/null +++ b/group01/765324639/src/zavier/week01/basic/Iterator.java @@ -0,0 +1,8 @@ +package zavier.week01.basic; + +public interface Iterator { + public boolean hasNext(); + + public Object next(); + +} diff --git a/group01/765324639/src/zavier/week01/basic/LinkedList.java b/group01/765324639/src/zavier/week01/basic/LinkedList.java new file mode 100644 index 0000000000..c876b48f1b --- /dev/null +++ b/group01/765324639/src/zavier/week01/basic/LinkedList.java @@ -0,0 +1,148 @@ +package zavier.week01.basic; + +import java.util.NoSuchElementException; + +public class LinkedList implements List { + + private Node head; + + private int size = 0; + + @Override + public void add(Object o) { + if (head == null) { + head = new Node(o); + } else { + Node tail = head; + while (tail.next != null) { + tail = tail.next; + } + Node node = new Node(o); + + tail.next = node; + } + size++; + } + + @Override + public void add(int index, Object o) { + rangeCheckForAdd(index); + if (index == 0) { + Node node = new Node(o); + node.next = head; + head = node; + } else { + Node preDest = head; + for (int i = 0; i < index - 1; i++) { + preDest = preDest.next; + } + Node node = new Node(o); + node.next = preDest.next; + preDest.next = node; + } + + size++; + } + + private void rangeCheckForAdd(int index) { + if (index > size || index < 0) { + throw new IndexOutOfBoundsException(); + } + } + + @Override + public Object get(int index) { + rangeCheck(index); + + Node dest = head; + for (int i = 0; i < index; i++) { + dest = dest.next; + } + return dest.data; + } + + private void rangeCheck(int index) { + if (index >= size || index < 0) { + throw new IndexOutOfBoundsException(); + } + } + + @Override + public Object remove(int index) { + rangeCheck(index); + + Node preDest = head; + for (int i = 0; i < index - 1; i++) { + preDest = preDest.next; + } + Node dest = preDest.next; + preDest.next = dest.next; + + size--; + return dest.data; + } + + @Override + public int size() { + return size; + } + + public void addFirst(Object o) { + Node node = new Node(o); + node.next = head; + head = node; + size++; + } + + public void addLast(Object o) { + Node lastNode = head; + while (lastNode.next != null) { + lastNode = lastNode.next; + } + + Node node = new Node(o); + lastNode.next = node; + size++; + } + + public Object removeFirst() { + if (head == null) { + throw new NoSuchElementException(); + } + Node target = head; + head = head.next; + size--; + return target.data; + } + + public Object removeLast() { + if (head == null) { + throw new NoSuchElementException(); + } + + Node preDest = head; + while (preDest.next.next != null) { + preDest = preDest.next; + } + Node dest = preDest.next; + preDest.next = null; + + size--; + return dest.data; + } + + public Iterator iterator() { + return null; + } + + + private static class Node { + Object data; + Node next; + + Node(Object data) { + this.data = data; + next = null; + } + } +} diff --git a/group01/765324639/src/zavier/week01/basic/List.java b/group01/765324639/src/zavier/week01/basic/List.java new file mode 100644 index 0000000000..4f2d49bd73 --- /dev/null +++ b/group01/765324639/src/zavier/week01/basic/List.java @@ -0,0 +1,13 @@ +package zavier.week01.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/group01/765324639/src/zavier/week01/basic/Queue.java b/group01/765324639/src/zavier/week01/basic/Queue.java new file mode 100644 index 0000000000..5a212d46c1 --- /dev/null +++ b/group01/765324639/src/zavier/week01/basic/Queue.java @@ -0,0 +1,25 @@ +package zavier.week01.basic; + +public class Queue { + + private LinkedList list = new LinkedList(); + + public void enQueue(Object o) { + list.add(o); + } + + public Object deQueue() { + if (list.size() == 0) { + return null; + } + return list.removeFirst(); + } + + public boolean isEmpty() { + return list.size() == 0; + } + + public int size() { + return list.size(); + } +} diff --git a/group01/765324639/src/zavier/week01/basic/Stack.java b/group01/765324639/src/zavier/week01/basic/Stack.java new file mode 100644 index 0000000000..ebe4afb19f --- /dev/null +++ b/group01/765324639/src/zavier/week01/basic/Stack.java @@ -0,0 +1,33 @@ +package zavier.week01.basic; + +import java.util.EmptyStackException; + +public class Stack { + private ArrayList elementData = new ArrayList(); + + public void push(Object o) { + elementData.add(o); + } + + public Object pop() { + if (elementData.size() == 0) { + throw new EmptyStackException(); + } + return elementData.remove(elementData.size() - 1); + } + + public Object peek() { + if (elementData.size() == 0) { + throw new EmptyStackException(); + } + return elementData.get(elementData.size() - 1); + } + + public boolean isEmpty() { + return elementData.size() == 0; + } + + public int size() { + return elementData.size(); + } +} diff --git a/group01/765324639/src/zavier/week01/test/AllTests.java b/group01/765324639/src/zavier/week01/test/AllTests.java new file mode 100644 index 0000000000..c1755f6803 --- /dev/null +++ b/group01/765324639/src/zavier/week01/test/AllTests.java @@ -0,0 +1,12 @@ +package zavier.week01.test; + +import org.junit.runner.RunWith; +import org.junit.runners.Suite; +import org.junit.runners.Suite.SuiteClasses; + +@RunWith(Suite.class) +@SuiteClasses({ArrayListTest.class, LinkedListTest.class, QueueTest.class, StackTest.class, + BinaryTreeNodeTest.class}) +public class AllTests { + +} diff --git a/group01/765324639/src/zavier/week01/test/ArrayListTest.java b/group01/765324639/src/zavier/week01/test/ArrayListTest.java new file mode 100644 index 0000000000..6a475500df --- /dev/null +++ b/group01/765324639/src/zavier/week01/test/ArrayListTest.java @@ -0,0 +1,91 @@ +package zavier.week01.test; + +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; + +import zavier.week01.basic.ArrayList; +import zavier.week01.basic.Iterator; + +public class ArrayListTest { + + private ArrayList arrayList = new ArrayList(); + + @Before + public void setUp() { + for (int i = 0; i < 500; i++) { + arrayList.add(i); + } + } + + @Test + public void testAddObject() { + for (int i = 0; i < 500; i++) { + arrayList.add(i); + } + } + + @Test + public void testAddIntObject() { + arrayList.add(100, -100); + Assert.assertEquals(-100, arrayList.get(100)); + Assert.assertEquals(100, arrayList.get(101)); + Assert.assertEquals(501, arrayList.size()); + } + + @Test(expected = IndexOutOfBoundsException.class) + public void testAddIllegalIntObject() { + arrayList.add(1000, 5); + } + + @Test(expected = IndexOutOfBoundsException.class) + public void testAddNegativeIntObject() { + arrayList.add(-1, 5); + } + + @Test + public void testGet() { + for (int i = 0; i < 500; i++) { + Assert.assertEquals(i, ((Integer) arrayList.get(i)).intValue()); + } + } + + @Test(expected = IndexOutOfBoundsException.class) + public void testIllegalGet() { + arrayList.get(500); + } + + @Test(expected = IndexOutOfBoundsException.class) + public void testNegativeGet() { + arrayList.get(-10); + } + + @Test + public void testRemove() { + Assert.assertEquals(100, arrayList.remove(100)); + Assert.assertEquals(101, arrayList.get(100)); + Assert.assertEquals(499, arrayList.size()); + } + + @Test(expected = IndexOutOfBoundsException.class) + public void testIllegalRemove() { + arrayList.remove(500); + } + + @Test + public void testSize() { + Assert.assertEquals(500, arrayList.size()); + } + + @Test + public void testIterator() { + Iterator iterator = arrayList.iterator(); + int i = 0; + while (iterator.hasNext()) { + Assert.assertEquals(i, iterator.next()); + i++; + } + Assert.assertEquals(500, i); + } + +} diff --git a/group01/765324639/src/zavier/week01/test/BinaryTreeNodeTest.java b/group01/765324639/src/zavier/week01/test/BinaryTreeNodeTest.java new file mode 100644 index 0000000000..30a096a350 --- /dev/null +++ b/group01/765324639/src/zavier/week01/test/BinaryTreeNodeTest.java @@ -0,0 +1,33 @@ +package zavier.week01.test; + +import org.junit.Assert; +import org.junit.Test; + +import zavier.week01.basic.BinaryTreeNode; + +public class BinaryTreeNodeTest { + + private BinaryTreeNode root = new BinaryTreeNode(5); + + @Test + public void testInsert() { + root.insert(2); + root.insert(7); + root.insert(1); + root.insert(6); + + Assert.assertEquals((Integer) 5, root.getData()); + Assert.assertEquals((Integer) 2, root.getLeft().getData()); + Assert.assertEquals((Integer) 1, root.getLeft().getLeft().getData()); + Assert.assertEquals(null, root.getLeft().getRight()); + Assert.assertEquals((Integer) 7, root.getRight().getData()); + Assert.assertEquals((Integer) 6, root.getRight().getLeft().getData()); + Assert.assertEquals(null, root.getRight().getRight()); + + root.insert(4); + root.insert(8); + Assert.assertEquals((Integer) 4, root.getLeft().getRight().getData()); + Assert.assertEquals((Integer) 8, root.getRight().getRight().getData()); + } + +} diff --git a/group01/765324639/src/zavier/week01/test/LinkedListTest.java b/group01/765324639/src/zavier/week01/test/LinkedListTest.java new file mode 100644 index 0000000000..de7436a350 --- /dev/null +++ b/group01/765324639/src/zavier/week01/test/LinkedListTest.java @@ -0,0 +1,109 @@ +package zavier.week01.test; + +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; + +import zavier.week01.basic.LinkedList; + + +public class LinkedListTest { + + private LinkedList linkedList = new LinkedList(); + + @Before + public void setUp() { + for (int i = 0; i < 500; i++) { + linkedList.add(i); + } + } + + @Test + public void testAddObject() { + for (int i = 0; i < 100; i++) { + linkedList.add(i); + } + Assert.assertEquals(600, linkedList.size()); + } + + @Test + public void testAddIntObject() { + linkedList.add(100, -100); + Assert.assertEquals(-100, linkedList.get(100)); + Assert.assertEquals(100, linkedList.get(101)); + } + + @Test(expected = IndexOutOfBoundsException.class) + public void testAddIllegalIntObject() { + linkedList.add(1000, 10); + } + + @Test(expected = IndexOutOfBoundsException.class) + public void testAddNegativeIntObject() { + linkedList.add(-10, 10); + } + + @Test + public void testGet() { + for (int i = 0; i < 500; i++) { + Assert.assertEquals(i, ((Integer) linkedList.get(i)).intValue()); + } + } + + @Test(expected = IndexOutOfBoundsException.class) + public void testIllegalGet() { + linkedList.get(500); + } + + @Test(expected = IndexOutOfBoundsException.class) + public void testNegativeGet() { + linkedList.get(-10); + } + + @Test + public void testRemove() { + Assert.assertEquals(100, linkedList.remove(100)); + Assert.assertEquals(101, linkedList.get(100)); + Assert.assertEquals(499, linkedList.size()); + } + + @Test + public void testSize() { + Assert.assertEquals(500, linkedList.size()); + linkedList.add(10); + Assert.assertEquals(501, linkedList.size()); + } + + @Test + public void testAddFirst() { + linkedList.addFirst(-10); + Assert.assertEquals(-10, linkedList.get(0)); + linkedList.addFirst(-100); + Assert.assertEquals(-100, linkedList.get(0)); + Assert.assertEquals(-10, linkedList.get(1)); + } + + @Test + public void testAddLast() { + linkedList.addLast(-9); + Assert.assertEquals(-9, linkedList.get(linkedList.size() - 1)); + linkedList.addLast(-8); + Assert.assertEquals(-8, linkedList.get(linkedList.size() - 1)); + Assert.assertEquals(-9, linkedList.get(linkedList.size() - 2)); + } + + @Test + public void testRemoveFirst() { + Assert.assertEquals(0, linkedList.removeFirst()); + Assert.assertEquals(1, linkedList.removeFirst()); + Assert.assertEquals(498, linkedList.size()); + } + + @Test + public void testRemoveLast() { + Assert.assertEquals(499, linkedList.removeLast()); + Assert.assertEquals(498, linkedList.removeLast()); + Assert.assertEquals(498, linkedList.size()); + } + +} diff --git a/group01/765324639/src/zavier/week01/test/QueueTest.java b/group01/765324639/src/zavier/week01/test/QueueTest.java new file mode 100644 index 0000000000..99d6466c8a --- /dev/null +++ b/group01/765324639/src/zavier/week01/test/QueueTest.java @@ -0,0 +1,49 @@ +package zavier.week01.test; + +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; + +import zavier.week01.basic.Queue; + +public class QueueTest { + + private Queue queue = new Queue(); + + @Before + public void setUp() { + for (int i = 0; i < 500; i++) { + queue.enQueue(i); + } + } + + @Test + public void testEnQueue() { + for (int i = 0; i < 100; i++) { + queue.enQueue(i); + } + Assert.assertEquals(600, queue.size()); + } + + @Test + public void testDeQueue() { + for (int i = 0; i < 500; i++) { + Assert.assertEquals(i, queue.deQueue()); + } + Assert.assertNull(queue.deQueue()); + Assert.assertNull(queue.deQueue()); + } + + @Test + public void testIsEmpty() { + Assert.assertFalse(queue.isEmpty()); + Queue q = new Queue(); + Assert.assertTrue(q.isEmpty()); + } + + @Test + public void testSize() { + Assert.assertEquals(500, queue.size()); + } + +} diff --git a/group01/765324639/src/zavier/week01/test/StackTest.java b/group01/765324639/src/zavier/week01/test/StackTest.java new file mode 100644 index 0000000000..8138f97d3d --- /dev/null +++ b/group01/765324639/src/zavier/week01/test/StackTest.java @@ -0,0 +1,60 @@ +package zavier.week01.test; + +import java.util.EmptyStackException; + +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; + +import zavier.week01.basic.Stack; + + +public class StackTest { + + private Stack stack = new Stack(); + + @Before + public void setUp() { + for (int i = 0; i < 500; i++) { + stack.push(i); + } + } + + @Test + public void testPush() { + for (int i = 0; i < 100; i++) { + stack.push(i); + } + Assert.assertEquals(600, stack.size()); + } + + @Test(expected = EmptyStackException.class) + public void testPop() { + for (int i = 0; i < 500; i++) { + Assert.assertEquals(499 - i, stack.pop()); + } + stack.pop(); + } + + @Test + public void testPeek() { + Assert.assertEquals(499, stack.peek()); + Assert.assertEquals(499, stack.peek()); + stack.pop(); + Assert.assertEquals(498, stack.peek()); + } + + @Test + public void testIsEmpty() { + Assert.assertFalse(stack.isEmpty()); + Assert.assertTrue(new Stack().isEmpty()); + } + + @Test + public void testSize() { + Assert.assertEquals(500, stack.size()); + stack.pop(); + Assert.assertEquals(499, stack.size()); + } + +} From bddcf6e28a648405325343e52a3c4eb5b79cfdeb Mon Sep 17 00:00:00 2001 From: zj <2258659044@qq.com> Date: Thu, 23 Feb 2017 13:40:27 +0800 Subject: [PATCH 005/518] my project --- group12/2258659044/readme.txt | 1 + .../src/com/coding/basic/ArrayList.java | 100 +++++++++++++ .../src/com/coding/basic/BinaryTreeNode.java | 81 +++++++++++ .../src/com/coding/basic/Iterator.java | 8 + .../src/com/coding/basic/LinkedList.java | 137 ++++++++++++++++++ .../zj-2017/src/com/coding/basic/List.java | 10 ++ .../zj-2017/src/com/coding/basic/Queue.java | 26 ++++ .../zj-2017/src/com/coding/basic/Stack.java | 28 ++++ .../test/com/coding/basic/ArrayListTest.java | 109 ++++++++++++++ .../test/com/coding/basic/LinkedListTest.java | 109 ++++++++++++++ 10 files changed, 609 insertions(+) create mode 100644 group12/2258659044/readme.txt create mode 100644 group12/2258659044/zj-2017/src/com/coding/basic/ArrayList.java create mode 100644 group12/2258659044/zj-2017/src/com/coding/basic/BinaryTreeNode.java create mode 100644 group12/2258659044/zj-2017/src/com/coding/basic/Iterator.java create mode 100644 group12/2258659044/zj-2017/src/com/coding/basic/LinkedList.java create mode 100644 group12/2258659044/zj-2017/src/com/coding/basic/List.java create mode 100644 group12/2258659044/zj-2017/src/com/coding/basic/Queue.java create mode 100644 group12/2258659044/zj-2017/src/com/coding/basic/Stack.java create mode 100644 group12/2258659044/zj-2017/src/test/com/coding/basic/ArrayListTest.java create mode 100644 group12/2258659044/zj-2017/src/test/com/coding/basic/LinkedListTest.java diff --git a/group12/2258659044/readme.txt b/group12/2258659044/readme.txt new file mode 100644 index 0000000000..59c627dd7e --- /dev/null +++ b/group12/2258659044/readme.txt @@ -0,0 +1 @@ +this is my projectWorkcpace! \ No newline at end of file diff --git a/group12/2258659044/zj-2017/src/com/coding/basic/ArrayList.java b/group12/2258659044/zj-2017/src/com/coding/basic/ArrayList.java new file mode 100644 index 0000000000..16cd3a0fc1 --- /dev/null +++ b/group12/2258659044/zj-2017/src/com/coding/basic/ArrayList.java @@ -0,0 +1,100 @@ +package com.coding.basic; + +import java.util.NoSuchElementException; + +public class ArrayList implements List { + + private int size = 0; + /*扩容因子*/ + private static final int GENE = 10; + + private Object[] elementData = new Object[10]; + /*扩容引用*/ + private Object[] newElementData; + + public void add(Object o){ + if(size>=elementData.length){//扩容 + grow(); + } + elementData[size] = o; + size ++; + } + public void add(int index, Object o){ + + if(index>size){ + throw new IndexOutOfBoundsException("Index: "+index+",Size:"+size); + } + if(size>=elementData.length||index>=elementData.length-1){//长度不够需要扩容 + grow(); + } + if(indexsize){ + size = index+1; + }else{ + size ++; + } + } + + public Object get(int index){ + + if(index>=size){ + throw new IndexOutOfBoundsException("Index: "+index+",Size:"+size); + } + return elementData[index]; + } + + public Object remove(int index){ + + Object o = elementData[index]; + System.arraycopy(elementData, index+1, elementData, index, size-(index+1)); + size --; + return o; + } + + public int size(){ + return size; + } + + /** + * 扩容,扩容因子为10 + */ + private void grow(){ + + newElementData = new Object[size+GENE]; + System.arraycopy(elementData, 0, newElementData, 0, elementData.length); + elementData = newElementData; + } + + + public Iterator iterator(){ + + return new Itr(); + } + + private class Itr implements Iterator{ + + int cursor; + @Override + public boolean hasNext() { + return cursor != ArrayList.this.size; + } + + @Override + public Object next() { + + int i = this.cursor; + if (i >= ArrayList.this.size){ + throw new NoSuchElementException(); + } + this.cursor = (i + 1); + return ArrayList.this.elementData[i]; + } + + } +} diff --git a/group12/2258659044/zj-2017/src/com/coding/basic/BinaryTreeNode.java b/group12/2258659044/zj-2017/src/com/coding/basic/BinaryTreeNode.java new file mode 100644 index 0000000000..c167c877c3 --- /dev/null +++ b/group12/2258659044/zj-2017/src/com/coding/basic/BinaryTreeNode.java @@ -0,0 +1,81 @@ +package com.coding.basic; +public class BinaryTreeNode { + + private Object data; + //根节点 + private BinaryTreeNode root; + //父节点 + private BinaryTreeNode parent; + private BinaryTreeNode left; + private BinaryTreeNode right; + //所有数据集合 + private final List datas = new ArrayList(); + 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; + } + + @SuppressWarnings({ "rawtypes", "unchecked" }) + public > BinaryTreeNode insert(T o){ + + BinaryTreeNode treeNode = new BinaryTreeNode(); + treeNode.data = o; + if(root == null){ + root = treeNode; + root.root = treeNode; + }else{ + BinaryTreeNode currentNode = root; + while(true){ + parent = currentNode; + if(((Comparable)currentNode.data).compareTo(o)>0){//向左放 + currentNode = currentNode.getLeft(); + if(currentNode == null){ + parent.left = treeNode; + treeNode.parent = parent; + treeNode.root = root; + break; + } + }else{//向右放 + currentNode = currentNode.getRight(); + if(currentNode == null){ + parent.right = treeNode; + treeNode.parent = parent; + treeNode.root = root; + break; + } + } + } + } + return treeNode; + } + + /** + * 先序遍历 + * @param node + * @return + */ + public List traversal(BinaryTreeNode node){ + + if(node !=null){ + datas.add(node.data); + traversal(node.left); + traversal(node.right); + } + return datas; + } + +} diff --git a/group12/2258659044/zj-2017/src/com/coding/basic/Iterator.java b/group12/2258659044/zj-2017/src/com/coding/basic/Iterator.java new file mode 100644 index 0000000000..c854120212 --- /dev/null +++ b/group12/2258659044/zj-2017/src/com/coding/basic/Iterator.java @@ -0,0 +1,8 @@ +package com.coding.basic; + +public interface Iterator { + + public boolean hasNext(); + public Object next(); + +} diff --git a/group12/2258659044/zj-2017/src/com/coding/basic/LinkedList.java b/group12/2258659044/zj-2017/src/com/coding/basic/LinkedList.java new file mode 100644 index 0000000000..460298ff56 --- /dev/null +++ b/group12/2258659044/zj-2017/src/com/coding/basic/LinkedList.java @@ -0,0 +1,137 @@ +package com.coding.basic; + +import java.util.NoSuchElementException; + +public class LinkedList implements List { + + private Node head; + + private int size = 0; + + public void add(Object o){ + + Node addNode = new Node(); + addNode.data = o; + if(size==0){ + head = addNode; + }else{ + //获取最后一个节点 + Node lastNode = getPointNode(size-1); + lastNode.next = addNode; + } + size++; + } + public void add(int index , Object o){ + + Node addNode = new Node(); + addNode.data = o; + if(index == 0){ + addFirst(o); + return; + } + if(index == size){ + Node lastNode = getPointNode(size-1); + lastNode.next = addNode; + }else{ + Node pointNode = getPointNode(index); + Node prePointNode = getPointNode(index-1); + prePointNode.next = addNode; + addNode.next = pointNode; + } + size ++; + } + public Object get(int index){ + + Node node = getPointNode(index); + return node.data; + } + + public Object remove(int index){ + + Node pointNode = getPointNode(index); + Node nextPointNode = getPointNode(index+1); + if(index ==0){ + head = nextPointNode; + }else{ + Node prePointNode = getPointNode(index-1); + prePointNode.next = nextPointNode; + } + size --; + return pointNode.data; + } + + public int size(){ + return size; + } + + public void addFirst(Object o){ + + Node secondNode = head; + head = new Node(); + head.data = o; + if(size>0){ + head.next = secondNode; + } + size ++; + } + + public void addLast(Object o){ + add(o); + } + + public Object removeFirst(){ + + return remove(0); + } + + public Object removeLast(){ + + return remove(size-1); + } + public Iterator iterator(){ + return new Itr(); + } + + private class Itr implements Iterator{ + + int cursor; + @Override + public boolean hasNext() { + return cursor != LinkedList.this.size; + } + + @Override + public Object next() { + + int i = this.cursor; + if (i >= LinkedList.this.size){ + throw new NoSuchElementException(); + } + this.cursor = (i + 1); + return LinkedList.this.get(i); + } + + } + + /** + * 获取指定的节点 + * @return + */ + private Node getPointNode(int index){ + + if(index>size){ + throw new IndexOutOfBoundsException("Index: "+index+",Size:"+size+""); + } + Node node = head; + for (int i = 0; i < index; i++) { + node = node.next; + } + return node; + } + + private static class Node{ + Object data; + Node next; + + } +} \ No newline at end of file diff --git a/group12/2258659044/zj-2017/src/com/coding/basic/List.java b/group12/2258659044/zj-2017/src/com/coding/basic/List.java new file mode 100644 index 0000000000..a5a3688eb6 --- /dev/null +++ b/group12/2258659044/zj-2017/src/com/coding/basic/List.java @@ -0,0 +1,10 @@ +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(); +} \ No newline at end of file diff --git a/group12/2258659044/zj-2017/src/com/coding/basic/Queue.java b/group12/2258659044/zj-2017/src/com/coding/basic/Queue.java new file mode 100644 index 0000000000..e29ff65ddf --- /dev/null +++ b/group12/2258659044/zj-2017/src/com/coding/basic/Queue.java @@ -0,0 +1,26 @@ +package com.coding.basic; + +public class Queue { + + private LinkedList element = new LinkedList(); + + public void enQueue(Object o){ + + element.add(o); + } + + public Object deQueue(){ + + return element.removeFirst(); + } + + public boolean isEmpty(){ + + return element.size()==0; + } + + public int size(){ + + return element.size(); + } +} diff --git a/group12/2258659044/zj-2017/src/com/coding/basic/Stack.java b/group12/2258659044/zj-2017/src/com/coding/basic/Stack.java new file mode 100644 index 0000000000..03709097e5 --- /dev/null +++ b/group12/2258659044/zj-2017/src/com/coding/basic/Stack.java @@ -0,0 +1,28 @@ +package com.coding.basic; + +public class Stack { + + private ArrayList elementData = new ArrayList(); + + public void push(Object o){ + + elementData.add(o); + } + + public Object pop(){ + + return elementData.remove(size()-1); + } + + public Object peek(){ + + return elementData.get(size()-1); + } + public boolean isEmpty(){ + + return size()==0; + } + public int size(){ + return elementData.size(); + } +} diff --git a/group12/2258659044/zj-2017/src/test/com/coding/basic/ArrayListTest.java b/group12/2258659044/zj-2017/src/test/com/coding/basic/ArrayListTest.java new file mode 100644 index 0000000000..e7613ee689 --- /dev/null +++ b/group12/2258659044/zj-2017/src/test/com/coding/basic/ArrayListTest.java @@ -0,0 +1,109 @@ +package test.com.coding.basic; + +import java.util.NoSuchElementException; + +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; + +import com.coding.basic.ArrayList; +import com.coding.basic.Iterator; + +public class ArrayListTest { + + ArrayList ls ; + @Before + public void setup() { + ls = new ArrayList(); + } + + /** + * 测试一个参数的add方法 + * ArrayList当数据超过10时进行第一次扩容 + */ + @Test + public void add(){ + + ls.add(3); + ls.add("a"); + for (int i = 0; i < 10; i++) { + ls.add(i); + } + Assert.assertEquals(ls.size(), 12); + Assert.assertEquals(ls.get(1), "a"); + } + + /** + * 两个参数的add方法 + */ + @Test(expected = IndexOutOfBoundsException.class) + public void add4ToPramter(){ + + ls.add(0, 0); + ls.add(1,1); + ls.add(2, 2); + ls.add(3,3); + for (int i = 0; i < 10; i++) { + ls.add(3,i); + } + Assert.assertEquals(ls.size(), 14); + Assert.assertEquals(ls.get(3), 9); + Assert.assertEquals(ls.get(13), 3); + ls.add(15, "a"); + } + + /** + * get(i) + */ + @Test(expected = IndexOutOfBoundsException.class) + public void get(){ + + for (int i = 0; i < 10; i++) { + ls.add(i); + } + ls.add(11,11); + Assert.assertEquals(ls.get(9), 9); + Assert.assertEquals(ls.get(10),null); + ls.get(12); + } + + @Test + public void remove(){ + + for (int i = 0; i < 10; i++) { + ls.add(i); + } + Assert.assertEquals(ls.remove(5),5); + Assert.assertEquals(ls.size(),9); + Assert.assertEquals(ls.remove(8),9); + Assert.assertEquals(ls.size(),8); + } + + @Test + public void size(){ + + Assert.assertEquals(ls.size(),0); + ls.add("a"); + Assert.assertEquals(ls.size(),1); + ls.add(0,0); + Assert.assertEquals(ls.size(),2); + ls.remove(0); + Assert.assertEquals(ls.size(),1); + + } + + @Test(expected = NoSuchElementException.class) + public void iterator(){ + + for (int i = 0; i < 10; i++) { + ls.add(i); + } + Iterator it = ls.iterator(); + Assert.assertEquals(it.hasNext(),true); + for (int i = 0; i < 10; i++) { + it.next(); + } + Assert.assertEquals(it.hasNext(),false); + it.next(); + } +} diff --git a/group12/2258659044/zj-2017/src/test/com/coding/basic/LinkedListTest.java b/group12/2258659044/zj-2017/src/test/com/coding/basic/LinkedListTest.java new file mode 100644 index 0000000000..e7b56eccff --- /dev/null +++ b/group12/2258659044/zj-2017/src/test/com/coding/basic/LinkedListTest.java @@ -0,0 +1,109 @@ +package test.com.coding.basic; + +import java.util.NoSuchElementException; + +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; + +import com.coding.basic.Iterator; +import com.coding.basic.LinkedList; + +public class LinkedListTest { + + LinkedList ls ; + @Before + public void setup() { + ls = new LinkedList(); + } + + /** + * 测试一个参数的add方法 + * ArrayList当数据超过10时进行第一次扩容 + */ + @Test + public void add(){ + + ls.add(3); + ls.add("a"); + for (int i = 0; i < 10; i++) { + ls.add(i); + } + Assert.assertEquals(ls.size(), 12); + Assert.assertEquals(ls.get(1), "a"); + } + + /** + * 两个参数的add方法 + */ + @Test(expected = IndexOutOfBoundsException.class) + public void add4ToPramter(){ + + ls.add(0, 0); + ls.add(1,1); + ls.add(2, 2); + ls.add(3,3); + for (int i = 0; i < 10; i++) { + ls.add(3,i); + } + Assert.assertEquals(ls.size(), 14); + Assert.assertEquals(ls.get(3), 9); + Assert.assertEquals(ls.get(13), 3); + ls.add(15, "a"); + } + + /** + * get(i) + */ + @Test(expected = IndexOutOfBoundsException.class) + public void get(){ + + for (int i = 0; i < 10; i++) { + ls.add(i); + } + ls.add(11,11); + Assert.assertEquals(ls.get(9), 9); + Assert.assertEquals(ls.get(10),null); + ls.get(12); + } + + @Test + public void remove(){ + + for (int i = 0; i < 10; i++) { + ls.add(i); + } + Assert.assertEquals(ls.remove(5),5); + Assert.assertEquals(ls.size(),9); + Assert.assertEquals(ls.remove(8),9); + Assert.assertEquals(ls.size(),8); + } + + @Test + public void size(){ + + Assert.assertEquals(ls.size(),0); + ls.add("a"); + Assert.assertEquals(ls.size(),1); + ls.add(0,0); + Assert.assertEquals(ls.size(),2); + ls.remove(0); + Assert.assertEquals(ls.size(),1); + + } + + @Test(expected = NoSuchElementException.class) + public void iterator(){ + + for (int i = 0; i < 10; i++) { + ls.add(i); + } + Iterator it = ls.iterator(); + Assert.assertEquals(it.hasNext(),true); + for (int i = 0; i < 10; i++) { + it.next(); + } + Assert.assertEquals(it.hasNext(),false); + it.next(); + } +} From c4891ca32ede14c01c5f685a9b522ea2966da43b Mon Sep 17 00:00:00 2001 From: Korben_CHY Date: Thu, 23 Feb 2017 13:41:11 +0800 Subject: [PATCH 006/518] add .gitignore --- group20/.gitignore | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 group20/.gitignore diff --git a/group20/.gitignore b/group20/.gitignore new file mode 100644 index 0000000000..0979db8ba4 --- /dev/null +++ b/group20/.gitignore @@ -0,0 +1,41 @@ +# Java class files +*.class + +# Generated files +bin/ +gen/ +out/ +target/ + +# Gradle files +.gradle/ +build/ + +# Local configuration file (sdk path, etc) +local.properties + +# Proguard folder generated by Eclipse +proguard/ + +# Log Files +*.log + +# Intellij +*.iml +.idea/workspace.xml +.idea/tasks.xml +.idea/gradle.xml +.idea/dictionaries +.idea/libraries +.idea + +# Project generated files +.project +.settings +.classpath +.com +.metadata + +# Mac file +.DS_Store + From 7bc4437517ef425f69554b1ce058a04fb31533ce Mon Sep 17 00:00:00 2001 From: Haochen Date: Thu, 23 Feb 2017 13:46:51 +0800 Subject: [PATCH 007/518] init --- .../src/datastructure/basic/ArrayList.java | 85 ++++ .../datastructure/basic/BinaryTreeNode.java | 32 ++ .../src/datastructure/basic/Iterator.java | 7 + .../src/datastructure/basic/LinkedList.java | 102 +++++ .../code/src/datastructure/basic/List.java | 9 + .../code/src/datastructure/basic/Queue.java | 72 ++++ .../code/src/datastructure/basic/Stack.java | 43 ++ .../datastructure/jdklist/MyArrayList.java | 304 ++++++++++++++ .../datastructure/jdklist/MyLinkedList.java | 382 ++++++++++++++++++ .../datastructure/nongeneric/MyBaseList.java | 137 +++++++ .../nongeneric/MyBinaryTree.java | 61 +++ .../src/datastructure/nongeneric/MyQueue.java | 43 ++ .../src/datastructure/nongeneric/MyStack.java | 47 +++ 13 files changed, 1324 insertions(+) create mode 100644 group01/895457260/code/src/datastructure/basic/ArrayList.java create mode 100644 group01/895457260/code/src/datastructure/basic/BinaryTreeNode.java create mode 100644 group01/895457260/code/src/datastructure/basic/Iterator.java create mode 100644 group01/895457260/code/src/datastructure/basic/LinkedList.java create mode 100644 group01/895457260/code/src/datastructure/basic/List.java create mode 100644 group01/895457260/code/src/datastructure/basic/Queue.java create mode 100644 group01/895457260/code/src/datastructure/basic/Stack.java create mode 100644 group01/895457260/code/src/datastructure/jdklist/MyArrayList.java create mode 100644 group01/895457260/code/src/datastructure/jdklist/MyLinkedList.java create mode 100644 group01/895457260/code/src/datastructure/nongeneric/MyBaseList.java create mode 100644 group01/895457260/code/src/datastructure/nongeneric/MyBinaryTree.java create mode 100644 group01/895457260/code/src/datastructure/nongeneric/MyQueue.java create mode 100644 group01/895457260/code/src/datastructure/nongeneric/MyStack.java diff --git a/group01/895457260/code/src/datastructure/basic/ArrayList.java b/group01/895457260/code/src/datastructure/basic/ArrayList.java new file mode 100644 index 0000000000..ed7df1a702 --- /dev/null +++ b/group01/895457260/code/src/datastructure/basic/ArrayList.java @@ -0,0 +1,85 @@ +package datastructure.basic; + +public class ArrayList implements List { + + private int size = 0; + + Object[] elementData; + + public ArrayList() { + elementData = new Object[100]; + } + + public ArrayList(int initCapacity) { + elementData = new Object[initCapacity]; + } + + public void add(Object o){ + autoGrow(); + elementData[size()] = o; + size++; + } + + public void add(int index, Object o){ + autoGrow(); + 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 removed = elementData[index]; + System.arraycopy(elementData, index + 1, elementData, index, size() - index); + size--; + return removed; + } + + public int size(){ + return size; + } + + public Iterator iterator(){ + return new Iterator() { + int index = -1; + @Override + public boolean hasNext() { + return index + 1 < size(); + } + + @Override + public Object next() { + index++; + return elementData[index]; + } + }; + } + + private void autoGrow() { + if (size >= elementData.length) { + Object[] newArray = new Object[nextCapacity()]; + System.arraycopy(elementData, 0, newArray, 0, elementData.length); + elementData = newArray; + } + } + + private int nextCapacity() { + return elementData.length * 2; + } + + private void checkIndex(int index) { + if (index >= size() || index < 0) { + throw new IndexOutOfBoundsException(indexOutOfBoundMessage(index)); + } + } + + private String indexOutOfBoundMessage(int index) { + return "index: " + index + ", size: " + size(); + } + +} diff --git a/group01/895457260/code/src/datastructure/basic/BinaryTreeNode.java b/group01/895457260/code/src/datastructure/basic/BinaryTreeNode.java new file mode 100644 index 0000000000..d3a9ff377b --- /dev/null +++ b/group01/895457260/code/src/datastructure/basic/BinaryTreeNode.java @@ -0,0 +1,32 @@ +package datastructure.basic; + +public class BinaryTreeNode { + + private Object data; + private BinaryTreeNode left; + private BinaryTreeNode right; + + public Object getData() { + return data; + } + public void setData(Object data) { + this.data = data; + } + public BinaryTreeNode getLeft() { + return left; + } + public void setLeft(BinaryTreeNode left) { + this.left = left; + } + public BinaryTreeNode getRight() { + return right; + } + public void setRight(BinaryTreeNode right) { + this.right = right; + } + + public BinaryTreeNode insert(Object o){ + return null; + } + +} diff --git a/group01/895457260/code/src/datastructure/basic/Iterator.java b/group01/895457260/code/src/datastructure/basic/Iterator.java new file mode 100644 index 0000000000..4787b60086 --- /dev/null +++ b/group01/895457260/code/src/datastructure/basic/Iterator.java @@ -0,0 +1,7 @@ +package datastructure.basic; + +public interface Iterator { + public boolean hasNext(); + public Object next(); + +} diff --git a/group01/895457260/code/src/datastructure/basic/LinkedList.java b/group01/895457260/code/src/datastructure/basic/LinkedList.java new file mode 100644 index 0000000000..189280da30 --- /dev/null +++ b/group01/895457260/code/src/datastructure/basic/LinkedList.java @@ -0,0 +1,102 @@ +package datastructure.basic; + +public class LinkedList implements List { + + private Node head; + private int size; + + public LinkedList() { + head = new Node(); + } + + public void add(Object o){ + addLast(o); + } + + public void add(int index , Object o){ + Node pre = findNode(index - 1); + Node node = new Node(); + node.data = o; + addNode(node, pre); + } + + public Object get(int index){ + checkIndex(index); + return findNode(index); + } + public Object remove(int index){ + checkIndex(index); + Node pre = findNode(index - 1); + Node removed = pre.next; + removeNode(removed, pre); + return removed.data; + } + + public int size(){ + return size; + } + + public void addFirst(Object o){ + Node node = new Node(); + node.data = o; + addNode(node, head); + } + public void addLast(Object o){ + Node node = new Node(); + node.data = o; + Node pre = findNode(size()); + addNode(node, pre); + } + public Object removeFirst(){ + Node removed = head.next; + removeNode(head.next, head); + return removed.data; + } + public Object removeLast(){ + return remove(size() - 1); + } + public Iterator iterator(){ + return null; + } + + + private static class Node{ + Object data; + Node next; + } + + private Node findNode(int index) { + if (index == -1) { + return head; + } else { + checkIndex(index); + } + Node node = head.next; + for (int i = 0; i < index; ++i) { + node = node.next; + } + return node; + } + + private void checkIndex(int index) { + if (index >= size() || index < 0) { + throw new IndexOutOfBoundsException(indexOutOfBoundMessage(index)); + } + } + + private String indexOutOfBoundMessage(int index) { + return "index: " + index + ", size: " + size(); + } + + private void addNode(Node node, Node pre) { + node.next = pre.next; + pre.next = node; + size++; + } + + private void removeNode(Node node, Node pre) { + pre.next = node.next; + node.next = null; + size--; + } +} diff --git a/group01/895457260/code/src/datastructure/basic/List.java b/group01/895457260/code/src/datastructure/basic/List.java new file mode 100644 index 0000000000..39394c145e --- /dev/null +++ b/group01/895457260/code/src/datastructure/basic/List.java @@ -0,0 +1,9 @@ +package datastructure.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/group01/895457260/code/src/datastructure/basic/Queue.java b/group01/895457260/code/src/datastructure/basic/Queue.java new file mode 100644 index 0000000000..ee96a1a83e --- /dev/null +++ b/group01/895457260/code/src/datastructure/basic/Queue.java @@ -0,0 +1,72 @@ +package datastructure.basic; + +public class Queue { + //数组实现自增长的循环队列 + private Object[] array = new Object[10]; + private int head = 0; + private int rear = 0; + + public void enQueue(Object o){ + int target = mapIndex(rear); + autoGrow(); + array[target] = o; + rear++; + } + + public Object deQueue() { + Object obj = array[mapIndex(head)]; + head++; + return obj; + } + + public boolean isEmpty(){ + return head == rear; + } + + public int size(){ + return rear - head; + } + + private int capacity() { + return array.length; + } + + private void autoGrow() { + if (size() >= capacity()) { + Object[] newArray = new Object[nextCapacity()]; + System.arraycopy(array, 0, newArray, 0, capacity()); + + int increase = nextCapacity() - capacity(); + int moveCount = size() - mapIndex(rear); + System.arraycopy(newArray, mapIndex(head), newArray, mapIndex(head) + increase, moveCount); + array = newArray; + head += increase; + rear += increase; + } + } + + private int nextCapacity() { + return capacity() * 2; + } + + private int mapIndex(int index) { + return index >= capacity() ? index % capacity() : index; + } + + public static void main(String[] args) { + Queue queue = new Queue(); + for (int i = 0; i < 22; ++i) { + queue.enQueue(i); + } + for (int i = 0; i < 6; ++i) { + System.out.print(queue.deQueue() + " "); + } + for (int i = 22; i < 41; ++i) { + queue.enQueue(i); + } + while (!queue.isEmpty()) { + System.out.print(queue.deQueue() + " "); + } + System.out.println(); + } +} diff --git a/group01/895457260/code/src/datastructure/basic/Stack.java b/group01/895457260/code/src/datastructure/basic/Stack.java new file mode 100644 index 0000000000..772ab16385 --- /dev/null +++ b/group01/895457260/code/src/datastructure/basic/Stack.java @@ -0,0 +1,43 @@ +package datastructure.basic; + +public class Stack { + private ArrayList elementData = new ArrayList(); + + public void push(Object o){ + elementData.add(o); + } + + public Object pop(){ + Object peek = peek(); + elementData.remove(elementData.size() - 1); + return peek; + } + + public Object peek(){ + return elementData.get(elementData.size() - 1); + } + + public boolean isEmpty(){ + return size() == 0; + } + + public int size(){ + return elementData.size(); + } + + public static void main(String[] args) { + Stack stack = new Stack(); + for (int i = 0; i < 6; ++i) { + stack.push(i); + } + for (int i = 0; i < 4; ++i) { + System.out.print(stack.pop() + " "); + } + for (int i = 6; i < 21; ++i) { + stack.push(i); + } + while (!stack.isEmpty()) { + System.out.print(stack.pop() + " "); + } + } +} diff --git a/group01/895457260/code/src/datastructure/jdklist/MyArrayList.java b/group01/895457260/code/src/datastructure/jdklist/MyArrayList.java new file mode 100644 index 0000000000..3eb826c4cc --- /dev/null +++ b/group01/895457260/code/src/datastructure/jdklist/MyArrayList.java @@ -0,0 +1,304 @@ +package datastructure.jdklist; + +import datastructure.nongeneric.MyBaseList; + +import java.util.*; + +/** + * Created by Haochen on 2017/2/15. + * TODO: + */ +public class MyArrayList extends MyBaseList { + + private Object[] array; + private int size; + private int initSize; + + public MyArrayList() { + initSize = 10; + this.array = new Object[initSize]; + } + + public MyArrayList(int initSize) { + this.initSize = initSize; + this.array = new Object[initSize]; + } + + protected int nextSize(int size) { + return size * 2; + } + + @Override + public int size() { + return size; + } + + @Override + public Iterator iterator() { + return new Iterator() { + private int index = -1; + @Override + public boolean hasNext() { + return index < size() - 1; + } + + @Override + public T next() { + index++; + return (T) array[index]; + } + + @Override + public void remove() { + MyArrayList.this.remove(index); + index--; + } + }; + } + + @Override + public T1[] toArray(T1[] a) { + if (a.length < size()) { + return (T1[]) Arrays.copyOf(array, size(), a.getClass()); + } else { + System.arraycopy(array, 0, a, 0, size()); + return a; + } + } + + private boolean isFull() { + return size() >= array.length; + } + + private void expand(int newCapacity) { + Object[] newArray = new Object[newCapacity]; + System.arraycopy(array, 0, newArray, 0, size()); + this.array = newArray; + } + + @Override + public boolean remove(Object o) { + int index = indexOf(o); + if (index >= 0) { + remove(index); + } + return false; + } + + @Override + public boolean addAll(int index, Collection c) { + int addCount = c.size(); + int capacityAfterAdd = array.length; + int countAfterAdd = size + addCount; + while (capacityAfterAdd < countAfterAdd) { + capacityAfterAdd = nextSize(capacityAfterAdd); + } + if (capacityAfterAdd > array.length) { + expand(capacityAfterAdd); + } + System.arraycopy(array, index, array, index + addCount, size - index); + for (Object o : c) { + array[size] = o; + size++; + } + return true; + } + + @Override + protected T getNoCheck(int index) { + return (T) array[index]; + } + + @Override + protected T setNoCheck(int index, T element) { + T t = (T) array[index]; + array[index] = element; + return t; + } + + @Override + protected void addNoCheck(int index, T element) { + if (isFull()) { + expand(nextSize(array.length)); + } + System.arraycopy(array, index, array, index + 1, size() - index); + array[index] = element; + size++; + } + + @Override + public void clear() { + array = new Object[10]; + size = 0; + } + + @Override + protected T removeNoCheck(int index) { + T t = (T) array[index]; + if (index < size() - 1) { + System.arraycopy(array, index + 1, array, index, size() - index); + } + size--; + return t; + } + + @Override + public int indexOf(Object o) { + for (int i = 0; i < size(); ++i) { + if (array[i] == null ? o == null : array[i].equals(o)) { + return i; + } + } + return -1; + } + + @Override + public int lastIndexOf(Object o) { + for (int i = size - 1; i >= 0; --i) { + if (array[i] == null ? o == null : array[i].equals(o)) { + return i; + } + } + return -1; + } + + @Override + public ListIterator listIterator(int index) { + final int beginIndex = index; + return new ListIterator() { + private int point = beginIndex - 1; + @Override + public boolean hasNext() { + return point < size - 1; + } + + @Override + public T next() { + point++; + return (T) array[point]; + } + + @Override + public boolean hasPrevious() { + return point > beginIndex; + } + + @Override + public T previous() { + point--; + return (T) array[point]; + } + + @Override + public int nextIndex() { + return point + 1; + } + + @Override + public int previousIndex() { + return point - 1; + } + + @Override + public void remove() { + MyArrayList.this.remove(point); + point--; + } + + @Override + public void set(T t) { + MyArrayList.this.set(point, t); + } + + @Override + public void add(T t) { + MyArrayList.this.add(point + 1, t); + } + }; + } + + @Override + public List subList(int fromIndex, int toIndex) { + //这是错误实现 + MyArrayList result = new MyArrayList<>(toIndex - fromIndex + 1); + for (int i = fromIndex; i <= toIndex; ++i) { + result.array[result.size()] = array[i]; + result.size++; + } + return result; + } + + public static void main(String[] args) { + MyBaseList list = new MyArrayList<>(); + for (int i = 0; i < 10; ++i) { + list.add(i); + list.add(10 - i); + } + System.out.println("------------------size"); + System.out.println("size: " + list.size()); + + System.out.println("------------------for(int i)"); + for (int i = 0; i < list.size(); ++i) { + System.out.print(list.get(i) + " "); + } + + System.out.println("\n-----------------foreach"); + for (int i : list) { + System.out.print(i + " "); + } + + System.out.println("\n-----------------iterator"); + Iterator iterator = list.iterator(); + while (iterator.hasNext()) { + System.out.print(iterator.next() + " "); + } + + System.out.println("\n-----------------listIterator"); + iterator = list.listIterator(); + while (iterator.hasNext()) { + System.out.print(iterator.next() + " "); + } + + System.out.println("\n-----------------indexOf 0~10"); + for (int i = 0; i <= 10; ++i) { + System.out.print("[" + i + "]" + list.indexOf(i) + " "); + } + + System.out.println("\n-----------------lastIndexOf 0~10"); + for (int i = 0; i <= 10; ++i) { + System.out.print("[" + i + "]" + list.lastIndexOf(i) + " "); + } + + System.out.println("\n-----------------add at index 0 100~104"); + for (int i = 100; i < 105; ++i) { + list.add(0, i); + } + list.print(); + System.out.println("-----------------add at last 200~204"); + for (int i = 200; i < 205; ++i) { + list.add(list.size(), i); + } + list.print(); + + System.out.println("-----------------removeFirst x4"); + for (int i = 0; i < 4; ++i) { + list.remove(0); + } + list.print(); + + System.out.println("\n-----------------removeLast x4"); + for (int i = 0; i < 4; ++i) { + list.remove(list.size() - 1); + } + list.print(); + + System.out.println("-----------------iterator remove"); + iterator = list.iterator(); + while (iterator.hasNext()) { + System.out.print(iterator.next() + "[" + list.size() + "] "); + iterator.remove(); + } + System.out.println(); + list.print(); + } +} diff --git a/group01/895457260/code/src/datastructure/jdklist/MyLinkedList.java b/group01/895457260/code/src/datastructure/jdklist/MyLinkedList.java new file mode 100644 index 0000000000..44b2368f11 --- /dev/null +++ b/group01/895457260/code/src/datastructure/jdklist/MyLinkedList.java @@ -0,0 +1,382 @@ +package datastructure.jdklist; + +import datastructure.nongeneric.MyBaseList; + +import java.util.Collection; +import java.util.Iterator; +import java.util.List; +import java.util.ListIterator; + +/** + * Created by Haochen on 2017/2/15. + * TODO: + */ +public class MyLinkedList extends MyBaseList { + + private Node head; + private Node rear; + private int size; + + public MyLinkedList() { + head = new Node<>(); + rear = new Node<>(); + clear(); + } + + private static class Node { + T data; + Node next; + Node previous; + } + + @Override + public int size() { + return size; + } + + private void addNode(Node node, Node previous) { + node.next = previous.next; + node.previous = previous; + node.next.previous = node; + previous.next = node; + } + + private void removeNode(Node node) { + node.previous.next = node.next; + node.next.previous = node.previous; + node.previous = null; + node.next = null; + node.data = null; + } + + public void addFirst(T element) { + add(0, element); + } + + public void addLast(T element) { + add(size(), element); + } + + public T removeFirst() { + return remove(0); + } + + public T removeLast() { + return remove(size() - 1); + } + + @Override + public Iterator iterator() { + return new Iterator() { + private Node node = head; + @Override + public boolean hasNext() { + return node.next != rear; + } + + @Override + public T next() { + node = node.next; + return node.data; + } + + @Override + public void remove() { + if (node != head && node != rear) { + node = node.previous; + removeNode(node.next); + size--; + } + } + }; + } + + @Override + public T1[] toArray(T1[] a) { + Object[] result = a.length < size ? new Object[size] : a; + for (Node node = head.next; node != rear; node = node.next) { + result[result.length] = node.data; + } + return (T1[]) result; + } + + private Node findNode(Object o) { + for (Node node = head.next; node != rear; node = node.next) { + if (node.data == null ? o == null : node.data.equals(o)) { + return node; + } + } + return null; + } + + private Node findNode(int index) { + if (index == -1) { + return head; + } else if (index == size) { + return rear; + } else if (index < -1 || index > size) { + indexOuOfBound(index); + } + Node node; + if (index > size() / 2) { + node = rear.previous; + for (int i = 0; i < size() - index - 1; ++i) { + node = node.previous; + } + } else { + node = head.next; + for (int i = 0; i < index; ++i) { + node = node.next; + } + } + return node; + } + + @Override + public boolean remove(Object o) { + Node node = findNode(o); + removeNode(node); + size--; + return false; + } + + @Override + public boolean addAll(int index, Collection c) { + Node target = findNode(index); + Node newLinkHead = new Node(); + Node newLinkRear = newLinkHead; + for (T t : c) { + newLinkRear.next = new Node(); + newLinkRear.next.data = t; + newLinkRear.next.previous = newLinkRear; + newLinkRear = newLinkRear.next; + } + if (newLinkRear != newLinkHead) { + newLinkRear.next = target.next; + target.next.previous = newLinkRear; + newLinkHead = newLinkHead.next; + newLinkHead.previous = target; + target.next = newLinkHead; + size += c.size(); + } + return true; + } + + @Override + protected T getNoCheck(int index) { + return findNode(index).data; + } + + @Override + protected T setNoCheck(int index, T element) { + Node node = findNode(index); + T t = node.data; + node.data = element; + return t; + } + + @Override + protected void addNoCheck(int index, T element) { + Node pre = findNode(index - 1); + Node node = new Node(); + node.data = element; + addNode(node, pre); + size++; + } + + @Override + public void clear() { + head.next = rear; + head.previous = rear; + rear.next = head; + rear.previous = head; + size = 0; + } + + @Override + protected T removeNoCheck(int index) { + Node node = findNode(index); + T t = node.data; + removeNode(node); + size--; + return t; + } + + @Override + public int indexOf(Object o) { + int index = 0; + Node node; + for (node = head.next; node != rear; node = node.next, index++) { + if (node.data == null ? o == null : node.data.equals(o)) { + break; + } + } + return node == rear ? -1 : index; + } + + @Override + public int lastIndexOf(Object o) { + int index = size - 1; + Node node; + for (node = rear.previous; node != head; node = node.previous, index--) { + if (node.data == null ? o == null : node.data.equals(o)) { + break; + } + } + return node == head ? -1 : index; + } + + @Override + public ListIterator listIterator(int index) { + final int beginIndex = index - 1; + return new ListIterator() { + private Node node = findNode(beginIndex); + private int index = beginIndex; + + @Override + public boolean hasNext() { + return node.next != rear; + } + + @Override + public T next() { + node = node.next; + index++; + return node.data; + } + + @Override + public boolean hasPrevious() { + return node.previous != head; + } + + @Override + public T previous() { + node = node.previous; + index--; + return node.data; + } + + @Override + public int nextIndex() { + return hasNext() ? index + 1 : index; + } + + @Override + public int previousIndex() { + return hasPrevious() ? index - 1 : -1; + } + + @Override + public void remove() { + if (node != head && node != rear) { + node = node.previous; + removeNode(node.next); + size--; + } + } + + @Override + public void set(T t) { + node.data = t; + } + + @Override + public void add(T t) { + Node node = new Node(); + node.data = t; + addNode(node, this.node); + size++; + } + }; + } + + @Override + public List subList(int fromIndex, int toIndex) { + //这是错误实现 + Node from = findNode(fromIndex); + Node to = findNode(toIndex); + List list = new MyLinkedList<>(); + if (from != null && to != null) { + for (Node node = from; node != to.next; node = node.next) { + list.add(node.data); + } + } + return list; + } + + public static void main(String[] args) { + MyLinkedList list = new MyLinkedList<>(); + for (int i = 0; i < 10; ++i) { + list.add(i); + list.add(10 - i); + } + System.out.println("------------------size"); + System.out.println("size: " + list.size()); + + System.out.println("------------------for(int i)"); + for (int i = 0; i < list.size(); ++i) { + System.out.print(list.get(i) + " "); + } + + System.out.println("\n-----------------foreach"); + for (int i : list) { + System.out.print(i + " "); + } + + System.out.println("\n-----------------iterator"); + Iterator iterator = list.iterator(); + while (iterator.hasNext()) { + System.out.print(iterator.next() + " "); + } + + System.out.println("\n-----------------listIterator"); + iterator = list.listIterator(); + while (iterator.hasNext()) { + System.out.print(iterator.next() + " "); + } + + System.out.println("\n-----------------indexOf 0~10"); + for (int i = 0; i <= 10; ++i) { + System.out.print("[" + i + "]" + list.indexOf(i) + " "); + } + + System.out.println("\n-----------------lastIndexOf 0~10"); + for (int i = 0; i <= 10; ++i) { + System.out.print("[" + i + "]" + list.lastIndexOf(i) + " "); + } + + System.out.println("\n-----------------addFirst 100~104"); + for (int i = 100; i < 105; ++i) { + list.addFirst(i); + } + list.print(); + System.out.println("-----------------addLast 200~204"); + for (int i = 200; i < 205; ++i) { + list.addLast(i); + } + list.print(); + + System.out.println("-----------------removeFirst x4"); + for (int i = 0; i < 4; ++i) { + list.removeFirst(); + } + list.print(); + + System.out.println("-----------------removeLast x4"); + for (int i = 0; i < 4; ++i) { + list.removeLast(); + } + list.print(); + + System.out.println("-----------------iterator remove"); + iterator = list.iterator(); + while (iterator.hasNext()) { + System.out.print(iterator.next() + "[" + list.size() + "] "); + iterator.remove(); + } + System.out.println(); + list.print(); + } + +} diff --git a/group01/895457260/code/src/datastructure/nongeneric/MyBaseList.java b/group01/895457260/code/src/datastructure/nongeneric/MyBaseList.java new file mode 100644 index 0000000000..ca04443db2 --- /dev/null +++ b/group01/895457260/code/src/datastructure/nongeneric/MyBaseList.java @@ -0,0 +1,137 @@ +package datastructure.nongeneric; + +import java.util.Collection; +import java.util.List; +import java.util.ListIterator; + +/** + * Created by Haochen on 2017/2/20. + * TODO: + */ +public abstract class MyBaseList implements List { + + protected final boolean checkGetIndex(int index) { + return index >= 0 && index < size(); + } + + protected final void checkGetIndexAndThrow(int index) { + if (!checkGetIndex(index)) { + indexOuOfBound(index); + } + } + + protected final boolean checkAddIndex(int index) { + return index >= 0 && index <= size(); + } + + protected final void checkAddIndexAndThrow(int index) { + if (!checkAddIndex(index)) { + indexOuOfBound(index); + } + } + + protected final void indexOuOfBound(int index) { + throw new IndexOutOfBoundsException(indexOutOfBoundMessage(index)); + } + + @Override + public T remove(int index) { + checkGetIndexAndThrow(index); + return removeNoCheck(index); + } + + protected abstract T removeNoCheck(int index); + + protected final String indexOutOfBoundMessage(int index) { + return "Index: " + index + ", size: " + size(); + } + + @Override + public boolean isEmpty() { + return size() == 0; + } + + @Override + public Object[] toArray() { + return toArray(new Object[size()]); + } + + @Override + public boolean add(T t) { + int before = size(); + add(size(), t); + return size() != before; + } + + @Override + public boolean containsAll(Collection c) { + for (Object o : c) { + if (!contains(o)) { + return false; + } + } + return true; + } + + @Override + public boolean addAll(Collection c) { + return addAll(size(), c); + } + + @Override + public boolean removeAll(Collection c) { + int before = size(); + c.parallelStream().forEach(this::remove); + return size() != before; + } + + @Override + public boolean retainAll(Collection c) { + int before = size(); + parallelStream().forEach((o) -> { + if (!c.contains(o)) { + remove(o); + } + }); + return size() != before; + } + + protected abstract T getNoCheck(int index); + protected abstract T setNoCheck(int index, T element); + protected abstract void addNoCheck(int index, T element); + + @Override + public T get(int index) { + checkGetIndexAndThrow(index); + return getNoCheck(index); + } + + @Override + public T set(int index, T element) { + checkGetIndexAndThrow(index); + return setNoCheck(index, element); + } + + @Override + public void add(int index, T element) { + checkAddIndexAndThrow(index); + addNoCheck(index, element); + } + + @Override + public boolean contains(Object o) { + return indexOf(o) >= 0; + } + + @Override + public ListIterator listIterator() { + return listIterator(0); + } + + public void print() { + for (T t : this) { + System.out.print(t + " "); + } + System.out.println("\nsize: " + size()); + } +} diff --git a/group01/895457260/code/src/datastructure/nongeneric/MyBinaryTree.java b/group01/895457260/code/src/datastructure/nongeneric/MyBinaryTree.java new file mode 100644 index 0000000000..893c1d88ca --- /dev/null +++ b/group01/895457260/code/src/datastructure/nongeneric/MyBinaryTree.java @@ -0,0 +1,61 @@ +package datastructure.nongeneric; + +/** + * Created by Haochen on 2017/2/15. + * TODO: + */ +public class MyBinaryTree { + private static class Node { + Object data; + Node left; + Node right; + } + + private Node root = null; + + //不递归的写法 + public void add(T o) { + //根节点空,直接加入 + if (root == null) { + root = new Node(); + root.data = o; + } else { + Node target = root; + //从根结点不断向下比较target和o,o小则往左,o大则往右,相等不加入 + while (true) { + int compare = o.compareTo(target.data); + if (compare == 0) {//相等不加入 + return; + } else if (compare < 0) {//o小往左 + if (target.left == null) {//左空则加入 + target.left = new Node(); + target.left.data = o; + return; + } else {//不空继续比较 + target = target.left; + } + } else {//o大往右 + if (target.right == null) { + target.right = new Node(); + target.right.data = o; + return; + } else { + target = target.right; + } + } + } + } + } + + public static void main(String[] args) { + MyBinaryTree tree = new MyBinaryTree<>(); + tree.add(5); + tree.add(2); + tree.add(1); + tree.add(7); + tree.add(6); + tree.add(4); + tree.add(8); + tree.add(8); + } +} diff --git a/group01/895457260/code/src/datastructure/nongeneric/MyQueue.java b/group01/895457260/code/src/datastructure/nongeneric/MyQueue.java new file mode 100644 index 0000000000..c7d6e2c13b --- /dev/null +++ b/group01/895457260/code/src/datastructure/nongeneric/MyQueue.java @@ -0,0 +1,43 @@ +package datastructure.nongeneric; + +import datastructure.jdklist.MyLinkedList; + +import java.util.List; + +/** + * Created by Haochen on 2017/2/15. + * TODO: + */ +public class MyQueue { + //先进先出,进在队尾,出在队头 + private List list = new MyLinkedList<>(); + + public void enQueue(Object o) { + list.add(o); + } + + public Object deQueue() { + Object o = list.get(0); + list.remove(0); + return o; + } + + public int size() { + return list.size(); + } + + public boolean isEmpty() { + return list.isEmpty(); + } + + public static void main(String[] args) { + MyQueue queue = new MyQueue(); + for (int i = 0; i < 20; ++i) { + queue.enQueue(i); + } + System.out.println("size: " + queue.size()); + while (!queue.isEmpty()) { + System.out.print(queue.deQueue() + "[" + queue.size() + "] "); + } + } +} diff --git a/group01/895457260/code/src/datastructure/nongeneric/MyStack.java b/group01/895457260/code/src/datastructure/nongeneric/MyStack.java new file mode 100644 index 0000000000..16e65c304a --- /dev/null +++ b/group01/895457260/code/src/datastructure/nongeneric/MyStack.java @@ -0,0 +1,47 @@ +package datastructure.nongeneric; + +import datastructure.jdklist.MyLinkedList; + +import java.util.List; + +/** + * Created by Haochen on 2017/2/15. + * TODO: + */ +public class MyStack { + //后进先出,进出都在队头 + private List list = new MyLinkedList<>(); + + public void push(Object o) { + list.add(0, o); + } + + public Object pop() { + Object o = list.get(0); + list.remove(0); + return o; + } + + public Object peek() { + return list.get(0); + } + + public int size() { + return list.size(); + } + + public boolean isEmpty() { + return list.isEmpty(); + } + + public static void main(String[] args) { + MyStack stack = new MyStack(); + for (int i = 0; i < 20; ++i) { + stack.push(i); + } + System.out.println("size: " + stack.size()); + while (!stack.isEmpty()) { + System.out.print(stack.pop() + "[" + stack.size() + "] "); + } + } +} From 237903198968004d3dcce3aab677d6edc9855c62 Mon Sep 17 00:00:00 2001 From: TonyHui Date: Thu, 23 Feb 2017 13:50:04 +0800 Subject: [PATCH 008/518] =?UTF-8?q?1.=20=E5=AE=8C=E6=88=90=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E7=BB=93=E6=9E=84=E4=B9=A0=E9=A2=98=202.=20=E5=AE=8C?= =?UTF-8?q?=E6=88=90=E6=B5=8B=E8=AF=95=E7=94=A8=E4=BE=8B=203.=20=E4=BA=8C?= =?UTF-8?q?=E5=8F=89=E6=A0=91=E6=B7=BB=E5=8A=A0delete()=EF=BC=8C=20search(?= =?UTF-8?q?)=EF=BC=8C=20min()=EF=BC=8C=20max()=20=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- group01/954958168/954958168.md | 0 .../class01/BasicDataStructure/.gitignore | 28 ++ .../class01/BasicDataStructure/pom.xml | 24 ++ .../com/aaront/exercise/basic/ArrayList.java | 90 +++++++ .../com/aaront/exercise/basic/BinaryTree.java | 235 ++++++++++++++++ .../com/aaront/exercise/basic/Iterator.java | 9 + .../com/aaront/exercise/basic/LinkedList.java | 129 +++++++++ .../java/com/aaront/exercise/basic/List.java | 9 + .../java/com/aaront/exercise/basic/Queue.java | 26 ++ .../java/com/aaront/exercise/basic/Stack.java | 29 ++ .../exercise/generic/GenericArrayList.java | 98 +++++++ .../exercise/generic/GenericBinaryTree.java | 255 ++++++++++++++++++ .../exercise/generic/GenericIterator.java | 9 + .../exercise/generic/GenericLinkedList.java | 140 ++++++++++ .../aaront/exercise/generic/GenericList.java | 9 + .../aaront/exercise/generic/GenericQueue.java | 30 +++ .../aaront/exercise/generic/GenericStack.java | 33 +++ .../com/aaront/execrise/basic/AllTest.java | 19 ++ .../aaront/execrise/basic/ArrayListTest.java | 69 +++++ .../aaront/execrise/basic/BinaryTreeTest.java | 94 +++++++ .../aaront/execrise/basic/LinkListTest.java | 81 ++++++ .../com/aaront/execrise/basic/QueueTest.java | 33 +++ .../com/aaront/execrise/basic/StackTest.java | 46 ++++ .../execrise/generic/GenericAllTest.java | 19 ++ .../generic/GenericArrayListTest.java | 76 ++++++ .../generic/GenericBinaryTreeTest.java | 75 ++++++ .../generic/GenericLinkedListTest.java | 90 +++++++ .../execrise/generic/GenericQueueTest.java | 33 +++ .../execrise/generic/GenericStackTest.java | 46 ++++ 29 files changed, 1834 insertions(+) create mode 100644 group01/954958168/954958168.md create mode 100644 group01/954958168/class01/BasicDataStructure/.gitignore create mode 100644 group01/954958168/class01/BasicDataStructure/pom.xml create mode 100644 group01/954958168/class01/BasicDataStructure/src/main/java/com/aaront/exercise/basic/ArrayList.java create mode 100644 group01/954958168/class01/BasicDataStructure/src/main/java/com/aaront/exercise/basic/BinaryTree.java create mode 100644 group01/954958168/class01/BasicDataStructure/src/main/java/com/aaront/exercise/basic/Iterator.java create mode 100644 group01/954958168/class01/BasicDataStructure/src/main/java/com/aaront/exercise/basic/LinkedList.java create mode 100644 group01/954958168/class01/BasicDataStructure/src/main/java/com/aaront/exercise/basic/List.java create mode 100644 group01/954958168/class01/BasicDataStructure/src/main/java/com/aaront/exercise/basic/Queue.java create mode 100644 group01/954958168/class01/BasicDataStructure/src/main/java/com/aaront/exercise/basic/Stack.java create mode 100644 group01/954958168/class01/BasicDataStructure/src/main/java/com/aaront/exercise/generic/GenericArrayList.java create mode 100644 group01/954958168/class01/BasicDataStructure/src/main/java/com/aaront/exercise/generic/GenericBinaryTree.java create mode 100644 group01/954958168/class01/BasicDataStructure/src/main/java/com/aaront/exercise/generic/GenericIterator.java create mode 100644 group01/954958168/class01/BasicDataStructure/src/main/java/com/aaront/exercise/generic/GenericLinkedList.java create mode 100644 group01/954958168/class01/BasicDataStructure/src/main/java/com/aaront/exercise/generic/GenericList.java create mode 100644 group01/954958168/class01/BasicDataStructure/src/main/java/com/aaront/exercise/generic/GenericQueue.java create mode 100644 group01/954958168/class01/BasicDataStructure/src/main/java/com/aaront/exercise/generic/GenericStack.java create mode 100644 group01/954958168/class01/BasicDataStructure/src/test/java/com/aaront/execrise/basic/AllTest.java create mode 100644 group01/954958168/class01/BasicDataStructure/src/test/java/com/aaront/execrise/basic/ArrayListTest.java create mode 100644 group01/954958168/class01/BasicDataStructure/src/test/java/com/aaront/execrise/basic/BinaryTreeTest.java create mode 100644 group01/954958168/class01/BasicDataStructure/src/test/java/com/aaront/execrise/basic/LinkListTest.java create mode 100644 group01/954958168/class01/BasicDataStructure/src/test/java/com/aaront/execrise/basic/QueueTest.java create mode 100644 group01/954958168/class01/BasicDataStructure/src/test/java/com/aaront/execrise/basic/StackTest.java create mode 100644 group01/954958168/class01/BasicDataStructure/src/test/java/com/aaront/execrise/generic/GenericAllTest.java create mode 100644 group01/954958168/class01/BasicDataStructure/src/test/java/com/aaront/execrise/generic/GenericArrayListTest.java create mode 100644 group01/954958168/class01/BasicDataStructure/src/test/java/com/aaront/execrise/generic/GenericBinaryTreeTest.java create mode 100644 group01/954958168/class01/BasicDataStructure/src/test/java/com/aaront/execrise/generic/GenericLinkedListTest.java create mode 100644 group01/954958168/class01/BasicDataStructure/src/test/java/com/aaront/execrise/generic/GenericQueueTest.java create mode 100644 group01/954958168/class01/BasicDataStructure/src/test/java/com/aaront/execrise/generic/GenericStackTest.java diff --git a/group01/954958168/954958168.md b/group01/954958168/954958168.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/group01/954958168/class01/BasicDataStructure/.gitignore b/group01/954958168/class01/BasicDataStructure/.gitignore new file mode 100644 index 0000000000..eb95f3ba7f --- /dev/null +++ b/group01/954958168/class01/BasicDataStructure/.gitignore @@ -0,0 +1,28 @@ +# Created by .ignore support plugin (hsz.mobi) +### Java template +*.class + +# Log file +*.log + +# BlueJ files +*.ctxt + +# Mobile Tools for Java (J2ME) +.mtj.tmp/ + +# Package Files # +*.jar +*.war +*.ear +*.zip +*.tar.gz +*.rar + +# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml +hs_err_pid* + +# Idea Files # +.idea +*.iml + diff --git a/group01/954958168/class01/BasicDataStructure/pom.xml b/group01/954958168/class01/BasicDataStructure/pom.xml new file mode 100644 index 0000000000..a224b2116f --- /dev/null +++ b/group01/954958168/class01/BasicDataStructure/pom.xml @@ -0,0 +1,24 @@ + + + 4.0.0 + + com.aaront.execrise + coding2017 + 1.0.0-SNAPSHOT + jar + + + + UTF-8 + 1.8 + + + + + junit + junit + 4.12 + + + \ No newline at end of file diff --git a/group01/954958168/class01/BasicDataStructure/src/main/java/com/aaront/exercise/basic/ArrayList.java b/group01/954958168/class01/BasicDataStructure/src/main/java/com/aaront/exercise/basic/ArrayList.java new file mode 100644 index 0000000000..ae462ea905 --- /dev/null +++ b/group01/954958168/class01/BasicDataStructure/src/main/java/com/aaront/exercise/basic/ArrayList.java @@ -0,0 +1,90 @@ +package com.aaront.exercise.basic; + +import java.util.Arrays; + +public class ArrayList implements List { + + private int size = 0; + + private static final double factor = 0.75; + + private Object[] elementData = new Object[100]; + + public void add(Object o) { + _ensureCapacityEnough(); + elementData[size++] = o; + } + + public void add(int index, Object o) { + if (index < 0 || index > size) throw new IndexOutOfBoundsException("index超出边界"); + _ensureCapacityEnough(); + int i = size; + for (; i > index; i--) { + elementData[i] = elementData[i - 1]; + } + elementData[i] = o; + size++; + } + + private void _ensureCapacityEnough() { + if (size >= elementData.length) { + dilatancy(); + } + } + + private void dilatancy() { + int newLength = elementData.length + (int) (elementData.length * factor); + elementData = Arrays.copyOf(elementData, newLength); + } + + public Object get(int index) { + if(index < 0 || index >= size) throw new IndexOutOfBoundsException("index超出边界"); + return elementData[index]; + } + + public Object remove(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException("index超出边界"); + Object element = elementData[index]; + System.arraycopy(elementData, index + 1, elementData, index, size - 1 - index); + size--; + return element; + + } + + public int size() { + return size; + } + + public Iterator iterator() { + return new ArrayListIterator(this); + } + + public Object[] toArray() { + Object[] objects = new Object[size]; + System.arraycopy(elementData, 0, objects, 0, size); + return objects; + } + + private static class ArrayListIterator implements Iterator { + + private ArrayList arrayList; + private int pos = 0; + + private ArrayListIterator(ArrayList arrayList) { + this.arrayList = arrayList; + } + + public boolean hasNext() { + return pos < arrayList.size(); + } + + public Object next() { + return arrayList.elementData[pos++]; + } + + public void remove() { + arrayList.remove(pos - 1); + pos--; + } + } +} diff --git a/group01/954958168/class01/BasicDataStructure/src/main/java/com/aaront/exercise/basic/BinaryTree.java b/group01/954958168/class01/BasicDataStructure/src/main/java/com/aaront/exercise/basic/BinaryTree.java new file mode 100644 index 0000000000..2c0d156561 --- /dev/null +++ b/group01/954958168/class01/BasicDataStructure/src/main/java/com/aaront/exercise/basic/BinaryTree.java @@ -0,0 +1,235 @@ +package com.aaront.exercise.basic; + +public class BinaryTree { + + private BinaryTreeNode head = new BinaryTreeNode(null); + private BinaryTreeNode root; + private int size; + private int index = 0; + + public static final int PREORDER = 0; + public static final int INORDER = 1; + public static final int POSTORDER = 2; + public static final int HIERARCHICAL = 3; + + public static final int RECURSION = 10; + public static final int ITERATION = 11; + + public void add(Integer o) { + BinaryTreeNode node = new BinaryTreeNode(o); + if (root == null) { + root = node; + head.setLeft(root); + } else { + insert(root, node); + } + size++; + } + + private void insert(BinaryTreeNode node, BinaryTreeNode newNode) { + // 要插入的节点插入当前节点的左子树 + if (node.getData() > newNode.getData()) { + if (node.getLeft() == null) { + node.setLeft(newNode); + } else { + insert(node.left, newNode); + } + } else { // 要插入的节点插入当前节点的右子树 + if (node.getRight() == null) { + node.setRight(newNode); + } else { + insert(node.right, newNode); + } + } + } + + public BinaryTreeNode search(int data) { + return search(data, ITERATION); + } + + public BinaryTreeNode search(int data, int method) { + switch (method) { + case RECURSION: + return findNodeRecursion(root, data); + case ITERATION: + return findNodeIteration(data); + default: + throw new IllegalArgumentException("不支持的查找方法"); + } + } + + private BinaryTreeNode findNodeRecursion(BinaryTreeNode node, int data) { + if (node == null) return null; + if (node.getData() == data) return node; + if (node.getData() > data) return findNodeRecursion(node.getLeft(), data); + return findNodeRecursion(node.getRight(), data); + } + + private BinaryTreeNode findNodeIteration(int data) { + BinaryTreeNode currentNode = root; + while (currentNode != null) { + if (currentNode.getData() == data) { + return currentNode; + } + if (currentNode.getData() > data) { + currentNode = currentNode.getLeft(); + } else { + currentNode = currentNode.getRight(); + } + } + return null; + } + + public BinaryTreeNode min() { + return findMin(root); + } + + private BinaryTreeNode findMin(BinaryTreeNode node) { + if (node == null) return null; + if (node.getLeft() == null) return node; + return findMin(node.getLeft()); + } + + public BinaryTreeNode max() { + return findMax(root); + } + + private BinaryTreeNode findMax(BinaryTreeNode node) { + if (node == null) return null; + if (node.getRight() == null) return node; + return findMax(node.getRight()); + } + + public void delete(Integer data) { + BinaryTreeNode node = search(data); + if (node == null) return; + BinaryTreeNode parentNode = searchParentNode(node); + if (parentNode == null) return; + // 删除叶子节点 + if (node.getLeft() == null && node.getRight() == null) { + if (parentNode.getLeft() == node) parentNode.setLeft(null); + else parentNode.setRight(null); + } else if (node.getLeft() != null && node.getRight() == null) { // 删除只有左子树的节点 + if (parentNode.getLeft() == node) parentNode.setLeft(node.getLeft()); + else parentNode.setRight(node.getLeft()); + } else if (node.getRight() != null && node.getLeft() == null) { // 删除只有右子树的节点 + if (parentNode.getLeft() == node) parentNode.setLeft(node.getRight()); + else parentNode.setRight(node.getRight()); + } else { // 删除有两个子树的节点 + BinaryTreeNode replace = findMin(node.getRight()); + BinaryTreeNode replaceParentNode = searchParentNode(replace); + replaceParentNode.setLeft(replace.getRight()); + node.setData(replace.getData()); + replace.setLeft(null); + replace.setRight(null); + } + size--; + } + + private BinaryTreeNode searchParentNode(BinaryTreeNode node) { + if (node == null) return null; + if (node == root) return head; + BinaryTreeNode current = root; + while (current != null) { + if (current.getLeft() == node || current.getRight() == node) return current; + if (current.getData().compareTo(node.getData()) > 0) current = current.getLeft(); + else current = current.getRight(); + } + return null; + } + + public int[] traversal() { + return traversal(PREORDER); + } + + public int[] traversal(int order) { + int[] datas = new int[size]; + if (order == PREORDER) { + preorderTraversal(root, datas); + } else if (order == INORDER) { + inorderTraversal(root, datas); + } else if (order == POSTORDER) { + postorderTraversal(root, datas); + } else { + hierarchicalTraversal(root, datas); + } + index = 0; + return datas; + } + + private void preorderTraversal(BinaryTreeNode node, int[] datas) { + if (node == null) { + return; + } + + datas[index++] = node.getData(); + preorderTraversal(node.getLeft(), datas); + preorderTraversal(node.getRight(), datas); + } + + private void inorderTraversal(BinaryTreeNode node, int[] datas) { + if (node == null) { + return; + } + + inorderTraversal(node.getLeft(), datas); + datas[index++] = node.getData(); + inorderTraversal(node.getRight(), datas); + } + + private void postorderTraversal(BinaryTreeNode node, int[] datas) { + if (node == null) { + return; + } + + postorderTraversal(node.getLeft(), datas); + postorderTraversal(node.getRight(), datas); + datas[index++] = node.getData(); + } + + private void hierarchicalTraversal(BinaryTreeNode node, int[] datas) { + if (node == null) return; + Queue queue = new Queue(); + queue.enQueue(node); + while (!queue.isEmpty()) { + BinaryTreeNode tmp = (BinaryTreeNode) queue.deQueue(); + datas[index++] = tmp.getData(); + if (tmp.getLeft() != null) queue.enQueue(tmp.getLeft()); + if (tmp.getRight() != null) queue.enQueue(tmp.getRight()); + } + } + + public class BinaryTreeNode { + private Integer data; + private BinaryTreeNode left; + private BinaryTreeNode right; + + public BinaryTreeNode(Integer data) { + this.data = data; + } + + public Integer getData() { + return data; + } + + public void setData(Integer data) { + this.data = data; + } + + public BinaryTreeNode getLeft() { + return left; + } + + public void setLeft(BinaryTreeNode left) { + this.left = left; + } + + public BinaryTreeNode getRight() { + return right; + } + + public void setRight(BinaryTreeNode right) { + this.right = right; + } + } +} diff --git a/group01/954958168/class01/BasicDataStructure/src/main/java/com/aaront/exercise/basic/Iterator.java b/group01/954958168/class01/BasicDataStructure/src/main/java/com/aaront/exercise/basic/Iterator.java new file mode 100644 index 0000000000..e446dd8f65 --- /dev/null +++ b/group01/954958168/class01/BasicDataStructure/src/main/java/com/aaront/exercise/basic/Iterator.java @@ -0,0 +1,9 @@ +package com.aaront.exercise.basic; + +public interface Iterator { + boolean hasNext(); + + Object next(); + + void remove(); +} diff --git a/group01/954958168/class01/BasicDataStructure/src/main/java/com/aaront/exercise/basic/LinkedList.java b/group01/954958168/class01/BasicDataStructure/src/main/java/com/aaront/exercise/basic/LinkedList.java new file mode 100644 index 0000000000..504e73580b --- /dev/null +++ b/group01/954958168/class01/BasicDataStructure/src/main/java/com/aaront/exercise/basic/LinkedList.java @@ -0,0 +1,129 @@ +package com.aaront.exercise.basic; + +public class LinkedList implements List { + + private Node head = new Node(null); + private int size = 0; + + public void add(Object o) { + Node newNode = new Node(o); + Node first = head.next; + Node second = head; + while (first != null) { + second = first; + first = first.next; + } + second.next = newNode; + size++; + } + + public void add(int index, Object o) { + if (index < 0 || index > size) throw new IndexOutOfBoundsException("索引超出范围"); + Node first = head; + int i = 0; + while (i < index) { + first = first.next; + i++; + } + Node node = new Node(o); + node.next = first.next; + first.next = node; + size++; + } + + public Object get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException("索引超出范围"); + Node first = head.next; + int i = 0; + while (i < index) { + first = first.next; + i++; + } + return first.data; + } + + public Object remove(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException("索引超出范围"); + Node first = head; + int i = 0; + while (i < index) { + first = first.next; + i++; + } + Node element = first.next; + first.next = first.next.next; + size--; + return element.data; + } + + public int size() { + return size; + } + + public void addFirst(Object o) { + add(0, o); + } + + public void addLast(Object o) { + add(size, o); + } + + public Object removeFirst() { + return remove(0); + } + + public Object removeLast() { + return remove(size - 1); + } + + public Iterator iterator() { + return new LinkedListIterator(this); + } + + public Object[] toArray() { + Object[] objects = new Object[size]; + Node first = head.next; + int pos = 0; + while (first!= null) { + objects[pos++] = first.data; + first = first.next; + } + return objects; + } + + private static class LinkedListIterator implements Iterator { + + private int pos = 0; + private LinkedList linkedList; + + private LinkedListIterator(LinkedList linkList) { + this.linkedList = linkList; + } + + @Override + public boolean hasNext() { + return pos < linkedList.size(); + } + + @Override + public Object next() { + return linkedList.get(pos++); + } + + @Override + public void remove() { + linkedList.remove(pos - 1); + pos--; + } + } + + + private static class Node { + private Object data; + private Node next; + + private Node(Object data) { + this.data = data; + } + } +} diff --git a/group01/954958168/class01/BasicDataStructure/src/main/java/com/aaront/exercise/basic/List.java b/group01/954958168/class01/BasicDataStructure/src/main/java/com/aaront/exercise/basic/List.java new file mode 100644 index 0000000000..0988b60f4a --- /dev/null +++ b/group01/954958168/class01/BasicDataStructure/src/main/java/com/aaront/exercise/basic/List.java @@ -0,0 +1,9 @@ +package com.aaront.exercise.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/group01/954958168/class01/BasicDataStructure/src/main/java/com/aaront/exercise/basic/Queue.java b/group01/954958168/class01/BasicDataStructure/src/main/java/com/aaront/exercise/basic/Queue.java new file mode 100644 index 0000000000..7c310bca9e --- /dev/null +++ b/group01/954958168/class01/BasicDataStructure/src/main/java/com/aaront/exercise/basic/Queue.java @@ -0,0 +1,26 @@ +package com.aaront.exercise.basic; + +public class Queue { + + private LinkedList linkedList = new LinkedList(); + + public void enQueue(Object o) { + linkedList.add(o); + } + + public Object deQueue() { + return linkedList.removeFirst(); + } + + public boolean isEmpty() { + return linkedList.size() == 0; + } + + public int size() { + return linkedList.size(); + } + + public Object[] toArray() { + return linkedList.toArray(); + } +} diff --git a/group01/954958168/class01/BasicDataStructure/src/main/java/com/aaront/exercise/basic/Stack.java b/group01/954958168/class01/BasicDataStructure/src/main/java/com/aaront/exercise/basic/Stack.java new file mode 100644 index 0000000000..450d21ee89 --- /dev/null +++ b/group01/954958168/class01/BasicDataStructure/src/main/java/com/aaront/exercise/basic/Stack.java @@ -0,0 +1,29 @@ +package com.aaront.exercise.basic; + +public class Stack { + private ArrayList elementData = new ArrayList(); + + public void push(Object o) { + elementData.add(o); + } + + public Object pop() { + return elementData.remove(elementData.size() - 1); + } + + public Object peek() { + return elementData.get(elementData.size() - 1); + } + + public boolean isEmpty() { + return elementData.size() == 0; + } + + public int size() { + return elementData.size(); + } + + public Object[] toArray() { + return elementData.toArray(); + } +} diff --git a/group01/954958168/class01/BasicDataStructure/src/main/java/com/aaront/exercise/generic/GenericArrayList.java b/group01/954958168/class01/BasicDataStructure/src/main/java/com/aaront/exercise/generic/GenericArrayList.java new file mode 100644 index 0000000000..a099746b55 --- /dev/null +++ b/group01/954958168/class01/BasicDataStructure/src/main/java/com/aaront/exercise/generic/GenericArrayList.java @@ -0,0 +1,98 @@ +package com.aaront.exercise.generic; + +import java.util.Arrays; + +public class GenericArrayList implements GenericList { + + private int size = 0; + + private static final double factor = 0.75; + + private Object[] elementData = new Object[100]; + + public void add(T o) { + _ensureCapacityEnough(); + elementData[size++] = o; + } + + public void add(int index, T o) { + if (index < 0 || index > size) throw new IndexOutOfBoundsException("index超出边界"); + _ensureCapacityEnough(); + int i = size; + for (; i > index; i--) { + elementData[i] = elementData[i - 1]; + } + elementData[i] = o; + size++; + } + + private void _ensureCapacityEnough() { + if (size >= elementData.length) { + dilatancy(); + } + } + + private void dilatancy() { + int newLength = elementData.length + (int) (elementData.length * factor); + elementData = Arrays.copyOf(elementData, newLength); + } + + public T get(int index) { + if(index < 0 || index >= size) throw new IndexOutOfBoundsException("index超出边界"); + return (T) elementData[index]; + } + + public T remove(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException("index超出边界"); + Object element = elementData[index]; + System.arraycopy(elementData, index + 1, elementData, index, size - 1 - index); + size--; + return (T) element; + + } + + public int size() { + return size; + } + + public GenericIterator iterator() { + return new ArrayListGenericIterator(this); + } + + public Object[] toArray() { + Object[] objects = new Object[size]; + System.arraycopy(elementData, 0, objects, 0, size); + return objects; + } + + public T[] toArray(T[] a) { + if (a.length < size) + // Make a new array of a's runtime type, but my contents: + return (T[]) Arrays.copyOf(elementData, size, a.getClass()); + System.arraycopy(elementData, 0, a, 0, size); + return a; + } + + private static class ArrayListGenericIterator implements GenericIterator { + + private GenericArrayList genericArrayList; + private int pos = 0; + + private ArrayListGenericIterator(GenericArrayList genericArrayList) { + this.genericArrayList = genericArrayList; + } + + public boolean hasNext() { + return pos < genericArrayList.size(); + } + + public T next() { + return (T) genericArrayList.elementData[pos++]; + } + + public void remove() { + genericArrayList.remove(pos - 1); + pos--; + } + } +} \ No newline at end of file diff --git a/group01/954958168/class01/BasicDataStructure/src/main/java/com/aaront/exercise/generic/GenericBinaryTree.java b/group01/954958168/class01/BasicDataStructure/src/main/java/com/aaront/exercise/generic/GenericBinaryTree.java new file mode 100644 index 0000000000..e5cf3b439a --- /dev/null +++ b/group01/954958168/class01/BasicDataStructure/src/main/java/com/aaront/exercise/generic/GenericBinaryTree.java @@ -0,0 +1,255 @@ +package com.aaront.exercise.generic; + +import java.util.Arrays; + +public class GenericBinaryTree> { + + private BinaryTreeNode head = new BinaryTreeNode<>(null); + private BinaryTreeNode root; + private int size; + private int index = 0; + public static final int PREORDER = 0; + public static final int INORDER = 1; + public static final int POSTORDER = 2; + public static final int HIERARCHICAL = 3; + + public static final int RECURSION = 10; + public static final int ITERATION = 11; + + public void add(T o) { + BinaryTreeNode node = new BinaryTreeNode<>(o); + if (root == null) { + root = node; + head.setLeft(root); + } else { + insert(root, node); + } + size++; + } + + private void insert(BinaryTreeNode node, BinaryTreeNode newNode) { + // 要插入的节点插入当前节点的左子树 + if (node.getData().compareTo(newNode.getData()) > 0) { + if (node.getLeft() == null) { + node.setLeft(newNode); + } else { + insert(node.left, newNode); + } + } else { // 要插入的节点插入当前节点的右子树 + if (node.getRight() == null) { + node.setRight(newNode); + } else { + insert(node.right, newNode); + } + } + } + + public BinaryTreeNode search(T data) { + return search(data, ITERATION); + } + + public BinaryTreeNode search(T data, int method) { + switch (method) { + case RECURSION: + return findNodeRecursion(root, data); + case ITERATION: + return findNodeIteration(data); + default: + throw new IllegalArgumentException("不支持的查找方法"); + } + } + + private BinaryTreeNode findNodeRecursion(BinaryTreeNode node, T data) { + if (node == null) return null; + if (node.getData().compareTo(data) == 0) return node; + if (node.getData().compareTo(data) > 0) return findNodeRecursion(node.getLeft(), data); + return findNodeRecursion(node.getRight(), data); + } + + private BinaryTreeNode findNodeIteration(T data) { + BinaryTreeNode currentNode = root; + while (currentNode != null) { + if (currentNode.getData().compareTo(data) == 0) { + return currentNode; + } + if (currentNode.getData().compareTo(data) > 0) { + currentNode = currentNode.getLeft(); + } else { + currentNode = currentNode.getRight(); + } + } + return null; + } + + public BinaryTreeNode min() { + return findMin(root); + } + + private BinaryTreeNode findMin(BinaryTreeNode node) { + if (node == null) return null; + if (node.getLeft() == null) return node; + return findMin(node.getLeft()); + } + + public BinaryTreeNode max() { + return findMax(root); + } + + private BinaryTreeNode findMax(BinaryTreeNode node) { + if (node == null) return null; + if (node.getRight() == null) return node; + return findMax(node.getRight()); + } + + public void delete(T data) { + BinaryTreeNode node = search(data); + if (node == null) return; + BinaryTreeNode parentNode = searchParentNode(node); + if (parentNode == null) return; + // 删除叶子节点 + if (node.getLeft() == null && node.getRight() == null) { + if (parentNode.getLeft() == node) parentNode.setLeft(null); + else parentNode.setRight(null); + } else if (node.getLeft() != null && node.getRight() == null) { // 删除只有左子树的节点 + if (parentNode.getLeft() == node) parentNode.setLeft(node.getLeft()); + else parentNode.setRight(node.getLeft()); + } else if (node.getRight() != null && node.getLeft() == null) { // 删除只有右子树的节点 + if (parentNode.getLeft() == node) parentNode.setLeft(node.getRight()); + else parentNode.setRight(node.getRight()); + } else { // 删除有两个子树的节点 + BinaryTreeNode replace = findMin(node.getRight()); + BinaryTreeNode replaceParentNode = searchParentNode(replace); + replaceParentNode.setLeft(replace.getRight()); + node.setData(replace.getData()); + replace.setLeft(null); + replace.setRight(null); + } + size--; + } + + private BinaryTreeNode searchParentNode(BinaryTreeNode node) { + if (node == null) return null; + if (node == root) return head; + BinaryTreeNode current = root; + while (current != null) { + if (current.getLeft() == node || current.getRight() == node) return current; + if (current.getData().compareTo(node.getData()) > 0) current = current.getLeft(); + else current = current.getRight(); + } + return null; + } + + public Object[] traversal() { + return traversal(PREORDER); + } + + public T[] traversal(T[] a) { + Object[] elementData = traversal(PREORDER); + return toArray(elementData, a); + } + + public T[] traversal(int order, T[] a) { + Object[] elementData = traversal(order); + return toArray(elementData, a); + } + + private T[] toArray(Object[] elementData, T[] a) { + if (a.length < size) + // Make a new array of a's runtime type, but my contents: + return (T[]) Arrays.copyOf(elementData, size, a.getClass()); + System.arraycopy(elementData, 0, a, 0, size); + return a; + } + + public Object[] traversal(int order) { + Object[] datas = new Object[size]; + if (order == PREORDER) { + preorderTraversal(root, datas); + } else if (order == INORDER) { + inorderTraversal(root, datas); + } else if (order == POSTORDER) { + postorderTraversal(root, datas); + } else { + hierarchicalTraversal(root, datas); + } + index = 0; + return datas; + } + + private void preorderTraversal(BinaryTreeNode node, Object[] datas) { + if (node == null) { + return; + } + + datas[index++] = node.getData(); + preorderTraversal(node.getLeft(), datas); + preorderTraversal(node.getRight(), datas); + } + + private void inorderTraversal(BinaryTreeNode node, Object[] datas) { + if (node == null) { + return; + } + + inorderTraversal(node.getLeft(), datas); + datas[index++] = node.getData(); + inorderTraversal(node.getRight(), datas); + } + + private void postorderTraversal(BinaryTreeNode node, Object[] datas) { + if (node == null) { + return; + } + + postorderTraversal(node.getLeft(), datas); + postorderTraversal(node.getRight(), datas); + datas[index++] = node.getData(); + } + + private void hierarchicalTraversal(BinaryTreeNode node, Object[] datas) { + if (node == null) return; + GenericQueue> queue = new GenericQueue<>(); + queue.enQueue(node); + while (!queue.isEmpty()) { + BinaryTreeNode tmp = queue.deQueue(); + datas[index++] = tmp.getData(); + if (tmp.getLeft() != null) queue.enQueue(tmp.getLeft()); + if (tmp.getRight() != null) queue.enQueue(tmp.getRight()); + } + } + + + class BinaryTreeNode> { + private T data; + private BinaryTreeNode left; + private BinaryTreeNode right; + + public BinaryTreeNode(T data) { + this.data = data; + } + + public T getData() { + return data; + } + + public void setData(T 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; + } + } +} diff --git a/group01/954958168/class01/BasicDataStructure/src/main/java/com/aaront/exercise/generic/GenericIterator.java b/group01/954958168/class01/BasicDataStructure/src/main/java/com/aaront/exercise/generic/GenericIterator.java new file mode 100644 index 0000000000..565114dce7 --- /dev/null +++ b/group01/954958168/class01/BasicDataStructure/src/main/java/com/aaront/exercise/generic/GenericIterator.java @@ -0,0 +1,9 @@ +package com.aaront.exercise.generic; + +public interface GenericIterator { + boolean hasNext(); + + T next(); + + void remove(); +} diff --git a/group01/954958168/class01/BasicDataStructure/src/main/java/com/aaront/exercise/generic/GenericLinkedList.java b/group01/954958168/class01/BasicDataStructure/src/main/java/com/aaront/exercise/generic/GenericLinkedList.java new file mode 100644 index 0000000000..7caf32eae1 --- /dev/null +++ b/group01/954958168/class01/BasicDataStructure/src/main/java/com/aaront/exercise/generic/GenericLinkedList.java @@ -0,0 +1,140 @@ +package com.aaront.exercise.generic; + +import java.util.Arrays; + +public class GenericLinkedList implements GenericList { + + private Node head = new Node<>(null); + private int size = 0; + + public void add(T o) { + Node newNode = new Node<>(o); + Node first = head.next; + Node second = head; + while (first != null) { + second = first; + first = first.next; + } + second.next = newNode; + size++; + } + + public void add(int index, T o) { + if (index < 0 || index > size) throw new IndexOutOfBoundsException("索引超出范围"); + Node first = head; + int i = 0; + while (i < index) { + first = first.next; + i++; + } + Node node = new Node<>(o); + node.next = first.next; + first.next = node; + size++; + } + + public T get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException("索引超出范围"); + Node first = head.next; + int i = 0; + while (i < index) { + first = first.next; + i++; + } + return first.data; + } + + public T remove(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException("索引超出范围"); + Node first = head; + int i = 0; + while (i < index) { + first = first.next; + i++; + } + Node element = first.next; + first.next = first.next.next; + size--; + return element.data; + } + + public int size() { + return size; + } + + public void addFirst(T o) { + add(0, o); + } + + public void addLast(T o) { + add(size, o); + } + + public T removeFirst() { + return remove(0); + } + + public T removeLast() { + return remove(size - 1); + } + + public GenericIterator iterator() { + return new LinkedListGenericIterator<>(this); + } + + public Object[] toArray() { + Object[] objects = new Object[size]; + Node first = head.next; + int pos = 0; + while (first != null) { + objects[pos++] = first.data; + first = first.next; + } + return objects; + } + + public T[] toArray(T[] a) { + Object[] elementData = toArray(); + if (a.length < size) + // Make a new array of a's runtime type, but my contents: + return (T[]) Arrays.copyOf(elementData, size, a.getClass()); + System.arraycopy(elementData, 0, a, 0, size); + return a; + } + + private static class LinkedListGenericIterator implements GenericIterator { + + private int pos = 0; + private GenericLinkedList genericLinkedList; + + private LinkedListGenericIterator(GenericLinkedList linkList) { + this.genericLinkedList = linkList; + } + + @Override + public boolean hasNext() { + return pos < genericLinkedList.size(); + } + + @Override + public T next() { + return genericLinkedList.get(pos++); + } + + @Override + public void remove() { + genericLinkedList.remove(pos - 1); + pos--; + } + } + + + private static class Node { + private T data; + private Node next; + + private Node(T data) { + this.data = data; + } + } +} diff --git a/group01/954958168/class01/BasicDataStructure/src/main/java/com/aaront/exercise/generic/GenericList.java b/group01/954958168/class01/BasicDataStructure/src/main/java/com/aaront/exercise/generic/GenericList.java new file mode 100644 index 0000000000..94dc9f8a98 --- /dev/null +++ b/group01/954958168/class01/BasicDataStructure/src/main/java/com/aaront/exercise/generic/GenericList.java @@ -0,0 +1,9 @@ +package com.aaront.exercise.generic; + +public interface GenericList { + public void add(T o); + public void add(int index, T o); + public T get(int index); + public T remove(int index); + public int size(); +} \ No newline at end of file diff --git a/group01/954958168/class01/BasicDataStructure/src/main/java/com/aaront/exercise/generic/GenericQueue.java b/group01/954958168/class01/BasicDataStructure/src/main/java/com/aaront/exercise/generic/GenericQueue.java new file mode 100644 index 0000000000..d5cf5681e5 --- /dev/null +++ b/group01/954958168/class01/BasicDataStructure/src/main/java/com/aaront/exercise/generic/GenericQueue.java @@ -0,0 +1,30 @@ +package com.aaront.exercise.generic; + +public class GenericQueue { + + private GenericLinkedList linkedList = new GenericLinkedList<>(); + + public void enQueue(T o) { + linkedList.add(o); + } + + public T deQueue() { + return linkedList.removeFirst(); + } + + public boolean isEmpty() { + return linkedList.size() == 0; + } + + public int size() { + return linkedList.size(); + } + + public Object[] toArray() { + return linkedList.toArray(); + } + + public T[] toArray(T[] a) { + return linkedList.toArray(a); + } +} diff --git a/group01/954958168/class01/BasicDataStructure/src/main/java/com/aaront/exercise/generic/GenericStack.java b/group01/954958168/class01/BasicDataStructure/src/main/java/com/aaront/exercise/generic/GenericStack.java new file mode 100644 index 0000000000..9efb2f2220 --- /dev/null +++ b/group01/954958168/class01/BasicDataStructure/src/main/java/com/aaront/exercise/generic/GenericStack.java @@ -0,0 +1,33 @@ +package com.aaront.exercise.generic; + +public class GenericStack { + private GenericArrayList elementData = new GenericArrayList<>(); + + public void push(T o) { + elementData.add(o); + } + + public T pop() { + return elementData.remove(elementData.size() - 1); + } + + public T peek() { + return elementData.get(elementData.size() - 1); + } + + public boolean isEmpty() { + return elementData.size() == 0; + } + + public int size() { + return elementData.size(); + } + + public Object[] toArray() { + return elementData.toArray(); + } + + public T[] toArray(T[] a) { + return elementData.toArray(a); + } +} diff --git a/group01/954958168/class01/BasicDataStructure/src/test/java/com/aaront/execrise/basic/AllTest.java b/group01/954958168/class01/BasicDataStructure/src/test/java/com/aaront/execrise/basic/AllTest.java new file mode 100644 index 0000000000..ebff633b23 --- /dev/null +++ b/group01/954958168/class01/BasicDataStructure/src/test/java/com/aaront/execrise/basic/AllTest.java @@ -0,0 +1,19 @@ +package com.aaront.execrise.basic; + +import org.junit.runner.RunWith; +import org.junit.runners.Suite; + +/** + * @author tonyhui + * @since 17/2/21 + */ +@RunWith(Suite.class) +@Suite.SuiteClasses({ + ArrayListTest.class, + BinaryTreeTest.class, + LinkListTest.class, + QueueTest.class, + StackTest.class +}) +public class AllTest { +} diff --git a/group01/954958168/class01/BasicDataStructure/src/test/java/com/aaront/execrise/basic/ArrayListTest.java b/group01/954958168/class01/BasicDataStructure/src/test/java/com/aaront/execrise/basic/ArrayListTest.java new file mode 100644 index 0000000000..dcc45d792e --- /dev/null +++ b/group01/954958168/class01/BasicDataStructure/src/test/java/com/aaront/execrise/basic/ArrayListTest.java @@ -0,0 +1,69 @@ +package com.aaront.execrise.basic; + +import com.aaront.exercise.basic.ArrayList; +import com.aaront.exercise.basic.Iterator; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; + +/** + * @author tonyhui + * @since 17/2/20 + */ +public class ArrayListTest { + + private ArrayList arrayList = new ArrayList(); + + @Before + public void init() { + arrayList.add(1); + arrayList.add(2); + arrayList.add(3); + } + + @Test + public void testAdd() { + Assert.assertEquals(arrayList.get(0), 1); + Assert.assertEquals(arrayList.get(1), 2); + Assert.assertEquals(arrayList.get(2), 3); + Assert.assertEquals(arrayList.size(), 3); + } + + @Test + public void testAddIndex() { + arrayList.add(1, 4); + arrayList.add(2, 5); + Assert.assertArrayEquals(arrayList.toArray(), new Object[]{1, 4, 5, 2, 3}); + } + + @Test + public void testToArray() { + Assert.assertArrayEquals(arrayList.toArray(), new Object[]{1, 2, 3}); + } + + @Test + public void testGet() { + Assert.assertEquals(arrayList.get(2), 3); + Assert.assertEquals(arrayList.get(0), 1); + Assert.assertEquals(arrayList.get(1), 2); + } + + @Test + public void testRemove() { + testAddIndex(); + arrayList.remove(2); + arrayList.add(4, 10); + arrayList.add(3, 9); + Assert.assertArrayEquals(arrayList.toArray(), new Object[]{1, 4, 2, 9, 3, 10}); + } + + @Test + public void testIterator() { + Iterator iterator = arrayList.iterator(); + while (iterator.hasNext()) { + iterator.next(); + iterator.remove(); + } + Assert.assertArrayEquals(arrayList.toArray(), new Object[]{}); + } +} diff --git a/group01/954958168/class01/BasicDataStructure/src/test/java/com/aaront/execrise/basic/BinaryTreeTest.java b/group01/954958168/class01/BasicDataStructure/src/test/java/com/aaront/execrise/basic/BinaryTreeTest.java new file mode 100644 index 0000000000..11fb7ad66b --- /dev/null +++ b/group01/954958168/class01/BasicDataStructure/src/test/java/com/aaront/execrise/basic/BinaryTreeTest.java @@ -0,0 +1,94 @@ +package com.aaront.execrise.basic; + +import com.aaront.exercise.basic.BinaryTree; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; + +/** + * @author tonyhui + * @since 17/2/20 + */ +public class BinaryTreeTest { + + private BinaryTree binaryTree = null; + + @Before + public void init() { + int[] datas = new int[]{9, 4, 5, 7, 1, 2, 3, 10, 17, 9}; + binaryTree = new BinaryTree(); + for (int data : datas) { + binaryTree.add(data); + } + } + + + @Test + public void testAdd() { + int[] preorderDatas = binaryTree.traversal(BinaryTree.PREORDER); + Assert.assertArrayEquals(preorderDatas, new int[]{9, 4, 1, 2, 3, 5, 7, 10, 9, 17}); + int[] inorderDatas = binaryTree.traversal(BinaryTree.INORDER); + Assert.assertArrayEquals(inorderDatas, new int[]{1, 2, 3, 4, 5, 7, 9, 9, 10, 17}); + int[] postorderDatas = binaryTree.traversal(BinaryTree.POSTORDER); + Assert.assertArrayEquals(postorderDatas, new int[]{3, 2, 1, 7, 5, 4, 9, 17, 10, 9}); + int[] hierarchicalDatas = binaryTree.traversal(BinaryTree.HIERARCHICAL); + Assert.assertArrayEquals(hierarchicalDatas, new int[]{9, 4, 10, 1, 5, 9, 17, 2, 7, 3}); + } + + @Test + public void testSearch() { + BinaryTree.BinaryTreeNode node1 = binaryTree.search(5, BinaryTree.RECURSION); + Assert.assertTrue(node1.getData() == 5); + BinaryTree.BinaryTreeNode node2 = binaryTree.search(17, BinaryTree.RECURSION); + Assert.assertTrue(node2.getData() == 17); + BinaryTree.BinaryTreeNode node3 = binaryTree.search(100, BinaryTree.RECURSION); + Assert.assertTrue(node3 == null); + } + + @Test + public void testMin() { + BinaryTree.BinaryTreeNode min = binaryTree.min(); + Assert.assertTrue(min.getData() == 1); + } + + @Test + public void testMax() { + BinaryTree.BinaryTreeNode max = binaryTree.max(); + Assert.assertTrue(max.getData() == 17); + } + + @Test + public void testDelete() { + buildTree(new int[]{50, 25, 12, 11, 40, 14, 35, 45, 44, 43, 42, 75, 55, 70, 60, 65, 63, 61, 90, 80, 85, 82, 88}); + // 删除叶子节点 + binaryTree.delete(11); + int[] preOrderDatas = binaryTree.traversal(); + Assert.assertArrayEquals(preOrderDatas, new int[]{50, 25, 12, 14, 40, 35, 45, 44, 43, 42, 75, 55, 70, 60, 65, 63, 61, 90, 80, 85, 82, 88}); + binaryTree.delete(88); + preOrderDatas = binaryTree.traversal(); + Assert.assertArrayEquals(preOrderDatas, new int[]{50, 25, 12, 14, 40, 35, 45, 44, 43, 42, 75, 55, 70, 60, 65, 63, 61, 90, 80, 85, 82}); + + // 删除一个子节点的节点 + binaryTree.delete(70); + preOrderDatas = binaryTree.traversal(); + Assert.assertArrayEquals(preOrderDatas, new int[]{50, 25, 12, 14, 40, 35, 45, 44, 43, 42, 75, 55, 60, 65, 63, 61, 90, 80, 85, 82}); + binaryTree.delete(80); + preOrderDatas = binaryTree.traversal(); + Assert.assertArrayEquals(preOrderDatas, new int[]{50, 25, 12, 14, 40, 35, 45, 44, 43, 42, 75, 55, 60, 65, 63, 61, 90, 85, 82}); + + // 删除两个子节点的节点 + binaryTree.delete(40); + preOrderDatas = binaryTree.traversal(); + Assert.assertArrayEquals(preOrderDatas, new int[]{50, 25, 12, 14, 42, 35, 45, 44, 43, 75, 55, 60, 65, 63, 61, 90, 85, 82}); + binaryTree.delete(50); + preOrderDatas = binaryTree.traversal(); + Assert.assertArrayEquals(preOrderDatas, new int[]{55, 25, 12, 14, 42, 35, 45, 44, 43, 75, 60, 65, 63, 61, 90, 85, 82}); + } + + private void buildTree(int[] datas) { + binaryTree = new BinaryTree(); + for (int data : datas) { + binaryTree.add(data); + } + } +} \ No newline at end of file diff --git a/group01/954958168/class01/BasicDataStructure/src/test/java/com/aaront/execrise/basic/LinkListTest.java b/group01/954958168/class01/BasicDataStructure/src/test/java/com/aaront/execrise/basic/LinkListTest.java new file mode 100644 index 0000000000..b690c69c94 --- /dev/null +++ b/group01/954958168/class01/BasicDataStructure/src/test/java/com/aaront/execrise/basic/LinkListTest.java @@ -0,0 +1,81 @@ +package com.aaront.execrise.basic; + +import com.aaront.exercise.basic.Iterator; +import com.aaront.exercise.basic.LinkedList; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; + +/** + * @author tonyhui + * @since 17/2/21 + */ +public class LinkListTest { + + private LinkedList linkedList = new LinkedList(); + + @Before + public void init() { + linkedList.add(1); + linkedList.add(2); + linkedList.add(3); + } + + @Test + public void testAdd() { + Assert.assertArrayEquals(linkedList.toArray(), new Object[]{1, 2, 3}); + } + + @Test + public void testAddIndex() { + linkedList.add(1, 10); + linkedList.add(0, 8); + Assert.assertArrayEquals(linkedList.toArray(), new Object[]{8, 1, 10, 2, 3}); + } + + @Test + public void testAddFirst() { + linkedList.addFirst(-1); + Assert.assertArrayEquals(linkedList.toArray(), new Object[]{-1, 1, 2, 3}); + } + + @Test + public void testAddLast() { + linkedList.addLast(99); + Assert.assertArrayEquals(linkedList.toArray(), new Object[]{1, 2, 3, 99}); + } + + @Test + public void testRemove() { + testAddIndex(); + linkedList.remove(1); + linkedList.remove(2); + linkedList.add(3, 3); + linkedList.add(1, 2); + Assert.assertArrayEquals(linkedList.toArray(), new Object[]{8, 2, 10, 3, 3}); + } + + @Test + public void testRemoveFirst() { + linkedList.removeFirst(); + linkedList.removeFirst(); + Assert.assertArrayEquals(linkedList.toArray(), new Object[]{3}); + } + + @Test + public void testRemoveLast() { + linkedList.removeLast(); + linkedList.removeLast(); + Assert.assertArrayEquals(linkedList.toArray(), new Object[]{1}); + } + + @Test + public void testIterator() { + Iterator iterator = linkedList.iterator(); + while (iterator.hasNext()) { + iterator.next(); + iterator.remove(); + } + Assert.assertArrayEquals(linkedList.toArray(), new Object[]{}); + } +} diff --git a/group01/954958168/class01/BasicDataStructure/src/test/java/com/aaront/execrise/basic/QueueTest.java b/group01/954958168/class01/BasicDataStructure/src/test/java/com/aaront/execrise/basic/QueueTest.java new file mode 100644 index 0000000000..0035a353ec --- /dev/null +++ b/group01/954958168/class01/BasicDataStructure/src/test/java/com/aaront/execrise/basic/QueueTest.java @@ -0,0 +1,33 @@ +package com.aaront.execrise.basic; + +import com.aaront.exercise.basic.Queue; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; + +/** + * @author tonyhui + * @since 17/2/21 + */ +public class QueueTest { + private Queue queue = new Queue(); + + @Before + public void init() { + queue.enQueue(1); + queue.enQueue(2); + queue.enQueue(3); + } + + @Test + public void testEnqueue() { + Assert.assertArrayEquals(queue.toArray(), new Object[]{1, 2, 3}); + } + + @Test + public void testDequeue() { + queue.deQueue(); + queue.deQueue(); + Assert.assertArrayEquals(queue.toArray(), new Object[]{3}); + } +} diff --git a/group01/954958168/class01/BasicDataStructure/src/test/java/com/aaront/execrise/basic/StackTest.java b/group01/954958168/class01/BasicDataStructure/src/test/java/com/aaront/execrise/basic/StackTest.java new file mode 100644 index 0000000000..3add6bcfdf --- /dev/null +++ b/group01/954958168/class01/BasicDataStructure/src/test/java/com/aaront/execrise/basic/StackTest.java @@ -0,0 +1,46 @@ +package com.aaront.execrise.basic; + +import com.aaront.exercise.basic.Stack; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; + +/** + * @author tonyhui + * @since 17/2/21 + */ +public class StackTest { + + private Stack stack = new Stack(); + + @Before + public void init() { + stack.push(1); + stack.push(2); + stack.push(3); + } + + @Test + public void testPush() { + Assert.assertArrayEquals(stack.toArray(), new Object[]{1, 2, 3}); + } + + @Test + public void testPop() { + Object element1 = stack.pop(); + Assert.assertEquals(element1, 3); + Object element2 = stack.pop(); + Assert.assertEquals(element2, 2); + Assert.assertArrayEquals(stack.toArray(), new Object[]{1}); + } + + @Test + public void testPeek() { + Object element1 = stack.peek(); + Assert.assertEquals(element1, 3); + Object element2 = stack.peek(); + Assert.assertEquals(element2, 3); + Assert.assertArrayEquals(stack.toArray(), new Object[]{1, 2, 3}); + } + +} diff --git a/group01/954958168/class01/BasicDataStructure/src/test/java/com/aaront/execrise/generic/GenericAllTest.java b/group01/954958168/class01/BasicDataStructure/src/test/java/com/aaront/execrise/generic/GenericAllTest.java new file mode 100644 index 0000000000..66c071cf5c --- /dev/null +++ b/group01/954958168/class01/BasicDataStructure/src/test/java/com/aaront/execrise/generic/GenericAllTest.java @@ -0,0 +1,19 @@ +package com.aaront.execrise.generic; + +import org.junit.runner.RunWith; +import org.junit.runners.Suite; + +/** + * @author tonyhui + * @since 17/2/22 + */ +@RunWith(Suite.class) +@Suite.SuiteClasses({ + GenericArrayListTest.class, + GenericLinkedListTest.class, + GenericQueueTest.class, + GenericStackTest.class, + GenericBinaryTreeTest.class +}) +public class GenericAllTest { +} diff --git a/group01/954958168/class01/BasicDataStructure/src/test/java/com/aaront/execrise/generic/GenericArrayListTest.java b/group01/954958168/class01/BasicDataStructure/src/test/java/com/aaront/execrise/generic/GenericArrayListTest.java new file mode 100644 index 0000000000..8f97cbd3ea --- /dev/null +++ b/group01/954958168/class01/BasicDataStructure/src/test/java/com/aaront/execrise/generic/GenericArrayListTest.java @@ -0,0 +1,76 @@ +package com.aaront.execrise.generic; + +import com.aaront.exercise.generic.GenericArrayList; +import com.aaront.exercise.generic.GenericIterator; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; + +/** + * @author tonyhui + * @since 17/2/22 + */ +public class GenericArrayListTest { + + private GenericArrayList arrayList = new GenericArrayList<>(); + + @Before + public void init() { + arrayList.add("1"); + arrayList.add("2"); + arrayList.add("3"); + } + + + @Test + public void testAdd() { + Assert.assertEquals(arrayList.get(0), "1"); + Assert.assertEquals(arrayList.get(1), "2"); + Assert.assertEquals(arrayList.get(2), "3"); + Assert.assertEquals(arrayList.size(), 3); + } + + @Test + public void testAddIndex() { + arrayList.add(1, "4"); + arrayList.add(2, "5"); + Assert.assertArrayEquals(arrayList.toArray(), new String[]{"1", "4", "5", "2", "3"}); + } + + @Test + public void testToArray() { + Assert.assertArrayEquals(arrayList.toArray(), new String[]{"1", "2", "3"}); + } + + @Test + public void testToGenericArray() { + Assert.assertArrayEquals(arrayList.toArray(new String[0]), new String[]{"1", "2", "3"}); + } + + @Test + public void testGet() { + Assert.assertEquals(arrayList.get(2), "3"); + Assert.assertEquals(arrayList.get(0), "1"); + Assert.assertEquals(arrayList.get(1), "2"); + } + + @Test + public void testRemove() { + testAddIndex(); + arrayList.remove(2); + arrayList.add(4, "10"); + arrayList.add(3, "9"); + Assert.assertArrayEquals(arrayList.toArray(), new String[]{"1", "4", "2", "9", "3", "10"}); + } + + @Test + public void testIterator() { + GenericIterator genericIterator = arrayList.iterator(); + while (genericIterator.hasNext()) { + genericIterator.next(); + genericIterator.remove(); + } + Assert.assertArrayEquals(arrayList.toArray(), new String[]{}); + } + +} diff --git a/group01/954958168/class01/BasicDataStructure/src/test/java/com/aaront/execrise/generic/GenericBinaryTreeTest.java b/group01/954958168/class01/BasicDataStructure/src/test/java/com/aaront/execrise/generic/GenericBinaryTreeTest.java new file mode 100644 index 0000000000..41adbf6706 --- /dev/null +++ b/group01/954958168/class01/BasicDataStructure/src/test/java/com/aaront/execrise/generic/GenericBinaryTreeTest.java @@ -0,0 +1,75 @@ +package com.aaront.execrise.generic; + +import com.aaront.exercise.generic.GenericBinaryTree; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; + +/** + * @author tonyhui + * @since 17/2/20 + */ +public class GenericBinaryTreeTest { + + @Before + public void init() { + String[] datas = new String[]{"9", "4", "5", "7", "1", "2", "3", "10", "17", "9"}; + GenericBinaryTree binaryTree = new GenericBinaryTree<>(); + for (String data : datas) { + binaryTree.add(data); + } + } + + @Test + public void testAdd() { + String[] datas = new String[]{"9", "4", "5", "7", "1", "2", "3", "10", "17", "9"}; + GenericBinaryTree binaryTree = new GenericBinaryTree<>(); + for (String data : datas) { + binaryTree.add(data); + } + String[] preorderDatas = binaryTree.traversal(GenericBinaryTree.PREORDER, new String[0]); + Assert.assertArrayEquals(preorderDatas, new String[]{"9", "4", "1", "2", "10", "17", "3", "5", "7", "9" }); + String[] inorderDatas = binaryTree.traversal(GenericBinaryTree.INORDER, new String[0]); + Assert.assertArrayEquals(inorderDatas, new String[]{"1", "10", "17", "2", "3", "4", "5", "7", "9", "9" }); + String[] postorderDatas = binaryTree.traversal(GenericBinaryTree.POSTORDER, new String[0]); + Assert.assertArrayEquals(postorderDatas, new String[]{"17", "10", "3", "2", "1", "7", "5", "4", "9", "9" }); + String[] hierarchicalDatas = binaryTree.traversal(GenericBinaryTree.HIERARCHICAL, new String[0]); + Assert.assertArrayEquals(hierarchicalDatas, new String[]{"9", "4", "9", "1", "5", "2", "7", "10", "3", "17" }); + } + + @Test + public void testDelete() { + GenericBinaryTree binaryTree = buildTree(new int[]{50, 25, 12, 11, 40, 14, 35, 45, 44, 43, 42, 75, 55, 70, 60, 65, 63, 61, 90, 80, 85, 82, 88}); + // 删除叶子节点 + binaryTree.delete(11); + Object[] preOrderDatas = binaryTree.traversal(); + Assert.assertArrayEquals(preOrderDatas, new Object[]{50, 25, 12, 14, 40, 35, 45, 44, 43, 42, 75, 55, 70, 60, 65, 63, 61, 90, 80, 85, 82, 88}); + binaryTree.delete(88); + preOrderDatas = binaryTree.traversal(); + Assert.assertArrayEquals(preOrderDatas, new Object[]{50, 25, 12, 14, 40, 35, 45, 44, 43, 42, 75, 55, 70, 60, 65, 63, 61, 90, 80, 85, 82}); + + // 删除一个子节点的节点 + binaryTree.delete(70); + preOrderDatas = binaryTree.traversal(); + Assert.assertArrayEquals(preOrderDatas, new Object[]{50, 25, 12, 14, 40, 35, 45, 44, 43, 42, 75, 55, 60, 65, 63, 61, 90, 80, 85, 82}); + binaryTree.delete(80); + preOrderDatas = binaryTree.traversal(); + Assert.assertArrayEquals(preOrderDatas, new Object[]{50, 25, 12, 14, 40, 35, 45, 44, 43, 42, 75, 55, 60, 65, 63, 61, 90, 85, 82}); + + // 删除两个子节点的节点 + binaryTree.delete(40); + preOrderDatas = binaryTree.traversal(); + Assert.assertArrayEquals(preOrderDatas, new Object[]{50, 25, 12, 14, 42, 35, 45, 44, 43, 75, 55, 60, 65, 63, 61, 90, 85, 82}); + binaryTree.delete(50); + preOrderDatas = binaryTree.traversal(); + Assert.assertArrayEquals(preOrderDatas, new Object[]{55, 25, 12, 14, 42, 35, 45, 44, 43, 75, 60, 65, 63, 61, 90, 85, 82}); + } + + private GenericBinaryTree buildTree(int[] datas) { + GenericBinaryTree binaryTree = new GenericBinaryTree<>(); + for (int data : datas) { + binaryTree.add(data); + } + return binaryTree; + } +} \ No newline at end of file diff --git a/group01/954958168/class01/BasicDataStructure/src/test/java/com/aaront/execrise/generic/GenericLinkedListTest.java b/group01/954958168/class01/BasicDataStructure/src/test/java/com/aaront/execrise/generic/GenericLinkedListTest.java new file mode 100644 index 0000000000..513119fa6e --- /dev/null +++ b/group01/954958168/class01/BasicDataStructure/src/test/java/com/aaront/execrise/generic/GenericLinkedListTest.java @@ -0,0 +1,90 @@ +package com.aaront.execrise.generic; + +import com.aaront.exercise.generic.GenericLinkedList; +import com.aaront.exercise.generic.GenericIterator; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; + +/** + * @author tonyhui + * @since 17/2/22 + */ +public class GenericLinkedListTest { + private GenericLinkedList linkedList = new GenericLinkedList<>(); + + @Before + public void init() { + linkedList.add("1"); + linkedList.add("2"); + linkedList.add("3"); + } + + @Test + public void testAdd() { + Assert.assertArrayEquals(linkedList.toArray(), new String[]{"1", "2", "3"}); + } + + @Test + public void testAddIndex() { + linkedList.add(1, "10"); + linkedList.add(0, "8"); + Assert.assertArrayEquals(linkedList.toArray(), new String[]{"8", "1", "10", "2", "3"}); + } + + @Test + public void testAddFirst() { + linkedList.addFirst("-1"); + Assert.assertArrayEquals(linkedList.toArray(), new String[]{"-1", "1", "2", "3"}); + } + + @Test + public void testAddLast() { + linkedList.addLast("99"); + Assert.assertArrayEquals(linkedList.toArray(), new String[]{"1", "2", "3", "99"}); + } + + @Test + public void testRemove() { + testAddIndex(); + linkedList.remove(1); + linkedList.remove(2); + linkedList.add(3, "3"); + linkedList.add(1, "2"); + Assert.assertArrayEquals(linkedList.toArray(), new String[]{"8", "2", "10", "3", "3"}); + } + + @Test + public void testRemoveFirst() { + linkedList.removeFirst(); + linkedList.removeFirst(); + Assert.assertArrayEquals(linkedList.toArray(), new String[]{"3"}); + } + + @Test + public void testRemoveLast() { + linkedList.removeLast(); + linkedList.removeLast(); + Assert.assertArrayEquals(linkedList.toArray(), new String[]{"1"}); + } + + @Test + public void testToArray() { + Assert.assertArrayEquals(linkedList.toArray(), new String[]{"1", "2", "3"}); + } + + @Test + public void testToGenericArray() { + Assert.assertArrayEquals(linkedList.toArray(new String[0]), new String[]{"1", "2", "3"}); + } + + @Test + public void testIterator() { + GenericIterator genericIterator = linkedList.iterator(); + while (genericIterator.hasNext()) { + genericIterator.next(); + genericIterator.remove(); + } + Assert.assertArrayEquals(linkedList.toArray(), new String[]{}); + } +} diff --git a/group01/954958168/class01/BasicDataStructure/src/test/java/com/aaront/execrise/generic/GenericQueueTest.java b/group01/954958168/class01/BasicDataStructure/src/test/java/com/aaront/execrise/generic/GenericQueueTest.java new file mode 100644 index 0000000000..6b33a4b3e0 --- /dev/null +++ b/group01/954958168/class01/BasicDataStructure/src/test/java/com/aaront/execrise/generic/GenericQueueTest.java @@ -0,0 +1,33 @@ +package com.aaront.execrise.generic; + +import com.aaront.exercise.generic.GenericQueue; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; + +/** + * @author tonyhui + * @since 17/2/21 + */ +public class GenericQueueTest { + private GenericQueue queue = new GenericQueue<>(); + + @Before + public void init() { + queue.enQueue("1"); + queue.enQueue("2"); + queue.enQueue("3"); + } + + @Test + public void testEnqueue() { + Assert.assertArrayEquals(queue.toArray(), new String[]{"1", "2", "3"}); + } + + @Test + public void testDequeue() { + queue.deQueue(); + queue.deQueue(); + Assert.assertArrayEquals(queue.toArray(), new String[]{"3"}); + } +} diff --git a/group01/954958168/class01/BasicDataStructure/src/test/java/com/aaront/execrise/generic/GenericStackTest.java b/group01/954958168/class01/BasicDataStructure/src/test/java/com/aaront/execrise/generic/GenericStackTest.java new file mode 100644 index 0000000000..0b4b587704 --- /dev/null +++ b/group01/954958168/class01/BasicDataStructure/src/test/java/com/aaront/execrise/generic/GenericStackTest.java @@ -0,0 +1,46 @@ +package com.aaront.execrise.generic; + +import com.aaront.exercise.generic.GenericStack; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; + +/** + * @author tonyhui + * @since 17/2/21 + */ +public class GenericStackTest { + + private GenericStack stack = new GenericStack<>(); + + @Before + public void init() { + stack.push("1"); + stack.push("2"); + stack.push("3"); + } + + @Test + public void testPush() { + Assert.assertArrayEquals(stack.toArray(), new String[]{"1", "2", "3"}); + } + + @Test + public void testPop() { + String element1 = stack.pop(); + Assert.assertEquals(element1, "3"); + String element2 = stack.pop(); + Assert.assertEquals(element2, "2"); + Assert.assertArrayEquals(stack.toArray(), new String[]{"1"}); + } + + @Test + public void testPeek() { + String element1 = stack.peek(); + Assert.assertEquals(element1, "3"); + String element2 = stack.peek(); + Assert.assertEquals(element2, "3"); + Assert.assertArrayEquals(stack.toArray(), new String[]{"1", "2", "3"}); + } + +} From 8758eda26ca7b986290d889ecc9ca7364554b830 Mon Sep 17 00:00:00 2001 From: Korben_CHY Date: Thu, 23 Feb 2017 13:54:12 +0800 Subject: [PATCH 009/518] do not ignore .jar files in Group20 --- group20/.gitignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/group20/.gitignore b/group20/.gitignore index 0979db8ba4..389e717ef0 100644 --- a/group20/.gitignore +++ b/group20/.gitignore @@ -39,3 +39,5 @@ proguard/ # Mac file .DS_Store +# Do not ignore .jar file +!*.jar From f1c0709fb21a2d1adc1cb9801ac868c4d5dce347 Mon Sep 17 00:00:00 2001 From: honokaBiu Date: Thu, 23 Feb 2017 00:50:46 -0500 Subject: [PATCH 010/518] LinkedList --- .../src/SinglyLinkedList/LinkedList0.java | 75 ++++++ .../src/SinglyLinkedList2/LinkedList1.java | 242 ++++++++++++++++++ 2 files changed, 317 insertions(+) create mode 100644 group20/1040154728/1040154728Learning/src/SinglyLinkedList/LinkedList0.java create mode 100644 group20/1040154728/1040154728Learning/src/SinglyLinkedList2/LinkedList1.java diff --git a/group20/1040154728/1040154728Learning/src/SinglyLinkedList/LinkedList0.java b/group20/1040154728/1040154728Learning/src/SinglyLinkedList/LinkedList0.java new file mode 100644 index 0000000000..7cdf1e7f26 --- /dev/null +++ b/group20/1040154728/1040154728Learning/src/SinglyLinkedList/LinkedList0.java @@ -0,0 +1,75 @@ +package SinglyLinkedList; + +/** + * Created by Honoka on 2/16/2017. + */ +public class LinkedList0 { + //Node class represents a list node + private class Node + { + String value; + Node next; + /** + * Constructor + * @param val The element to store in this node. + * @param n The reference to the next node. + */ + Node (String val, Node n) + { + value = val; + next = n; + } + + /** + * Constructor + * @param val The element to store in this node. + */ + Node(String val) + { + value = val; + next = null; + } + } + //Reference to the first node in the list + private Node first = null; + /** + * Constructor + * Builds a linked list + */ + public LinkedList0() + { + //test + first = new Node("Apple"); + first.next = new Node("Peach"); + first.next.next = new Node("Kiwi"); + first = new Node("Blueberry",first); + + //Using an array to add elements into list + String[] fruits = {"Banana", "Cherry"}; + for (String f : fruits) + { + first = new Node(f, first); + } + } + /** + * print method + * traverses the list and prints all elements + */ + public void print() + { + Node reference = first; + while(reference != null) + { + System.out.println(reference.value + " "); + reference = reference.next; + } + } + + //Main test method + public static void main(String [] args) + { + LinkedList0 list = new LinkedList0(); + System.out.println("The elements inside this list are "); + list.print(); + } +} diff --git a/group20/1040154728/1040154728Learning/src/SinglyLinkedList2/LinkedList1.java b/group20/1040154728/1040154728Learning/src/SinglyLinkedList2/LinkedList1.java new file mode 100644 index 0000000000..8c93bbc640 --- /dev/null +++ b/group20/1040154728/1040154728Learning/src/SinglyLinkedList2/LinkedList1.java @@ -0,0 +1,242 @@ +package SinglyLinkedList2; +/** + * Created by Honoka on 2/16/2017. + */ +public class LinkedList1 { + private class Node + { + String value; + Node next; + + Node(String val, Node n) + { + value = val; + next = n; + } + Node(String val) + { + //Call the other(daddy(or sister(whatever))) constructor. + this(val, null); + } + } + + private Node first; // head + private Node last; //the last element in list + + public LinkedList1() + { + first = null; + last = null; + } + + /**This method checks to see + * if the list is empty + * @return true if list is empty + */ + public boolean isEmpty() + { + return first == null; + } + + /** + * size method returns the length of the list + * @return The number of the elements in the list + */ + public int size() + { + int counter = 0; + Node p = first; + while (p != null) + { + counter ++; + p = p.next; + } + return counter; + } + + /** + * add method add an element to the end of the list + * @param element the value to add + */ + public void add(String element) + { + if (isEmpty()) + { + //Obviously, add the element to the first position in the list + first = new Node(element); + last = first; + } + else + { + //add to the end of existing list + last.next = new Node(element); + last = last.next; + } + } + + /** + * add method, or you might call it insert method since it can + * add element to a specific position + * @param index The position at which to add the element + * @param element you should know what is this + */ + public void add (int index, String element) + { + if (index < 0 || index > size()) + { + String message = String.valueOf(index); + throw new IndexOutOfBoundsException(message); + } + + //index is at least 0 + if(index == 0) + { + //new element add to the head + first = new Node(element, first); + if (last == null) + { + last = first; + } + return; + } + //set a reference predecessor to point to the node that + //will be the predecessor of the new node + Node predecessor = first; + for (int k = 1; k <= index - 1; k++) + { + predecessor = predecessor.next; + } + //Splice in a node containing the new element + predecessor.next = new Node(element, predecessor.next); + + //if there is a new last element + if(predecessor.next.next == null) + last = predecessor.next; + } + + /** + * toString method, like print method, hopefully it will display the contents of the list + * @return say something I'm giving up on you( + */ + public String toString() + { + StringBuffer strBuilder = new StringBuffer(); + //Use p to walk down the list + Node p = first; + while (p != null) + { + strBuilder.append(p.value + "\n"); + p = p.next; + } + return strBuilder.toString(); + } + + /** + * remove method removes the element with the position you want + * @param index the position of the element that you want to remove + * @return the removed element + */ + public String remove (int index) + { + /* Index out of bounds */ + if (index < 0 || index >= size()) + { + String message = String.valueOf(index); + throw new IndexOutOfBoundsException(message); + } + String element = null; + if(index == 0) + { + //Removal of first item in the list + element = first.value; + first = first.next; + if (first == null) + { + last = null; + } + } + else + { + /* find the predecessor of the element to be removed */ + Node predecessor = first; + + /* Move predecessor forward index - 1 times */ + for (int k = 1; k <= index - 1; k++) + { + predecessor = predecessor.next; + /* Store the value to return */ + element = predecessor.next.value; + /* Route link around the node to be removed */ + predecessor.next = predecessor.next.next; + /* Check if predecessor is now last */ + if(predecessor.next == null) + { + last = predecessor; + } + } + } + return element; + } + + /** + * The remove method removes an element + * @param element the element to remove + * @return true if the remove succeeded + */ + public boolean remove(String element) + { + if (isEmpty()) + { + return false; + } + + if (element.equals(first.value)) + { + //Removal of first element in the list + first = first.next; + if(first == null) + { + last = null; + } + return true; + } + + /* Find the predecessor of the element to remove */ + Node predecessor = first; + while (predecessor.next != null && + !predecessor.next.value.equals(element)) + { + predecessor = predecessor.next; + } + /* predecessor.next == null OR predecessor.next.value is element */ + if(predecessor.next == null) + { + return false; + } + /* predecessor.next.value is element */ + predecessor.next = predecessor.next.next; + + /* check if predecessor is now last */ + if (predecessor.next == null) + { + last = predecessor; + } + return true; + } + + public static void main (String [] args) + { + LinkedList1 testList = new LinkedList1(); + testList.add("Apple"); + testList.add("Banana"); + testList.add(0,"Blueberry"); + testList.add(2,"Cherry"); + testList.add(4,"Peach"); + System.out.println("The list has : "); + System.out.println(testList); + testList.remove("Cherry"); + testList.remove(2); + System.out.println("The list has : "); + System.out.println(testList); + } +} From 41057016ea7a29fbc746ad429396c4a1fd263ddc Mon Sep 17 00:00:00 2001 From: JayXu Date: Thu, 23 Feb 2017 13:54:26 +0800 Subject: [PATCH 011/518] xuweijay --- .../src/com/coding/basic/ArrayList.java | 66 ++++++++ .../com/coding/basic/BinarySearchTree.java | 130 +++++++++++++++ .../coding/basic/BinarySearchTreeNode.java | 36 +++++ .../coding/basic/BinarySearchTreeTest.java | 83 ++++++++++ .../src/com/coding/basic/Iterator.java | 6 + .../src/com/coding/basic/LinkedList.java | 150 ++++++++++++++++++ .../src/com/coding/basic/List.java | 12 ++ .../src/com/coding/basic/Queue.java | 36 +++++ .../src/com/coding/basic/Stack.java | 38 +++++ 9 files changed, 557 insertions(+) create mode 100644 group15/1511_714512544/src/com/coding/basic/ArrayList.java create mode 100644 group15/1511_714512544/src/com/coding/basic/BinarySearchTree.java create mode 100644 group15/1511_714512544/src/com/coding/basic/BinarySearchTreeNode.java create mode 100644 group15/1511_714512544/src/com/coding/basic/BinarySearchTreeTest.java create mode 100644 group15/1511_714512544/src/com/coding/basic/Iterator.java create mode 100644 group15/1511_714512544/src/com/coding/basic/LinkedList.java create mode 100644 group15/1511_714512544/src/com/coding/basic/List.java create mode 100644 group15/1511_714512544/src/com/coding/basic/Queue.java create mode 100644 group15/1511_714512544/src/com/coding/basic/Stack.java diff --git a/group15/1511_714512544/src/com/coding/basic/ArrayList.java b/group15/1511_714512544/src/com/coding/basic/ArrayList.java new file mode 100644 index 0000000000..3bc92837d1 --- /dev/null +++ b/group15/1511_714512544/src/com/coding/basic/ArrayList.java @@ -0,0 +1,66 @@ +package com.coding.basic; + +import java.util.Arrays; +import java.util.NoSuchElementException; + +public class ArrayList implements List { + private int size = 0; //表内元素个数 + private Object[] elementData = new Object[10]; //数据结构--数组 + + public void add(Object o){ //在后面追加 + if(size == elementData.length) elementData = grow(elementData, 2*elementData.length); //先扩容 + elementData[size++] = o; + } + + public void add(int index, Object o){ //在指定位置插入 + if(size == elementData.length) elementData = grow(elementData, 2*elementData.length); //先扩容 + if(index > size || index < 0) throw new RuntimeException("索引越界"); //保证最后一个元素后面也可以插 + System.arraycopy(elementData,index,elementData,index+1,size-index); + elementData[index] = o; + size ++; + } + + public Object get(int index){ //返回指定索引的元素 + if(index > size - 1 || index < 0) throw new RuntimeException("索引越界"); + return elementData[index]; + } + + public Object remove(int index){ //删除指定索引处的元素 + if(index > size - 1 || index < 0) throw new RuntimeException("索引越界"); + Object o = elementData[index]; + System.arraycopy(elementData,index+1,elementData,index,size-index-1); + elementData[size-1] = null; + size --; + return o; + } + + public int size(){ //元素多少 + return size; + } + + public Iterator iterator(){ //迭代器 + return new ListIterator(); + } + + private class ListIterator implements Iterator{ //实例内部类 + private int i = 0; + + @Override + public boolean hasNext() { + return i < size; + } + + @Override + public Object next() { + if(size() == 0) throw new NoSuchElementException("堆栈下溢"); + return elementData[i++]; + } + } + + //数组扩容 + private Object[] grow(Object[] src, int newLength){ + assert src.length < newLength; //断言 + return Arrays.copyOf(src,newLength); + } + +} diff --git a/group15/1511_714512544/src/com/coding/basic/BinarySearchTree.java b/group15/1511_714512544/src/com/coding/basic/BinarySearchTree.java new file mode 100644 index 0000000000..b875c82b5c --- /dev/null +++ b/group15/1511_714512544/src/com/coding/basic/BinarySearchTree.java @@ -0,0 +1,130 @@ +package com.coding.basic; + +/** + * 二叉树 + 5 + / \ + 2 7 + / \ /\ +1 4 6 8 + + 1.前序遍历: 5 2 1 4 7 6 8 + 2.中序遍历: 1 2 4 5 6 7 8 + 3.后序遍历: 1 4 2 6 8 7 5 + */ +public class BinarySearchTree> { + private BinarySearchTreeNode root; //根节点 + + public BinarySearchTreeNode getRoot() { + return root; + } + + public void setRoot(BinarySearchTreeNode root) { + this.root = root; + } + + /** + * 二叉树插入节点 + * @param data 节点元素 + * @return 插入的节点 + */ + public BinarySearchTreeNode insert(T data){ + if(root == null){ + root = new BinarySearchTreeNode(data); + return root; + } + //root非空 + BinarySearchTreeNode current = root; + while(true){ + //当前节点的数据小于data + if(current.getData().compareTo(data) >= 0){ + if(current.getLeft() != null){ + current = current.getLeft(); + }else { + current.setLeft(new BinarySearchTreeNode(data)); + return current.getLeft(); + } + }else {//当前节点数据大于root + if(current.getRight() != null){ + current = current.getRight(); + }else { + current.setRight(new BinarySearchTreeNode(data)); + return current.getRight(); + } + } + } + } + + /** + * 查找元素data + * @param data 要查找的元素 + * @return 返回true找到、false未找到 + */ + public boolean contains(T data){ + if(root == null){ + return false; + } + BinarySearchTreeNode current = root; + while(true){ + if(current.getData().compareTo(data) > 0){ + if(current.getLeft() != null){ + current = current.getLeft(); + }else{ + return false; + } + }else if(current.getData().compareTo(data) < 0){ + if(current.getRight() != null){ + current = current.getRight(); + }else { + return false; + } + }else { + return true; + } + } + } + + /** + * 前序遍历递归实现 + * @param n 根节点 + */ + public void preOrder(BinarySearchTreeNode n){ + System.out.print(n.getData()+" "); + if(n.getLeft() != null){ + preOrder(n.getLeft()); + } + if(n.getRight() != null){ + preOrder(n.getRight()); + } + } + + /** + * 中序遍历递归实现 + * @param n 根节点 + */ + public void midOrder(BinarySearchTreeNode n){ + if(n.getLeft() != null){ + midOrder(n.getLeft()); + } + System.out.print(n.getData()+" "); + if(n.getRight() != null){ + midOrder(n.getRight()); + } + } + + /** + * 后序遍历递归实现 + * @param n + */ + public void postOrder(BinarySearchTreeNode n){ + if(n.getLeft() != null){ + postOrder(n.getLeft()); + } + if(n.getRight() != null){ + postOrder(n.getRight()); + } + System.out.print(n.getData()+" "); + } + + +} diff --git a/group15/1511_714512544/src/com/coding/basic/BinarySearchTreeNode.java b/group15/1511_714512544/src/com/coding/basic/BinarySearchTreeNode.java new file mode 100644 index 0000000000..68ca1c2d9b --- /dev/null +++ b/group15/1511_714512544/src/com/coding/basic/BinarySearchTreeNode.java @@ -0,0 +1,36 @@ +package com.coding.basic; + +/** + * 二叉树结点 + */ +public class BinarySearchTreeNode{ + private T data; + private BinarySearchTreeNode left; + private BinarySearchTreeNode right; + + public BinarySearchTreeNode(T data) { + this.data = data; + this.left = null; + this.right = null; + } + + public T getData() { + return data; + } + public void setData(T data) { + this.data = data; + } + public BinarySearchTreeNode getLeft() { + return left; + } + public void setLeft(BinarySearchTreeNode left) { + this.left = left; + } + public BinarySearchTreeNode getRight() { + return right; + } + public void setRight(BinarySearchTreeNode right) { + this.right = right; + } + +} diff --git a/group15/1511_714512544/src/com/coding/basic/BinarySearchTreeTest.java b/group15/1511_714512544/src/com/coding/basic/BinarySearchTreeTest.java new file mode 100644 index 0000000000..2da60ab332 --- /dev/null +++ b/group15/1511_714512544/src/com/coding/basic/BinarySearchTreeTest.java @@ -0,0 +1,83 @@ +package com.coding.basic; + +import static org.junit.Assert.*; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +public class BinarySearchTreeTest { + + @Before + public void setUp() throws Exception { + } + + @After + public void tearDown() throws Exception { + } + + @Test + public void testInsert() { + BinarySearchTree bst = new BinarySearchTree(); + bst.insert(5); + bst.insert(2); + bst.insert(7); + bst.insert(1); + bst.insert(6); + bst.insert(4); + bst.insert(8); + } + + @Test + public void testContains() { + BinarySearchTree bst = new BinarySearchTree(); + bst.insert(5); + bst.insert(2); + bst.insert(7); + bst.insert(1); + bst.insert(6); + bst.insert(4); + bst.insert(8); + System.out.println(bst.contains(8)); + } + + @Test + public void testPreOrder(){ + BinarySearchTree bst = new BinarySearchTree(); + bst.insert(5); + bst.insert(2); + bst.insert(7); + bst.insert(1); + bst.insert(6); + bst.insert(4); + bst.insert(8); + bst.preOrder(bst.getRoot()); + } + + @Test + public void testMidOrder(){ + BinarySearchTree bst = new BinarySearchTree(); + bst.insert(5); + bst.insert(2); + bst.insert(7); + bst.insert(1); + bst.insert(6); + bst.insert(4); + bst.insert(8); + bst.midOrder(bst.getRoot()); + } + + @Test + public void testPostOrder(){ + BinarySearchTree bst = new BinarySearchTree(); + bst.insert(5); + bst.insert(2); + bst.insert(7); + bst.insert(1); + bst.insert(6); + bst.insert(4); + bst.insert(8); + bst.postOrder(bst.getRoot()); + } + +} diff --git a/group15/1511_714512544/src/com/coding/basic/Iterator.java b/group15/1511_714512544/src/com/coding/basic/Iterator.java new file mode 100644 index 0000000000..b8c8e0ce6a --- /dev/null +++ b/group15/1511_714512544/src/com/coding/basic/Iterator.java @@ -0,0 +1,6 @@ +package com.coding.basic; + +public interface Iterator { + boolean hasNext(); + Object next(); +} diff --git a/group15/1511_714512544/src/com/coding/basic/LinkedList.java b/group15/1511_714512544/src/com/coding/basic/LinkedList.java new file mode 100644 index 0000000000..3cc3769421 --- /dev/null +++ b/group15/1511_714512544/src/com/coding/basic/LinkedList.java @@ -0,0 +1,150 @@ +package com.coding.basic; + +import java.util.NoSuchElementException; + +public class LinkedList implements List { + private Node head; //数据结构,首节点 + private int size; //节点个数 + + public void add(Object o){ //在链表尾部添加node + if(head == null){ + head = new Node(o, null); + }else { + Node last = head; + while(last.next != null){ + last = last.next; + } + last.next = new Node(o, null); + } + size ++; + } + + public void add(int index , Object o){ //在指定索引处插入node + if(index > size || index < 0) throw new RuntimeException("索引越界"); + if(head == null){ + head = new Node(o, null); + }else { + if(index == 0){ //插入位置在头部 + head = new Node(o, head); + }else { //后面位置 + int i = 0; + Node temp = head; + while(i != index - 1){ + i ++; + temp = temp.next; + } + Node tempNext = temp.next; + temp.next = new Node(o, tempNext); + } + } + size ++; + } + + public Object get(int index){ //取出指定节点处的元素 + if(index > size -1 || index < 0) throw new RuntimeException("索引越界"); + int i = 0; + Node temp = head; + while(i != index){ + i ++; + temp = temp.next; + } + return temp.data; + } + + public Object remove(int index){ //删除指定索引处的节点 + if(index > size -1 || index < 0) throw new RuntimeException("索引越界"); + if(index == 0) { //第一个元素或只有一个元素 + Object o = head.data; + head = head.next; + size --; + return o; + }else { //其他元素 + int i = 0; + Node temp = head; + while(i != index - 1){ + i ++; + temp = temp.next; + } + Node delete = temp.next; + Object o = delete.data; + temp.next = delete.next; + delete = null; + size --; + return o; + } + } + + public int size(){ + return size; + } + + public void addFirst(Object o){ //在表头添加节点 + head = new Node(o, head); + size ++; + } + + public void addLast(Object o){ //在链表尾部添加节点 + if(head == null){ + head = new Node(o,null); + size ++; + return; + } + Node last = head; + while(last.next != null){ + last = last.next; + } + last.next = new Node(o, null); + size ++; + } + + public Object removeFirst(){ //在链表头部删除节点 + if(size() == 0) throw new RuntimeException("堆栈下溢"); + Object o = head.data; + head = head.next; + size --; + return o; + } + + public Object removeLast(){ //在链表尾部删除节点 + if(size() == 0) throw new RuntimeException("堆栈下溢"); + Node last = head; + while(last.next != null){ + last = last.next; + } + Object o = last.data; + size --; + last = null; + return o; + } + + public Iterator iterator(){ //迭代器 + return new ListIterator(); + } + + private class ListIterator implements Iterator{ //实例内部类 + private Node current = head; + + @Override + public boolean hasNext() { + return current != null; + } + + @Override + public Object next() { + if(size() == 0) throw new NoSuchElementException("堆栈下溢"); + Object o = current.data; + current = current.next; + return o; + } + } + + //这里内部类必须为static,这里的每个LinkedList对象都对应唯一的class Node,在类级别上一一对应,非实例级别 + private static class Node{ + Object data; + Node next; + public Node(Object data, Node next) { + this.data = data; + this.next = next; + } + } +} diff --git a/group15/1511_714512544/src/com/coding/basic/List.java b/group15/1511_714512544/src/com/coding/basic/List.java new file mode 100644 index 0000000000..ed7729f25b --- /dev/null +++ b/group15/1511_714512544/src/com/coding/basic/List.java @@ -0,0 +1,12 @@ +package com.coding.basic; + +/** + * 随机访问 + */ +public interface List { + void add(Object o); + void add(int index, Object o); + Object get(int index); + Object remove(int index); + int size(); +} diff --git a/group15/1511_714512544/src/com/coding/basic/Queue.java b/group15/1511_714512544/src/com/coding/basic/Queue.java new file mode 100644 index 0000000000..d362906bb5 --- /dev/null +++ b/group15/1511_714512544/src/com/coding/basic/Queue.java @@ -0,0 +1,36 @@ +package com.coding.basic; + +import java.util.NoSuchElementException; + +/** + * 队列,先进先出 + */ +public class Queue { + private LinkedList list = new LinkedList(); //自己选取数据结构 + + //入队 + public void enQueue(Object o){ + list.addLast(o); + } + + //出队 + public Object deQueue(){ + if(list.size() == 0) throw new NoSuchElementException("队列无元素"); + return list.removeFirst(); + } + + //是否为空 + public boolean isEmpty(){ + return list.size() == 0; + } + + //队列内元素 + public int size(){ + return list.size(); + } + //迭代器 + public Iterator iterator(){ + return list.iterator(); + } + +} diff --git a/group15/1511_714512544/src/com/coding/basic/Stack.java b/group15/1511_714512544/src/com/coding/basic/Stack.java new file mode 100644 index 0000000000..b904cb288c --- /dev/null +++ b/group15/1511_714512544/src/com/coding/basic/Stack.java @@ -0,0 +1,38 @@ +package com.coding.basic; + +import java.util.NoSuchElementException; +//后进先出 +public class Stack { + private ArrayList elementData = new ArrayList(); //使用刚实现的ArrayList + + //入栈 + public void push(Object o){ + elementData.add(o); + } + + //出栈 + public Object pop(){ + if(elementData.size() == 0) throw new NoSuchElementException("堆栈下溢"); + return elementData.remove(elementData.size()-1); + } + + //栈顶元素 + public Object peek(){ + if(elementData.size() == 0) throw new NoSuchElementException("堆栈下溢"); + return elementData.get(elementData.size()-1); + } + + //是否为空 + public boolean isEmpty(){ + return elementData.size() == 0; + } + + //栈内元素个数 + public int size(){ + return elementData.size(); + } + + + + +} From 0a5e381474e3edf8ef167a7748988bab7c839ab8 Mon Sep 17 00:00:00 2001 From: JayXu Date: Thu, 23 Feb 2017 13:57:12 +0800 Subject: [PATCH 012/518] xuweijay --- .../1511_714512544/.idea/checkstyle-idea.xml | 10 ++ group15/1511_714512544/.idea/encodings.xml | 6 + group15/1511_714512544/.idea/misc.xml | 15 +++ group15/1511_714512544/.idea/modules.xml | 8 ++ group15/1511_714512544/.idea/vcs.xml | 6 + group15/1511_714512544/1511_714512544.iml | 20 ++++ .../coding/basic/BinarySearchTreeTest.java | 103 ++++++++++++++++++ 7 files changed, 168 insertions(+) create mode 100644 group15/1511_714512544/.idea/checkstyle-idea.xml create mode 100644 group15/1511_714512544/.idea/encodings.xml create mode 100644 group15/1511_714512544/.idea/misc.xml create mode 100644 group15/1511_714512544/.idea/modules.xml create mode 100644 group15/1511_714512544/.idea/vcs.xml create mode 100644 group15/1511_714512544/1511_714512544.iml create mode 100644 group15/1511_714512544/src/test/com/coding/basic/BinarySearchTreeTest.java diff --git a/group15/1511_714512544/.idea/checkstyle-idea.xml b/group15/1511_714512544/.idea/checkstyle-idea.xml new file mode 100644 index 0000000000..9d5b48d873 --- /dev/null +++ b/group15/1511_714512544/.idea/checkstyle-idea.xml @@ -0,0 +1,10 @@ + + + + + + \ No newline at end of file diff --git a/group15/1511_714512544/.idea/encodings.xml b/group15/1511_714512544/.idea/encodings.xml new file mode 100644 index 0000000000..cfca28230a --- /dev/null +++ b/group15/1511_714512544/.idea/encodings.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/group15/1511_714512544/.idea/misc.xml b/group15/1511_714512544/.idea/misc.xml new file mode 100644 index 0000000000..f45ffd5f26 --- /dev/null +++ b/group15/1511_714512544/.idea/misc.xml @@ -0,0 +1,15 @@ + + + + + + + + + \ No newline at end of file diff --git a/group15/1511_714512544/.idea/modules.xml b/group15/1511_714512544/.idea/modules.xml new file mode 100644 index 0000000000..0ed960e3bf --- /dev/null +++ b/group15/1511_714512544/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/group15/1511_714512544/.idea/vcs.xml b/group15/1511_714512544/.idea/vcs.xml new file mode 100644 index 0000000000..b2bdec2d71 --- /dev/null +++ b/group15/1511_714512544/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/group15/1511_714512544/1511_714512544.iml b/group15/1511_714512544/1511_714512544.iml new file mode 100644 index 0000000000..3ab15b1867 --- /dev/null +++ b/group15/1511_714512544/1511_714512544.iml @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/group15/1511_714512544/src/test/com/coding/basic/BinarySearchTreeTest.java b/group15/1511_714512544/src/test/com/coding/basic/BinarySearchTreeTest.java new file mode 100644 index 0000000000..6181413860 --- /dev/null +++ b/group15/1511_714512544/src/test/com/coding/basic/BinarySearchTreeTest.java @@ -0,0 +1,103 @@ +package test.com.coding.basic; + +import com.coding.basic.BinarySearchTree; +import org.junit.Test; +import org.junit.Before; +import org.junit.After; + +/** +* BinarySearchTree Tester. +* +* @author +* @since
���� 23, 2017
+* @version 1.0 +*/ +public class BinarySearchTreeTest { + +@Before +public void before() throws Exception { +} + +@After +public void after() throws Exception { +} + +/** +* +* Method: getRoot() +* +*/ +@Test +public void testGetRoot() throws Exception { +//TODO: Test goes here... +} + +/** +* +* Method: setRoot(BinarySearchTreeNode root) +* +*/ +@Test +public void testSetRoot() throws Exception { +//TODO: Test goes here... +} + +/** +* +* Method: insert(T data) +* +*/ +@Test +public void testInsert() throws Exception { + BinarySearchTree bst = new BinarySearchTree(); + bst.insert(5); + bst.insert(2); + bst.insert(7); + bst.insert(1); + bst.insert(6); + bst.insert(4); + bst.insert(8); +} + +/** +* +* Method: contains(T data) +* +*/ +@Test +public void testContains() throws Exception { +//TODO: Test goes here... +} + +/** +* +* Method: preOrder(BinarySearchTreeNode n) +* +*/ +@Test +public void testPreOrder() throws Exception { +//TODO: Test goes here... +} + +/** +* +* Method: midOrder(BinarySearchTreeNode n) +* +*/ +@Test +public void testMidOrder() throws Exception { +//TODO: Test goes here... +} + +/** +* +* Method: postOrder(BinarySearchTreeNode n) +* +*/ +@Test +public void testPostOrder() throws Exception { +//TODO: Test goes here... +} + + +} From b8d284ea10ac280ec72450e9e28336757c0cef30 Mon Sep 17 00:00:00 2001 From: cmhello88 Date: Thu, 23 Feb 2017 14:04:59 +0800 Subject: [PATCH 013/518] first load.... --- .../src/com/coding/basic/ArrayList.java | 32 +++++++++++++ .../src/com/coding/basic/BinaryTreeNode.java | 32 +++++++++++++ .../src/com/coding/basic/Iterator.java | 7 +++ .../src/com/coding/basic/LinkedList.java | 46 +++++++++++++++++++ .../src/com/coding/basic/List.java | 9 ++++ .../src/com/coding/basic/Queue.java | 19 ++++++++ .../src/com/coding/basic/Stack.java | 22 +++++++++ 7 files changed, 167 insertions(+) create mode 100644 group03/345943980/2017Learning/src/com/coding/basic/ArrayList.java create mode 100644 group03/345943980/2017Learning/src/com/coding/basic/BinaryTreeNode.java create mode 100644 group03/345943980/2017Learning/src/com/coding/basic/Iterator.java create mode 100644 group03/345943980/2017Learning/src/com/coding/basic/LinkedList.java create mode 100644 group03/345943980/2017Learning/src/com/coding/basic/List.java create mode 100644 group03/345943980/2017Learning/src/com/coding/basic/Queue.java create mode 100644 group03/345943980/2017Learning/src/com/coding/basic/Stack.java diff --git a/group03/345943980/2017Learning/src/com/coding/basic/ArrayList.java b/group03/345943980/2017Learning/src/com/coding/basic/ArrayList.java new file mode 100644 index 0000000000..57412dcf7f --- /dev/null +++ b/group03/345943980/2017Learning/src/com/coding/basic/ArrayList.java @@ -0,0 +1,32 @@ +package com.coding.basic; + +public class ArrayList implements List { + + private int size = 0; + + private Object[] elementData = new Object[100]; + + 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 Iterator iterator(){ + return null; + } + +} diff --git a/group03/345943980/2017Learning/src/com/coding/basic/BinaryTreeNode.java b/group03/345943980/2017Learning/src/com/coding/basic/BinaryTreeNode.java new file mode 100644 index 0000000000..266eff3d56 --- /dev/null +++ b/group03/345943980/2017Learning/src/com/coding/basic/BinaryTreeNode.java @@ -0,0 +1,32 @@ +package com.coding.basic; + +public class BinaryTreeNode { + + private Object data; + private BinaryTreeNode left; + private BinaryTreeNode right; + + public Object getData() { + return data; + } + public void setData(Object data) { + this.data = data; + } + public BinaryTreeNode getLeft() { + return left; + } + public void setLeft(BinaryTreeNode left) { + this.left = left; + } + public BinaryTreeNode getRight() { + return right; + } + public void setRight(BinaryTreeNode right) { + this.right = right; + } + + public BinaryTreeNode insert(Object o){ + return null; + } + +} diff --git a/group03/345943980/2017Learning/src/com/coding/basic/Iterator.java b/group03/345943980/2017Learning/src/com/coding/basic/Iterator.java new file mode 100644 index 0000000000..dbe8b9afb2 --- /dev/null +++ b/group03/345943980/2017Learning/src/com/coding/basic/Iterator.java @@ -0,0 +1,7 @@ +package com.coding.basic; + +public interface Iterator { + public boolean hasNext(); + public Object next(); + +} diff --git a/group03/345943980/2017Learning/src/com/coding/basic/LinkedList.java b/group03/345943980/2017Learning/src/com/coding/basic/LinkedList.java new file mode 100644 index 0000000000..1fd99bf26b --- /dev/null +++ b/group03/345943980/2017Learning/src/com/coding/basic/LinkedList.java @@ -0,0 +1,46 @@ +package com.coding.basic; + +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; + + } +} diff --git a/group03/345943980/2017Learning/src/com/coding/basic/List.java b/group03/345943980/2017Learning/src/com/coding/basic/List.java new file mode 100644 index 0000000000..396b1f6416 --- /dev/null +++ b/group03/345943980/2017Learning/src/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/group03/345943980/2017Learning/src/com/coding/basic/Queue.java b/group03/345943980/2017Learning/src/com/coding/basic/Queue.java new file mode 100644 index 0000000000..08d2d86b14 --- /dev/null +++ b/group03/345943980/2017Learning/src/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/group03/345943980/2017Learning/src/com/coding/basic/Stack.java b/group03/345943980/2017Learning/src/com/coding/basic/Stack.java new file mode 100644 index 0000000000..4bfe28057f --- /dev/null +++ b/group03/345943980/2017Learning/src/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; + } +} From 90a6fb539cb8d325e8cbf306a33a120fdd96639f Mon Sep 17 00:00:00 2001 From: hejj Date: Thu, 23 Feb 2017 14:12:33 +0800 Subject: [PATCH 014/518] wrote a 844028312 file --- group04/844028312/one/.classpath | 6 ++++++ group04/844028312/one/.gitignore | 1 + group04/844028312/one/.project | 17 +++++++++++++++++ 3 files changed, 24 insertions(+) create mode 100644 group04/844028312/one/.classpath create mode 100644 group04/844028312/one/.gitignore create mode 100644 group04/844028312/one/.project diff --git a/group04/844028312/one/.classpath b/group04/844028312/one/.classpath new file mode 100644 index 0000000000..fb5011632c --- /dev/null +++ b/group04/844028312/one/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/group04/844028312/one/.gitignore b/group04/844028312/one/.gitignore new file mode 100644 index 0000000000..ae3c172604 --- /dev/null +++ b/group04/844028312/one/.gitignore @@ -0,0 +1 @@ +/bin/ diff --git a/group04/844028312/one/.project b/group04/844028312/one/.project new file mode 100644 index 0000000000..d674d0dad5 --- /dev/null +++ b/group04/844028312/one/.project @@ -0,0 +1,17 @@ + + + one + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + From af1bebe261e13c594d40b821d5d4c776ecf5e147 Mon Sep 17 00:00:00 2001 From: Administrator Date: Thu, 23 Feb 2017 14:16:18 +0800 Subject: [PATCH 015/518] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E8=87=AA=E5=B7=B1?= =?UTF-8?q?=E7=9A=84=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/com/coding/basic/ArrayList.java | 32 +++++++++++++ .../src/com/coding/basic/BinaryTreeNode.java | 32 +++++++++++++ .../src/com/coding/basic/Iterator.java | 7 +++ .../src/com/coding/basic/LinkedList.java | 46 +++++++++++++++++++ .../423184723/src/com/coding/basic/List.java | 9 ++++ .../423184723/src/com/coding/basic/Queue.java | 19 ++++++++ .../423184723/src/com/coding/basic/Stack.java | 22 +++++++++ 7 files changed, 167 insertions(+) create mode 100644 group20/423184723/src/com/coding/basic/ArrayList.java create mode 100644 group20/423184723/src/com/coding/basic/BinaryTreeNode.java create mode 100644 group20/423184723/src/com/coding/basic/Iterator.java create mode 100644 group20/423184723/src/com/coding/basic/LinkedList.java create mode 100644 group20/423184723/src/com/coding/basic/List.java create mode 100644 group20/423184723/src/com/coding/basic/Queue.java create mode 100644 group20/423184723/src/com/coding/basic/Stack.java diff --git a/group20/423184723/src/com/coding/basic/ArrayList.java b/group20/423184723/src/com/coding/basic/ArrayList.java new file mode 100644 index 0000000000..1f185736f9 --- /dev/null +++ b/group20/423184723/src/com/coding/basic/ArrayList.java @@ -0,0 +1,32 @@ +package com.coding.basic; + +public class ArrayList implements List { + + private int size = 0; + + private Object[] elementData = new Object[100]; + + 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 Iterator iterator(){ + return null; + } + +} diff --git a/group20/423184723/src/com/coding/basic/BinaryTreeNode.java b/group20/423184723/src/com/coding/basic/BinaryTreeNode.java new file mode 100644 index 0000000000..d7ac820192 --- /dev/null +++ b/group20/423184723/src/com/coding/basic/BinaryTreeNode.java @@ -0,0 +1,32 @@ +package com.coding.basic; + +public class BinaryTreeNode { + + private Object data; + private BinaryTreeNode left; + private BinaryTreeNode right; + + public Object getData() { + return data; + } + public void setData(Object data) { + this.data = data; + } + public BinaryTreeNode getLeft() { + return left; + } + public void setLeft(BinaryTreeNode left) { + this.left = left; + } + public BinaryTreeNode getRight() { + return right; + } + public void setRight(BinaryTreeNode right) { + this.right = right; + } + + public BinaryTreeNode insert(Object o){ + return null; + } + +} diff --git a/group20/423184723/src/com/coding/basic/Iterator.java b/group20/423184723/src/com/coding/basic/Iterator.java new file mode 100644 index 0000000000..06ef6311b2 --- /dev/null +++ b/group20/423184723/src/com/coding/basic/Iterator.java @@ -0,0 +1,7 @@ +package com.coding.basic; + +public interface Iterator { + public boolean hasNext(); + public Object next(); + +} diff --git a/group20/423184723/src/com/coding/basic/LinkedList.java b/group20/423184723/src/com/coding/basic/LinkedList.java new file mode 100644 index 0000000000..e2c4e5e795 --- /dev/null +++ b/group20/423184723/src/com/coding/basic/LinkedList.java @@ -0,0 +1,46 @@ +package com.coding.basic; + +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; + + } +} diff --git a/group20/423184723/src/com/coding/basic/List.java b/group20/423184723/src/com/coding/basic/List.java new file mode 100644 index 0000000000..10d13b5832 --- /dev/null +++ b/group20/423184723/src/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/group20/423184723/src/com/coding/basic/Queue.java b/group20/423184723/src/com/coding/basic/Queue.java new file mode 100644 index 0000000000..36e516e266 --- /dev/null +++ b/group20/423184723/src/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/group20/423184723/src/com/coding/basic/Stack.java b/group20/423184723/src/com/coding/basic/Stack.java new file mode 100644 index 0000000000..a5a04de76d --- /dev/null +++ b/group20/423184723/src/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; + } +} From f79d519ce32fa46321510755469a88d6f49d3938 Mon Sep 17 00:00:00 2001 From: mengxz <82427129@qq.com> Date: Thu, 23 Feb 2017 14:23:14 +0800 Subject: [PATCH 016/518] first commit by Walker --- group17/82427129/.gitignore | 7 ++ group17/82427129/JavaUtil/pom.xml | 27 +++++ .../main/java/com/coding/basic/ArrayList.java | 100 ++++++++++++++++++ .../java/com/coding/basic/BinaryTreeNode.java | 32 ++++++ .../main/java/com/coding/basic/Iterator.java | 7 ++ .../java/com/coding/basic/LinkedList.java | 97 +++++++++++++++++ .../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 ++++ 9 files changed, 320 insertions(+) create mode 100644 group17/82427129/.gitignore create mode 100644 group17/82427129/JavaUtil/pom.xml create mode 100644 group17/82427129/JavaUtil/src/main/java/com/coding/basic/ArrayList.java create mode 100644 group17/82427129/JavaUtil/src/main/java/com/coding/basic/BinaryTreeNode.java create mode 100644 group17/82427129/JavaUtil/src/main/java/com/coding/basic/Iterator.java create mode 100644 group17/82427129/JavaUtil/src/main/java/com/coding/basic/LinkedList.java create mode 100644 group17/82427129/JavaUtil/src/main/java/com/coding/basic/List.java create mode 100644 group17/82427129/JavaUtil/src/main/java/com/coding/basic/Queue.java create mode 100644 group17/82427129/JavaUtil/src/main/java/com/coding/basic/Stack.java diff --git a/group17/82427129/.gitignore b/group17/82427129/.gitignore new file mode 100644 index 0000000000..e0db6fed9c --- /dev/null +++ b/group17/82427129/.gitignore @@ -0,0 +1,7 @@ +/.metadata/ +/RemoteSystemsTempFiles/ + +/JavaUtil/.settings/ + +.classpath +.project diff --git a/group17/82427129/JavaUtil/pom.xml b/group17/82427129/JavaUtil/pom.xml new file mode 100644 index 0000000000..6c95dbb077 --- /dev/null +++ b/group17/82427129/JavaUtil/pom.xml @@ -0,0 +1,27 @@ + + 4.0.0 + com.coding.basic + JavaUtil + 0.0.1-SNAPSHOT + + + + org.apache.maven.plugins + maven-compiler-plugin + + 1.7 + 1.7 + + + + + + + junit + junit + 4.7 + test + + + \ No newline at end of file diff --git a/group17/82427129/JavaUtil/src/main/java/com/coding/basic/ArrayList.java b/group17/82427129/JavaUtil/src/main/java/com/coding/basic/ArrayList.java new file mode 100644 index 0000000000..07f92770c9 --- /dev/null +++ b/group17/82427129/JavaUtil/src/main/java/com/coding/basic/ArrayList.java @@ -0,0 +1,100 @@ +package com.coding.basic; + +import java.util.Arrays; + +public class ArrayList implements List { + + private int size = 0; + + private Object[] elementData; + + private static Object[] EMPTY_ELEMENTDATA = {}; + + private static int INITIALCAPACITY = 10; + + public ArrayList(){ + elementData = EMPTY_ELEMENTDATA; + } + + public ArrayList(int initialCapacity){ + elementData = new Object[INITIALCAPACITY]; + } + + public void add(Object o){ + ensureCapacity(size+1); + elementData[size++] = o; + } + + public void add(int index, Object o){ + rangeCheckForAdd(index); + + ensureCapacity(size+1); + System.arraycopy(elementData, index, elementData, index+1, size-index); + elementData[index] = o; + size++; + } + + public Object set(int index, Object o){ + rangeCheck(index); + + Object oldValue = elementData[index]; + elementData[index] = o; + return oldValue; + } + + public Object get(int index){ + rangeCheck(index); + return elementData[index]; + } + + public Object remove(int index){ + rangeCheck(index); + Object oldValue = elementData[index]; + int movedLength = size - index - 1; + if(movedLength > 0)//��Ҫɾ�����һ��Ԫ��ʱ������Ҫ�ƶ����飬ֻ��Ҫ�����һ��Ԫ����null + System.arraycopy(elementData, index+1, elementData, index, size-index-1); + elementData[--size] = null; + return oldValue; + } + + private void rangeCheckForAdd(int index){ + if( index > size || index<0 ){ + throw new IndexOutOfBoundsException(outofIndex(index)); + } + } + private void rangeCheck(int index){ + if( index >= size || index < 0){ + throw new IndexOutOfBoundsException(outofIndex(index)); + } + } + + public int size(){ + return size; + } + + public Iterator iterator(){ + return null; + } + + private void ensureCapacity(int minCapacity){ + if(elementData == EMPTY_ELEMENTDATA){ + minCapacity = Math.max(minCapacity, INITIALCAPACITY);//���addall�״����ӵ������ͱ�INITIALCAPACITY�� + } + if(minCapacity - elementData.length > 0){ + grow(minCapacity); + } + } + + private void grow(int minCapcity){ + int oldCapacity = elementData.length; + int newCapcity = oldCapacity + (oldCapacity>>1); + if(newCapcity - minCapcity < 0){ + newCapcity = minCapcity; + } + elementData = Arrays.copyOf(elementData, newCapcity); + } + + private String outofIndex(int index){ + return "Index: "+index+", Size: "+size; + } +} diff --git a/group17/82427129/JavaUtil/src/main/java/com/coding/basic/BinaryTreeNode.java b/group17/82427129/JavaUtil/src/main/java/com/coding/basic/BinaryTreeNode.java new file mode 100644 index 0000000000..d7ac820192 --- /dev/null +++ b/group17/82427129/JavaUtil/src/main/java/com/coding/basic/BinaryTreeNode.java @@ -0,0 +1,32 @@ +package com.coding.basic; + +public class BinaryTreeNode { + + private Object data; + private BinaryTreeNode left; + private BinaryTreeNode right; + + public Object getData() { + return data; + } + public void setData(Object data) { + this.data = data; + } + public BinaryTreeNode getLeft() { + return left; + } + public void setLeft(BinaryTreeNode left) { + this.left = left; + } + public BinaryTreeNode getRight() { + return right; + } + public void setRight(BinaryTreeNode right) { + this.right = right; + } + + public BinaryTreeNode insert(Object o){ + return null; + } + +} diff --git a/group17/82427129/JavaUtil/src/main/java/com/coding/basic/Iterator.java b/group17/82427129/JavaUtil/src/main/java/com/coding/basic/Iterator.java new file mode 100644 index 0000000000..06ef6311b2 --- /dev/null +++ b/group17/82427129/JavaUtil/src/main/java/com/coding/basic/Iterator.java @@ -0,0 +1,7 @@ +package com.coding.basic; + +public interface Iterator { + public boolean hasNext(); + public Object next(); + +} diff --git a/group17/82427129/JavaUtil/src/main/java/com/coding/basic/LinkedList.java b/group17/82427129/JavaUtil/src/main/java/com/coding/basic/LinkedList.java new file mode 100644 index 0000000000..f651ddabe0 --- /dev/null +++ b/group17/82427129/JavaUtil/src/main/java/com/coding/basic/LinkedList.java @@ -0,0 +1,97 @@ +package com.coding.basic; + +public class LinkedList implements List { + private int size = 0; + + private Node first; + + private Node last; + + public static int getFirst(LinkedList l){ + return l.size; + } + + public void add(Object o){ + + } + public void add(int index , Object o){ + rangeCheck(index); + + final Node succ = indexOf(index); + Node newNode = new Node(succ.prev, o, succ); + succ.prev = newNode; + if(index == size){ + last = newNode; + }else{ + newNode.next = indexOf(index); + indexOf(index).prev = newNode; + } + size++; + } + private void rangeCheck(int index) { + if(index > size|| index < 0 ) + throw new IndexOutOfBoundsException("Size"+size+":index"+index); + } + /** + * ѭ����ȡindex�±�� + * @param index + * @return + */ + private Node indexOf(int index){ + if(index < (this.size>>1) ){ + Node x = first; + for (int i = 0; i < index; i++) { + x = x.next; + } + return x; + }else{ + Node x = last; + for (int i = this.size-1; i > index; i--) { + x = x.prev; + } + return x; + } + } + + public Object get(int index){ + return null; + } + public Object remove(int index){ + return null; + } + + public int size(){ + return size; + } + + 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 class Node{ + Object data; + Node next; + Node prev; + Node(Node prev,Object data,Node next){ + this.data = data; + this.next = next; + this.prev = prev; + } + } +} \ No newline at end of file diff --git a/group17/82427129/JavaUtil/src/main/java/com/coding/basic/List.java b/group17/82427129/JavaUtil/src/main/java/com/coding/basic/List.java new file mode 100644 index 0000000000..10d13b5832 --- /dev/null +++ b/group17/82427129/JavaUtil/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/group17/82427129/JavaUtil/src/main/java/com/coding/basic/Queue.java b/group17/82427129/JavaUtil/src/main/java/com/coding/basic/Queue.java new file mode 100644 index 0000000000..36e516e266 --- /dev/null +++ b/group17/82427129/JavaUtil/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/group17/82427129/JavaUtil/src/main/java/com/coding/basic/Stack.java b/group17/82427129/JavaUtil/src/main/java/com/coding/basic/Stack.java new file mode 100644 index 0000000000..a5a04de76d --- /dev/null +++ b/group17/82427129/JavaUtil/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; + } +} From be853d34d2135a838bd8db390eff49ff74f641bb Mon Sep 17 00:00:00 2001 From: chzh88 Date: Thu, 23 Feb 2017 14:24:07 +0800 Subject: [PATCH 017/518] test --- .gitignore | 9 +++++++++ group19/2558178127/.gitignore | 9 +++++++++ group19/2558178127/src/com/cn/kevin/Test.java | 5 +++++ 3 files changed, 23 insertions(+) create mode 100644 group19/2558178127/.gitignore create mode 100644 group19/2558178127/src/com/cn/kevin/Test.java diff --git a/.gitignore b/.gitignore index ec55baf87d..fcfd185b8c 100644 --- a/.gitignore +++ b/.gitignore @@ -14,3 +14,12 @@ hs_err_pid* #ide config .metadata .recommenders + +*.settings +*.project +*.classpath +*/.settings +*.iml +/.idea +/**/target/**/* + diff --git a/group19/2558178127/.gitignore b/group19/2558178127/.gitignore new file mode 100644 index 0000000000..ee46440140 --- /dev/null +++ b/group19/2558178127/.gitignore @@ -0,0 +1,9 @@ +/bin/ +*.class +*.settings +*.project +*.classpath +*/.settings +*.iml +/.idea +/**/target/**/* diff --git a/group19/2558178127/src/com/cn/kevin/Test.java b/group19/2558178127/src/com/cn/kevin/Test.java new file mode 100644 index 0000000000..f5a6ce104a --- /dev/null +++ b/group19/2558178127/src/com/cn/kevin/Test.java @@ -0,0 +1,5 @@ +package com.cn.kevin; + +public class Test { + +} From 954c7778e8f16531df2c0379180426e44f20db5a Mon Sep 17 00:00:00 2001 From: shaofriend <452472201@qq.com> Date: Thu, 23 Feb 2017 14:27:25 +0800 Subject: [PATCH 018/518] =?UTF-8?q?=E9=87=8D=E6=96=B0=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- group20/452472201/.gitignore | 1 + .../src/com/coding/basic/ArrayList.java | 98 +++++++++++++++++++ .../src/com/coding/basic/BinaryTreeNode.java | 32 ++++++ .../src/com/coding/basic/Iterator.java | 9 ++ .../src/com/coding/basic/LinkedList.java | 46 +++++++++ .../452472201/src/com/coding/basic/List.java | 9 ++ .../452472201/src/com/coding/basic/Queue.java | 19 ++++ .../452472201/src/com/coding/basic/Stack.java | 22 +++++ 8 files changed, 236 insertions(+) create mode 100644 group20/452472201/.gitignore create mode 100644 group20/452472201/src/com/coding/basic/ArrayList.java create mode 100644 group20/452472201/src/com/coding/basic/BinaryTreeNode.java create mode 100644 group20/452472201/src/com/coding/basic/Iterator.java create mode 100644 group20/452472201/src/com/coding/basic/LinkedList.java create mode 100644 group20/452472201/src/com/coding/basic/List.java create mode 100644 group20/452472201/src/com/coding/basic/Queue.java create mode 100644 group20/452472201/src/com/coding/basic/Stack.java diff --git a/group20/452472201/.gitignore b/group20/452472201/.gitignore new file mode 100644 index 0000000000..ae3c172604 --- /dev/null +++ b/group20/452472201/.gitignore @@ -0,0 +1 @@ +/bin/ diff --git a/group20/452472201/src/com/coding/basic/ArrayList.java b/group20/452472201/src/com/coding/basic/ArrayList.java new file mode 100644 index 0000000000..1af26ce934 --- /dev/null +++ b/group20/452472201/src/com/coding/basic/ArrayList.java @@ -0,0 +1,98 @@ +package com.coding.basic; + +public class ArrayList implements List { + + private int size=0; + + private Object[] elementData =new Object[10]; + + + //数组扩容 + private void ensureCapacityInternal(){ + if(size==elementData.length){ + Object[] newArray = new Object[size*2]; + System.arraycopy(elementData, 0, newArray, 0, elementData.length); + elementData=newArray; + } + } + + public void add(Object o){ + ensureCapacityInternal(); + elementData[size]=o; + size++; + } + + public void add(int index, Object o){ + ensureCapacityInternal(); + if(index<0){ + try { + throw new Exception(); + } catch (Exception e) { + e.printStackTrace(); + } + } + + System.arraycopy(elementData, index, elementData, index+1,size-index ); + elementData[index]=o; + size++; + } + + public Object get(int index){ + if(index<0||index>=size){ + try { + throw new Exception(); + } catch (Exception e) { + e.printStackTrace(); + } + } + return elementData[index]; + } + + public Object remove(int index){ + if(index>=size){ + try { + throw new Exception(); + } catch (Exception e) { + e.printStackTrace(); + } + }else{ + + int numMoved=size-index-1; + if(numMoved>0){ + System.arraycopy(elementData, index+1, elementData, index, numMoved); + } + + elementData[size--] = null; + } + return index; + + } + + + public int size(){ + return size; + } + + + private class Iter implements Iterator { + //计数器 + private int coursor=-1; + //判断是否存在下一个 + public boolean hasNext(){ + return coursor+1 Date: Thu, 23 Feb 2017 14:40:34 +0800 Subject: [PATCH 019/518] --- group17/102228177/.classpath | 6 + group17/102228177/.project | 17 +++ .../102228177/bin/data2_19/ArrayList.class | Bin 0 -> 2476 bytes .../bin/data2_19/BinaryTreeNode.class | Bin 0 -> 2283 bytes group17/102228177/bin/data2_19/Iterator.class | Bin 0 -> 168 bytes .../bin/data2_19/LinkedList$Node.class | Bin 0 -> 589 bytes .../102228177/bin/data2_19/LinkedList.class | Bin 0 -> 2573 bytes group17/102228177/bin/data2_19/List.class | Bin 0 -> 245 bytes group17/102228177/bin/data2_19/Queue.class | Bin 0 -> 1390 bytes group17/102228177/bin/data2_19/Stack.class | Bin 0 -> 1520 bytes group17/102228177/src/data2_19/ArrayList.java | 116 ++++++++++++++ .../src/data2_19/BinaryTreeNode.java | 74 +++++++++ group17/102228177/src/data2_19/Iterator.java | 8 + .../102228177/src/data2_19/LinkedList.java | 142 ++++++++++++++++++ group17/102228177/src/data2_19/List.java | 9 ++ group17/102228177/src/data2_19/Queue.java | 38 +++++ group17/102228177/src/data2_19/Stack.java | 44 ++++++ 17 files changed, 454 insertions(+) create mode 100644 group17/102228177/.classpath create mode 100644 group17/102228177/.project create mode 100644 group17/102228177/bin/data2_19/ArrayList.class create mode 100644 group17/102228177/bin/data2_19/BinaryTreeNode.class create mode 100644 group17/102228177/bin/data2_19/Iterator.class create mode 100644 group17/102228177/bin/data2_19/LinkedList$Node.class create mode 100644 group17/102228177/bin/data2_19/LinkedList.class create mode 100644 group17/102228177/bin/data2_19/List.class create mode 100644 group17/102228177/bin/data2_19/Queue.class create mode 100644 group17/102228177/bin/data2_19/Stack.class create mode 100644 group17/102228177/src/data2_19/ArrayList.java create mode 100644 group17/102228177/src/data2_19/BinaryTreeNode.java create mode 100644 group17/102228177/src/data2_19/Iterator.java create mode 100644 group17/102228177/src/data2_19/LinkedList.java create mode 100644 group17/102228177/src/data2_19/List.java create mode 100644 group17/102228177/src/data2_19/Queue.java create mode 100644 group17/102228177/src/data2_19/Stack.java diff --git a/group17/102228177/.classpath b/group17/102228177/.classpath new file mode 100644 index 0000000000..d171cd4c12 --- /dev/null +++ b/group17/102228177/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/group17/102228177/.project b/group17/102228177/.project new file mode 100644 index 0000000000..350a2aab85 --- /dev/null +++ b/group17/102228177/.project @@ -0,0 +1,17 @@ + + + 102228177 + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/group17/102228177/bin/data2_19/ArrayList.class b/group17/102228177/bin/data2_19/ArrayList.class new file mode 100644 index 0000000000000000000000000000000000000000..160f55d10fa8674cee37a60ff17a26ee731d2486 GIT binary patch literal 2476 zcmZuzTXz#x7~Q8yGijL8(v~zeEq8620F@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ZJ_|2=SK zRC@OfB8qqViFm@Jogtl}NV62{EM=M}%sEAEpJ%c~Z5;0@YEeorNp>kh-3aKKWW#3W zv-yDvOE&Y{v5BAYWtF62qrqF0wM!_5!Q%RxzrDmOdLfC$(`~MMSWCcVa=k*XOO)j* zo97aRy@qLA@8CS&;ymBtyhn-Xab~&b+H3xWki1#+KJQ76Qu%Hv*N>cZsk9HNMMK&5 zN~+tp-@_oD^e?|+Af?mwmk^ZwR4x^GflL!Ksh~f0`(wx-HGk|6^?OTmsZbO1*8)^% z{AZkdiSsL?FL2>Gt_)ml;#z97i5pFP-o&jYic+*x6W02hzuFa=rZ`}03&Ucutug!V zvP#NGpu%jik%7bPt6~B7P~uoay+gJ-PnUT=%(23rAuvbL+M#Cq`UeXdggD4OTM6X+ E2NA{D7XSbN literal 0 HcmV?d00001 diff --git a/group17/102228177/bin/data2_19/BinaryTreeNode.class b/group17/102228177/bin/data2_19/BinaryTreeNode.class new file mode 100644 index 0000000000000000000000000000000000000000..9088822d4f510ff17ba4e41b87e6b2ce5d786435 GIT binary patch literal 2283 zcmaKs%TF6u6vn@68ylM;fO!Q12{>)>D>#Iv36Iba9to|%Z9qg(7u8@UW>Pao!&Kqc0?*3E3rArj-zFPPI&8CaK%4NQX_?NF!eH{lNU2@MS|MHxLG)_S(5Dbg zrgo!H=+_WIr$SHOw2ZCl;htgdcxdr_rKp#8b=#D8e>3D9n8ymLq7W$=&Zulp8`7Mlh7{8DKhTd4q+@QMHWa$I9liM7rheqNA#7U5hRw#`YSr(yz%erBC*CQew8@oGXZmn+{J`;#%;!=kW0Xj0X-W1CiKL6XL(W5aSh^3b7f zS_(tSZyLlbN1PYWGovu&0v-KpBNSZS!okJ7MH zpXSB37qqm1NwNp|>)?MtMvkA8fN0%)Qnh?)Jf}AJe}!-BJP+_0OP`}Boq3D+8`pM# z|5q3V^bXN4O3e@QZOF6cQ)1B%!_2~2#Z`>>F>~%a(2@QX@n2{ZfP@QkTY^d$fuMmO zh9ar~E%`vGC;1d(92o5(<(7lO#v?jcJ-NY)I`!UzryJQM;>lTYxBu|!sV z@1UM%&N022PG`??J6msymu8BZOQMJ0N=Y-}In~ni`MQfzeV;O+sF>e5KgmCSl0qhX zhP$EH7-OO1e<7O5zQy>Pw7f~uQ{-HWfM=2LEfTIp!n5dphkMWCbLUw2LwfIZV&3iM zG!b*?#cd+a5N#GW2$SG9Era{Snd54nt3@p10ameuEj(-}r%)@Wz%%I@Q1Hu<{zcF+ z)HT=@Wtz|F=w0EDM39M{l?HbHhGq6JpXuP@43D2>dWUPP$i*t;FY4ME<=p@)oWoV} ztdV=2jebn#CoZ2i=Cjzq7qrtbg)fD#cbQts`yeS_OVM=ZPbl_Tgwi$cOhBtx8Q2&=RkJTmY$pC1d~q literal 0 HcmV?d00001 diff --git a/group17/102228177/bin/data2_19/LinkedList$Node.class b/group17/102228177/bin/data2_19/LinkedList$Node.class new file mode 100644 index 0000000000000000000000000000000000000000..d788f96bca992ae620f269646337c51396c36dc3 GIT binary patch literal 589 zcmZ`$%Syvg5Ixhz#>Uvz)@rSd**< zp?DOQC;VHh+Z)P$OwiN?Lec(PI^~)#pO{j$=ZP{WbLRSPd`>9W|4TF+7HM;L18FRq z$RbBb*Bee2Y{tX_GU`+`p<|JdXV0=Tdg#gUTJ$`rYz2McIU;mbJWXoxof{D-AXqb+ z&Uf2z4DPm}d>91dDj0=*dEu%?s`YeT2Wk@p^V0Wa*!Dye$wA(j}6&={W?U-;T9a(KfkXVwzw xJj#hE3vea_Du7w*Q}KP~C=;1xYl6zJCi42ooGQMyZ<;GMtGX+A}-~Eo+N&>ari% zf8o`ZCEV=7EgF)UY*&M1cl$S%ExXvo=Av`Y`<+AW2HY%Jnx5}FU%&T#pXYgh^oPH` z`4+$ljQinHIFL0|)6eLm_g*yk#br&D>J*!r~1p!_z8-+KTJN zl7eyFGP4RzsfzP$H(lv`)*9iRqJ76wP}2%kXY8C^8dLE0^v?5_bG#9N7vT_s2-QGg ze+V@Q$nHQ0epD-j3Cv2btt?uFIdgHDp6XKhjJZ5-7HoNU4~^1wyQt8x8xn%>npxs( z=t=#X)=2NXAI%B}_hJx06Iun|A%)~F_PYgisQ1p-(6%jvcHv>pChK%bqT^j_Hr_vzqFRQKDlhISh-RKh#`a(0**h&xv{Kc1TN**3K?t4 zmO7Bia7*^6_*4i@=WC|a4`pf3yx6Gflk5;a0ql!4G*pBafCZB?KR1# zi2Bj=6n;L9KN(Xfz3fu@jsB{5@1h{zgyxg>4jAhQerhO9qrqr4vY#X1(D^yBiB{ns z7yiS(s87zxFcJ0b!E-?8qm9{Wr??%Iwu@|!kWV*@vkSfaBoM<8`Y_I#Jx^uc#4*ix z%t2S?dl5Z4&qS=5d+2e}vIM8nvzLQ z2b=FB*i027pCR}d@r4Z>{Z2%g^^S=cUKJTzj8@FpsAD1ZaS7x9KuOv zV1RiWWZs6DkJIEmOe90hr4whLBx~!tSExGg1vPE-ovRDgW$o~vAnu8>;zl{G6 zhW9b>mA&w9Vq!NMM)r$sBEJZqVIv+joJ=~knq{rZN%DbuL2{T~0-Pnuagsbon6ILZ z3FyESfuARh*O!3Op`d-DBB$eH z46&VtbvvbEeY(nARi(;!P|-(Cy5mMrHJN5mgc?z@!vLxTB;Qh&_0_@qManKFYxUHXder*!FiXi-m#?HL|| a5#Db82-%M^st03ug{%DMHSv2EfxiLg>#O$w literal 0 HcmV?d00001 diff --git a/group17/102228177/bin/data2_19/List.class b/group17/102228177/bin/data2_19/List.class new file mode 100644 index 0000000000000000000000000000000000000000..a8d53da1d256bb79a3144df15a71a38b20709614 GIT binary patch literal 245 zcmZvX%L;-}5QhKBTiSJF&v4u%)hgNtg3uyp8z()8VhL(4dbAcjKo1p-(yH3b2lLM` z-#lOU2Y?kO7J7tHENi(uF4lgSR<#A4FwJBm{ajuWe|O4MR1-8A#{^e|-_gc95N0Cy zA83i>} z!c~EenA4;vLtHvDaMVE2`V91=SD>jP%kH*(Xjc?5?uOdxc6GYEc31_m$r!u4ZT@`0vQ>!N~qVa(NG}U(uG0ensk&@7BR@J2ZazqBvTJNfXh@9V2kY z37q6gD3L?(9KjLprLtepmaC&XyZi+y?bScnq@SZfU^7D`ePn0g79t5i56%)Qlt3YT zK7^+gypHo`051}r`^caXsH6jW8|m#FsYCR1NN->P7eYGw8qz2IXh0L`sSk*0yU|_Z zqCQl~2f80r-xR_!zKu{1oLvrC`H&S;EJX=Y3n<-(D6x>zh#W45&hKfhG#vc_!MOgSljDGh=Ii7oWp^0TWy?1x-^PF>@^E@~I{QL4R0GDy!#*{#=?MCjU?=N1d zHzT+8#D*m>``F!c>s{CH)VFsZt5zhCRbACnesrDD0`ra6S=YkQ-EVk|3f63VDlm8G!w+#f`$CvhE{6c!Arx)|&6g8Chbi6}|A zJ%jU=#Az%!*uqU4-v|_ps>wi!hVG%=*STFfBXC>d9F|zI8+JGvg*Ox|kRIq;AmB8E zVc1ePJUwBKG4O(>!4i>DygyU?<7k>E4kmY-C!A@nS-#z5l;B>hzJRPAAouVEW}joO zntG1H?8*O8E@fjz6oty0=!M&DSj(dpJA>x!aLQ6&rq;_ zn1Ib0jXCPdlVa9DF2rdGBmwX)P7zdSHxuxk1iYld`CqWwBP=&!iZ&@~zma+hT6)Y; z;66{0#W9Xj!jWScXA=%upKv@#oLQ`nQ2qtk1DvNf7ycfntZSOo7|jXVTVgRM$J|*= zXfBypktaUyO~SIyUHhNaRs4#y^)&VLHRiNAIyHusoy5|=IG6DOSKZ4xca4?SSQ;fZ zAVygpLrEtn8GMM3lH?(yb-z{*AXw+ejhgi*J{e)XmX7y7@CDm=V}!5cr(1kF9FUTk nu@!dmEc= maxLen){ + grow(); + } + elements[size] = o; + size++; + } + + /** + * 数组扩容 + */ + private void grow(){ + maxLen = maxLen + (maxLen >> 1); + Object[] newArr = new Object[maxLen]; + System.arraycopy(elements, 0, newArr, 0, size); + elements = newArr; + } + + /** + * 在指定索引处添加元素 + * @param i 指定索引 + * @param o 添加元素 + */ + public void add(int i,Object o){ + //判断插入位置大于数组实际长度 + if(i > size){ + size = i; + if(size >= maxLen){//数组大小大于数组最大容量则需要扩容 + grow(); + } + } + //插入位置不大于数组实际长度时,将插入位置的元素向后移。 + for (int j = size; j > i ; j++) { + elements[j] = elements[j-1]; + } + elements[i] = o; + size++; + } + + /** + * 获取传入索引的元素 + * @param index 索引 + * @return 返回传入索引的元素 + */ + public Object get(int index){ + //索引不在实际范围内 + if(index < 0||index >= size){ + throw new ArrayIndexOutOfBoundsException(); + } + for (int i = 0; i < size; i++) { + return elements[index]; + } + return null; + } + + /** + * 删除指定索引元素并返回 + * @param index + * @return 该索引处元素 + */ + public Object remove(int index){ + //索引不在实际范围内 + if(index < 0||index >= size){ + throw new ArrayIndexOutOfBoundsException(); + }else{ + for (int j = index; j < size-1; j++) { + elements[j]=elements[j+1]; + } + size--; + return elements[index]; + } + } + + /** + * 获取大小 + * @return + */ + public int size(){ + return size; + } + +// public Iterator iterator(){ +// return null; +// } + public static void main(String[] args) { + ArrayList list = new ArrayList(); + list.add(0); + list.add(1); + list.add(2); + list.add(3); + list.add(4); + list.add(6, 6); + list.remove(3); + for (int i = 0; i < list.size(); i++) { + System.out.println(i+":"+list.get(i)); + } + } +} diff --git a/group17/102228177/src/data2_19/BinaryTreeNode.java b/group17/102228177/src/data2_19/BinaryTreeNode.java new file mode 100644 index 0000000000..6b091c87b3 --- /dev/null +++ b/group17/102228177/src/data2_19/BinaryTreeNode.java @@ -0,0 +1,74 @@ +package data2_19; + +public class BinaryTreeNode implements Comparable{ + + private Object data; + private BinaryTreeNode left; + private BinaryTreeNode right; + + public BinaryTreeNode(Object o) { + this.data = o; + } + + 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; + } + + @Override + public int compareTo(BinaryTreeNode o) { + return (this.data.hashCode() < o.data.hashCode()) ? -1 : + ((this.data.hashCode() == o.data.hashCode()) ? 0 : 1); + } + + public BinaryTreeNode insert(Object o){ + BinaryTreeNode node = new BinaryTreeNode(o); + insertNode(this,node); + return node; + } + + private void insertNode(BinaryTreeNode parentNode, BinaryTreeNode node) { + //父节点大于添加元素 + if(parentNode.compareTo(node) == 1){ + if(parentNode.left == null){ + parentNode.left = node; + return; + } + insertNode(parentNode.left, node); + } + //父节点小于添加元素 + else + if(parentNode.compareTo(node) == -1){ + if(parentNode.right == null){ + parentNode.right = node; + return; + } + insertNode(parentNode.right, node); + }else{ + throw new RuntimeException("No duplicate vertex allowed!"); + } + } + + public static void main(String[] args) { + BinaryTreeNode tree = new BinaryTreeNode(5); + tree.insert(2); + tree.insert(23); + tree.insert(7); + tree.insert(1); + } + +} \ No newline at end of file diff --git a/group17/102228177/src/data2_19/Iterator.java b/group17/102228177/src/data2_19/Iterator.java new file mode 100644 index 0000000000..6d1fd8a2e3 --- /dev/null +++ b/group17/102228177/src/data2_19/Iterator.java @@ -0,0 +1,8 @@ +package data2_19; + +public interface Iterator { + + public boolean hasNext(); + public Object next(); + +} \ No newline at end of file diff --git a/group17/102228177/src/data2_19/LinkedList.java b/group17/102228177/src/data2_19/LinkedList.java new file mode 100644 index 0000000000..87613d0704 --- /dev/null +++ b/group17/102228177/src/data2_19/LinkedList.java @@ -0,0 +1,142 @@ +package data2_19; + +import java.util.NoSuchElementException; + +public class LinkedList implements List { + + private Node head; + private int size; + + public LinkedList(){ + size = 0; + head = null; + } + + public void add(Object o){ + Node node = new Node(o); + if(head == null){ + head = node; + }else{ + //p为游标 从头遍历到尾 + Node p = head; + while(p.next != null){ + p = p.next; + } + p.next = node; + } + size++; + } + + public void add(int index , Object o){ + //判断不为空链表 + if(head != null){ + Node p = head; + int k = 0; + //扫描单链表查找第index-1个节点 + while(k < index-1 && p.next != null){ + k++; + p = p.next; + } + //判断是否找到第index-1个节点 + if(p != null){ + Node node = new Node(o); + node.next = p.next; + p.next = node; + } + size++; + } + } + + public Object get(int index){ + if(index <0 || index >= size){ + throw new IndexOutOfBoundsException(); + }else{ + Node p = head; + int k = 0; + while(k < index && p.next != null){ + k++; + p = p.next; + } + return p.data; + } + } + public Object remove(int index){ + if(index <0 || index >= size){ + throw new IndexOutOfBoundsException(); + }else{ + if(head != null){ + Node p = head; + int k = 0; + while(k > index-1 && p.next != null){ + k++; + p = p.next; + } + Node next = p.next; + p.next = next.next; + size--; + return next.data; + } + } + return null; + } + + public int size(){ + return size; + } + + public void addFirst(Object o){ + Node node = new Node(o); + node.next = head; + head = node; + size++; + } + + public void addLast(Object o){ + Node node = new Node(o); + if(head == null){ + head = node; + }else{ + Node p = head; + while(p.next != null){ + p = p.next; + } + p.next = node; + } + size++; + } + + public Object removeFirst(){ + if(head == null){ + throw new NoSuchElementException(); + } + Node node = head; + head = node.next; + size--; + return node.data; + } + public Object removeLast(){ + if(head == null){ + throw new NoSuchElementException(); + }else{ + Node p = head; + int k = 0; + while(k < size-1 && p.next != null){ + k++; + p = p.next; + } + Node last = p.next; + p.next = null; + size--; + return last.data; + } + } + + private static class Node{ + Object data; + Node next; + private Node(Object o){ + this.data = o; + this.next = null; + } + } +} \ No newline at end of file diff --git a/group17/102228177/src/data2_19/List.java b/group17/102228177/src/data2_19/List.java new file mode 100644 index 0000000000..95c32f3b27 --- /dev/null +++ b/group17/102228177/src/data2_19/List.java @@ -0,0 +1,9 @@ +package data2_19; + +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(); +} \ No newline at end of file diff --git a/group17/102228177/src/data2_19/Queue.java b/group17/102228177/src/data2_19/Queue.java new file mode 100644 index 0000000000..e945f4a67a --- /dev/null +++ b/group17/102228177/src/data2_19/Queue.java @@ -0,0 +1,38 @@ +package data2_19; +public class Queue { + + private LinkedList linkedList = new LinkedList(); + private int elementCount; + + public Queue() { + this.elementCount = 0; + } + + public void enQueue(Object o){ + linkedList.addLast(o); + elementCount++; + } + + public Object deQueue(){ + Object object = linkedList.removeFirst(); + elementCount--; + return object; + } + + public boolean isEmpty(){ + return elementCount == 0; + } + + public int size(){ + return elementCount; + } + + public static void main(String[] args) { + Queue queue = new Queue(); + queue.enQueue(2); + queue.enQueue(3); + System.out.println(queue.isEmpty()); + System.out.println(queue.size()); + System.out.println(queue.deQueue()); + } +} \ No newline at end of file diff --git a/group17/102228177/src/data2_19/Stack.java b/group17/102228177/src/data2_19/Stack.java new file mode 100644 index 0000000000..2b17605631 --- /dev/null +++ b/group17/102228177/src/data2_19/Stack.java @@ -0,0 +1,44 @@ +package data2_19; + +import java.util.EmptyStackException; + +public class Stack { + private ArrayList elementData; + private int elementCount; + + public Stack() { + this.elementData = new ArrayList(); + this.elementCount = 0; + } + public void push(Object o){ + elementData.add(o); + elementCount++; + } + + public Object pop(){ + Object object = elementData.remove(elementCount-1); + elementCount--; + return object; + } + + public Object peek(){ + if(isEmpty()){ + throw new EmptyStackException(); + } + return elementData.get(elementCount-1); + } + public boolean isEmpty(){ + return elementCount==0; + } + public int size(){ + return elementCount; + } + public static void main(String[] args) { + Stack stack = new Stack(); + stack.push(1); + stack.push(2); + System.out.println(stack.pop()); + System.out.println(stack.peek()); + + } +} \ No newline at end of file From 2a62e4b39dc7b1743ee24536c54f5ef53e33e881 Mon Sep 17 00:00:00 2001 From: byhieg Date: Thu, 23 Feb 2017 14:49:08 +0800 Subject: [PATCH 020/518] =?UTF-8?q?=E5=AE=8C=E6=88=90=E4=BD=9C=E4=B8=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/ArrayList.java" | 102 ++++++++++++ .../src/BinaryTree.java" | 66 ++++++++ .../src/BinaryTreeNode.java" | 42 +++++ .../src/Iterator.java" | 7 + .../src/LinkedList.java" | 152 ++++++++++++++++++ .../src/List.java" | 13 ++ .../src/Queue.java" | 23 +++ .../src/Stack.java" | 36 +++++ .../test/ArrayListTest.java" | 81 ++++++++++ .../test/BinaryTreeTest.java" | 24 +++ .../test/LinkedListTest.java" | 122 ++++++++++++++ .../test/QueueTest.java" | 34 ++++ .../test/StackTest.java" | 52 ++++++ group03/1196051822/README | 2 + 14 files changed, 756 insertions(+) create mode 100644 "group03/1196051822/2\346\234\21026\346\227\245\344\275\234\344\270\232\347\232\204\344\273\243\347\240\201/src/ArrayList.java" create mode 100644 "group03/1196051822/2\346\234\21026\346\227\245\344\275\234\344\270\232\347\232\204\344\273\243\347\240\201/src/BinaryTree.java" create mode 100644 "group03/1196051822/2\346\234\21026\346\227\245\344\275\234\344\270\232\347\232\204\344\273\243\347\240\201/src/BinaryTreeNode.java" create mode 100644 "group03/1196051822/2\346\234\21026\346\227\245\344\275\234\344\270\232\347\232\204\344\273\243\347\240\201/src/Iterator.java" create mode 100644 "group03/1196051822/2\346\234\21026\346\227\245\344\275\234\344\270\232\347\232\204\344\273\243\347\240\201/src/LinkedList.java" create mode 100644 "group03/1196051822/2\346\234\21026\346\227\245\344\275\234\344\270\232\347\232\204\344\273\243\347\240\201/src/List.java" create mode 100644 "group03/1196051822/2\346\234\21026\346\227\245\344\275\234\344\270\232\347\232\204\344\273\243\347\240\201/src/Queue.java" create mode 100644 "group03/1196051822/2\346\234\21026\346\227\245\344\275\234\344\270\232\347\232\204\344\273\243\347\240\201/src/Stack.java" create mode 100644 "group03/1196051822/2\346\234\21026\346\227\245\344\275\234\344\270\232\347\232\204\344\273\243\347\240\201/test/ArrayListTest.java" create mode 100644 "group03/1196051822/2\346\234\21026\346\227\245\344\275\234\344\270\232\347\232\204\344\273\243\347\240\201/test/BinaryTreeTest.java" create mode 100644 "group03/1196051822/2\346\234\21026\346\227\245\344\275\234\344\270\232\347\232\204\344\273\243\347\240\201/test/LinkedListTest.java" create mode 100644 "group03/1196051822/2\346\234\21026\346\227\245\344\275\234\344\270\232\347\232\204\344\273\243\347\240\201/test/QueueTest.java" create mode 100644 "group03/1196051822/2\346\234\21026\346\227\245\344\275\234\344\270\232\347\232\204\344\273\243\347\240\201/test/StackTest.java" create mode 100644 group03/1196051822/README diff --git "a/group03/1196051822/2\346\234\21026\346\227\245\344\275\234\344\270\232\347\232\204\344\273\243\347\240\201/src/ArrayList.java" "b/group03/1196051822/2\346\234\21026\346\227\245\344\275\234\344\270\232\347\232\204\344\273\243\347\240\201/src/ArrayList.java" new file mode 100644 index 0000000000..4a68cd276b --- /dev/null +++ "b/group03/1196051822/2\346\234\21026\346\227\245\344\275\234\344\270\232\347\232\204\344\273\243\347\240\201/src/ArrayList.java" @@ -0,0 +1,102 @@ +package com.byhieg.coding2017; + +import java.util.Arrays; +import java.util.NoSuchElementException; + +public class ArrayList implements List { + + private int size = 0; + + private Object[] elementData = new Object[100]; + + + public void add(Object o) { + isCapacityEnough(size + 1); + elementData[size++] = o; + } + + public void add(int index, Object o) { + checkForAdd(index); + isCapacityEnough(size + 1); + System.arraycopy(elementData,index,elementData,index + 1,size - index); + elementData[index] = o; + size++; + } + + private void checkForAdd(int index){ + if (index < 0 || index > size) { + throw new IndexOutOfBoundsException("index不在指定范围内"); + } + + } + private void isCapacityEnough(int size) { + if (size > 100) { + explicitCapacity(size); + } + if (size < 0) { + throw new OutOfMemoryError(); + } + } + + private final static int MAX_ARRAY_LENGTH = Integer.MAX_VALUE - 8; + + public void explicitCapacity(int size) { + int newLength = elementData.length * 2; + if (newLength > (MAX_ARRAY_LENGTH)){ + newLength = (size > MAX_ARRAY_LENGTH ? Integer.MAX_VALUE : MAX_ARRAY_LENGTH); + } + elementData = Arrays.copyOf(elementData, newLength); + + } + + + public Object get(int index) { + checkRange(index); + return elementData[index]; + } + + private void checkRange(int index){ + if (index < 0 || index >= size) { + throw new IndexOutOfBoundsException("index不在范围内"); + } + } + + public Object remove(int index) { + Object o = get(index); + //要保证后面的 index + 1是有效的 + int moveSize = size - index - 1; + if (moveSize > 0) { + System.arraycopy(elementData,index + 1,elementData,index, size - index); + } + elementData[--size] = null; + return o; + } + + public int size() { + return size; + } + + public Iterator iterator() { + return new MyIterator(); + } + + private class MyIterator implements Iterator { + + private int cursor = 0; + + @Override + public boolean hasNext() { + return cursor != size; + } + + @Override + public Object next() { + if (cursor >= size) { + throw new NoSuchElementException(); + } + return elementData[cursor++]; + } + } + + +} diff --git "a/group03/1196051822/2\346\234\21026\346\227\245\344\275\234\344\270\232\347\232\204\344\273\243\347\240\201/src/BinaryTree.java" "b/group03/1196051822/2\346\234\21026\346\227\245\344\275\234\344\270\232\347\232\204\344\273\243\347\240\201/src/BinaryTree.java" new file mode 100644 index 0000000000..26407d749a --- /dev/null +++ "b/group03/1196051822/2\346\234\21026\346\227\245\344\275\234\344\270\232\347\232\204\344\273\243\347\240\201/src/BinaryTree.java" @@ -0,0 +1,66 @@ +package com.byhieg.coding2017; + +/** + * Created by byhieg on 17/2/22. + * Mail to byhieg@gmail.com + */ + +public class BinaryTree { + + private BinaryTreeNode root = new BinaryTreeNode(); + + public BinaryTree(Object rootData){ + root = root.insert(rootData); + } + + + //左边的值小于等于父节点的值,右边的值大于父节点的值 + private void insertNode(BinaryTreeNode root, BinaryTreeNode node) { + int value = (int)node.getData(); + int rootValue = (int)root.getData(); + if (value <= rootValue){ + insertLeft(root,node); + }else { + insertRight(root,node); + } + } + + + public void insert(Object o) { + BinaryTreeNode node = new BinaryTreeNode(); + node = node.insert(o); + insertNode(root,node); + } + + private void insertLeft(BinaryTreeNode father, BinaryTreeNode node) { + if (father.getLeft() == null) { + father.setLeft(node); + }else{ + insertNode(father.getLeft(),node); + } + } + + private void insertRight(BinaryTreeNode father, BinaryTreeNode node) { + if (father.getRight() == null) { + father.setRight(node); + } else { + insertNode(father.getRight(),node); + } + } + + //前序遍历输出书 + private void preOrder(BinaryTreeNode node) { + if (node != null) { + System.out.println(node.getData()); + preOrder(node.getLeft()); + preOrder(node.getRight()); + } + } + + + //打印树 + public void printTree(){ + preOrder(root); + } + +} diff --git "a/group03/1196051822/2\346\234\21026\346\227\245\344\275\234\344\270\232\347\232\204\344\273\243\347\240\201/src/BinaryTreeNode.java" "b/group03/1196051822/2\346\234\21026\346\227\245\344\275\234\344\270\232\347\232\204\344\273\243\347\240\201/src/BinaryTreeNode.java" new file mode 100644 index 0000000000..67f70bb696 --- /dev/null +++ "b/group03/1196051822/2\346\234\21026\346\227\245\344\275\234\344\270\232\347\232\204\344\273\243\347\240\201/src/BinaryTreeNode.java" @@ -0,0 +1,42 @@ +package com.byhieg.coding2017; + +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) { + BinaryTreeNode node = new BinaryTreeNode(); + int value = (int)o; + node.setData(value); + node.setRight(null); + node.setLeft(null); + return node; + } + +} diff --git "a/group03/1196051822/2\346\234\21026\346\227\245\344\275\234\344\270\232\347\232\204\344\273\243\347\240\201/src/Iterator.java" "b/group03/1196051822/2\346\234\21026\346\227\245\344\275\234\344\270\232\347\232\204\344\273\243\347\240\201/src/Iterator.java" new file mode 100644 index 0000000000..beef5b5554 --- /dev/null +++ "b/group03/1196051822/2\346\234\21026\346\227\245\344\275\234\344\270\232\347\232\204\344\273\243\347\240\201/src/Iterator.java" @@ -0,0 +1,7 @@ +package com.byhieg.coding2017; + +public interface Iterator { + public boolean hasNext(); + public Object next(); + +} diff --git "a/group03/1196051822/2\346\234\21026\346\227\245\344\275\234\344\270\232\347\232\204\344\273\243\347\240\201/src/LinkedList.java" "b/group03/1196051822/2\346\234\21026\346\227\245\344\275\234\344\270\232\347\232\204\344\273\243\347\240\201/src/LinkedList.java" new file mode 100644 index 0000000000..04b3f9f027 --- /dev/null +++ "b/group03/1196051822/2\346\234\21026\346\227\245\344\275\234\344\270\232\347\232\204\344\273\243\347\240\201/src/LinkedList.java" @@ -0,0 +1,152 @@ +package com.byhieg.coding2017; + +import javax.swing.text.html.HTMLDocument; + +public class LinkedList implements List { + + private Node head; + int size = 0; + + public void add(Object o) { + addLast(o); + } + + public void add(int index, Object o) { + checkRangeForAdd(index); + if (index == size) { + addLast(o); + } + Node nextNode = node(index); + Node newNode = new Node(o, nextNode); + + Node prevNode; + if (index == 0) { + prevNode = null; + } else { + prevNode = node(index); + } + + + if (prevNode == null) { + head = newNode; + }else{ + prevNode.next = newNode; + } + + size++; + } + + + private Node node(int index) { + Node cursor = head; + for (int i = 0; i < index; i++) { + cursor = cursor.next; + } + return cursor; + } + + private void checkRangeForAdd(int index) { + if (index > size || index < 0) { + throw new IndexOutOfBoundsException("指定的index超过界限"); + } + } + + public Object get(int index) { + checkRange(index); + return node(index).data; + } + + private void checkRange(int index) { + if (index >= size || index < 0) { + throw new IndexOutOfBoundsException("指定index超过界限"); + } + } + + public Object remove(int index) { + checkRange(index); + Node targetNode = node(index); + Object o = targetNode.data; + Node prevNode ; + Node nextNode = targetNode.next; + + if (index == 0) { + prevNode = null; + }else{ + prevNode = node(index - 1); + } + if (prevNode == null) { + head = nextNode; + targetNode.next = null; + }else { + prevNode.next = nextNode; + targetNode.next = null; + } + + targetNode.data = null; + size --; + return o; + } + + public int size() { + return size; + } + + public void addFirst(Object o) { + Node nextNode = head; + Node newNode = new Node(o, nextNode); + head = newNode; + size++; + } + + public void addLast(Object o) { + Node newNode = new Node(o, null); + if (size == 0) { + head = newNode; + }else{ + Node lastNode = node(size - 1); + lastNode.next = newNode; + } + size++; + } + + public Object removeFirst() { + return remove(0); + } + + public Object removeLast() { + return remove(size() - 1); + } + + public Iterator iterator() { + + return new MyIterator(); + } + + private class MyIterator implements Iterator { + + public Node cursor = head; + @Override + public boolean hasNext() { + return cursor != null; + } + + @Override + public Object next() { + Object o = cursor.data; + cursor = cursor.next; + return o; + } + } + + + + private static class Node { + Object data; + Node next; + + public Node(Object data, Node next) { + this.data = data; + this.next = next; + } + } +} diff --git "a/group03/1196051822/2\346\234\21026\346\227\245\344\275\234\344\270\232\347\232\204\344\273\243\347\240\201/src/List.java" "b/group03/1196051822/2\346\234\21026\346\227\245\344\275\234\344\270\232\347\232\204\344\273\243\347\240\201/src/List.java" new file mode 100644 index 0000000000..15c27c8cf2 --- /dev/null +++ "b/group03/1196051822/2\346\234\21026\346\227\245\344\275\234\344\270\232\347\232\204\344\273\243\347\240\201/src/List.java" @@ -0,0 +1,13 @@ +package com.byhieg.coding2017; + +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/group03/1196051822/2\346\234\21026\346\227\245\344\275\234\344\270\232\347\232\204\344\273\243\347\240\201/src/Queue.java" "b/group03/1196051822/2\346\234\21026\346\227\245\344\275\234\344\270\232\347\232\204\344\273\243\347\240\201/src/Queue.java" new file mode 100644 index 0000000000..f83ad337e7 --- /dev/null +++ "b/group03/1196051822/2\346\234\21026\346\227\245\344\275\234\344\270\232\347\232\204\344\273\243\347\240\201/src/Queue.java" @@ -0,0 +1,23 @@ +package com.byhieg.coding2017; + +public class Queue { + + private LinkedList list = new LinkedList(); + public void enQueue(Object o){ + list.addLast(o); + } + + public Object deQueue() { + Object value = list.get(0); + list.removeFirst(); + return value; + } + + public boolean isEmpty(){ + return size() == 0; + } + + public int size(){ + return list.size(); + } +} diff --git "a/group03/1196051822/2\346\234\21026\346\227\245\344\275\234\344\270\232\347\232\204\344\273\243\347\240\201/src/Stack.java" "b/group03/1196051822/2\346\234\21026\346\227\245\344\275\234\344\270\232\347\232\204\344\273\243\347\240\201/src/Stack.java" new file mode 100644 index 0000000000..45b8530a8f --- /dev/null +++ "b/group03/1196051822/2\346\234\21026\346\227\245\344\275\234\344\270\232\347\232\204\344\273\243\347\240\201/src/Stack.java" @@ -0,0 +1,36 @@ +package com.byhieg.coding2017; + +import java.util.EmptyStackException; + +public class Stack { + private ArrayList elementData = new ArrayList(); + + + + public void push(Object o){ + elementData.add(o); + } + + public Object pop(){ + if (size() == 0) { + throw new EmptyStackException(); + } + Object value = elementData.get(size() - 1); + elementData.remove(size() - 1); + return value; + } + + public Object peek(){ + if (size() == 0) { + throw new EmptyStackException(); + } + return elementData.get(size() - 1); + } + + public boolean isEmpty(){ + return size() == 0; + } + public int size(){ + return elementData.size(); + } +} diff --git "a/group03/1196051822/2\346\234\21026\346\227\245\344\275\234\344\270\232\347\232\204\344\273\243\347\240\201/test/ArrayListTest.java" "b/group03/1196051822/2\346\234\21026\346\227\245\344\275\234\344\270\232\347\232\204\344\273\243\347\240\201/test/ArrayListTest.java" new file mode 100644 index 0000000000..b0b3b6704d --- /dev/null +++ "b/group03/1196051822/2\346\234\21026\346\227\245\344\275\234\344\270\232\347\232\204\344\273\243\347\240\201/test/ArrayListTest.java" @@ -0,0 +1,81 @@ +package com.byhieg.coding2017test; + +import com.byhieg.coding2017.ArrayList; +import com.byhieg.coding2017.Iterator; +import junit.framework.TestCase; + +/** + * Created by byhieg on 17/2/22. + * Mail to byhieg@gmail.com + */ +public class ArrayListTest extends TestCase { + ArrayList arrayList = new ArrayList(); + + public void testAdd() throws Exception { + arrayList.add(1); + arrayList.add(null); + arrayList.add(-1); + arrayList.add("1"); + arrayList.add(true); + arrayList.add(Integer.MAX_VALUE); + arrayList.add(Integer.MIN_VALUE); + + + } + + public void testAdd1() throws Exception { +// arrayList.add(-1,0); +// arrayList.add(100,0); + arrayList.add(0,2); + arrayList.add(1,10); + arrayList.add(2,111); + } + + public void testGet() throws Exception { + for (int i = 0; i < 10 ; i++) { + arrayList.add(i); + } + + for (int i = 0 ; i < 10 ; i++) { + System.out.println(arrayList.get(i)); + } + } + + public void testRemove() throws Exception { + for (int i = 0; i < 10 ; i++) { + arrayList.add(i); + } + + for (int i = 0 ; i < 10 ; i++) { + System.out.println(arrayList.get(i)); + } + + for (int i = 0 ; i < 10 ; i++) { + arrayList.remove(9 - i); + } + + for (int i = 0 ; i < arrayList.size() ; i++) { + System.out.println(arrayList.get(i)); + } + } + + public void testSize() throws Exception { + for (int i = 0; i < 10 ; i++) { + arrayList.add(i); + } + System.out.println(arrayList.size()); + } + + public void testIterator() throws Exception { + for (int i = 0; i < 10 ; i++) { + arrayList.add(i); + } + + System.out.println("开始测试Iterator"); + Iterator iterator = arrayList.iterator(); + while (iterator.hasNext()) { + System.out.println(iterator.next()); + } + } + +} \ No newline at end of file diff --git "a/group03/1196051822/2\346\234\21026\346\227\245\344\275\234\344\270\232\347\232\204\344\273\243\347\240\201/test/BinaryTreeTest.java" "b/group03/1196051822/2\346\234\21026\346\227\245\344\275\234\344\270\232\347\232\204\344\273\243\347\240\201/test/BinaryTreeTest.java" new file mode 100644 index 0000000000..1945f2c695 --- /dev/null +++ "b/group03/1196051822/2\346\234\21026\346\227\245\344\275\234\344\270\232\347\232\204\344\273\243\347\240\201/test/BinaryTreeTest.java" @@ -0,0 +1,24 @@ +package com.byhieg.coding2017test; + +import com.byhieg.coding2017.BinaryTree; +import com.byhieg.coding2017.BinaryTreeNode; +import junit.framework.TestCase; + +/** + * Created by byhieg on 17/2/22. + * Mail to byhieg@gmail.com + */ +public class BinaryTreeTest extends TestCase { + + public void testPrintTree() throws Exception { + BinaryTree tree = new BinaryTree(5); + tree.insert(2); + tree.insert(7); + tree.insert(1); + tree.insert(6); + tree.insert(4); + tree.insert(8); + tree.printTree(); + } + +} \ No newline at end of file diff --git "a/group03/1196051822/2\346\234\21026\346\227\245\344\275\234\344\270\232\347\232\204\344\273\243\347\240\201/test/LinkedListTest.java" "b/group03/1196051822/2\346\234\21026\346\227\245\344\275\234\344\270\232\347\232\204\344\273\243\347\240\201/test/LinkedListTest.java" new file mode 100644 index 0000000000..61a78e150a --- /dev/null +++ "b/group03/1196051822/2\346\234\21026\346\227\245\344\275\234\344\270\232\347\232\204\344\273\243\347\240\201/test/LinkedListTest.java" @@ -0,0 +1,122 @@ +package com.byhieg.coding2017test; + +import com.byhieg.coding2017.Iterator; +import com.byhieg.coding2017.LinkedList; +import com.sun.org.apache.bcel.internal.generic.INEG; +import junit.framework.TestCase; + +/** + * Created by byhieg on 17/2/22. + * Mail to byhieg@gmail.com + */ +public class LinkedListTest extends TestCase { + private LinkedList list = new LinkedList(); + public void testAdd() throws Exception { + list.add(null); + list.add(-1); + list.add(-2); + list.add(0x5); + list.add(true); + list.add("123"); + list.add(Integer.MAX_VALUE + 100000); + + } + + public void testAdd1() throws Exception { +// list.add(-1,100); +// list.add(20,111); + list.add(0,11); + list.add(1,"sad"); + list.add(2,"fas"); + + } + + public void testGet() throws Exception { + for (int i = 0 ; i < 10 ; i++) { + list.add(i,i + ""); + } + + for (int i = 0 ;i < list.size();i++) { + System.out.println(list.get(i)); + } + } + + public void testRemove() throws Exception { + for (int i = 0 ; i < 10 ; i++) { + list.add(i,i + ""); + } + + for (int i = 0 ; i < list.size() ; i++) { + list.remove(i); + } + + for (int i = 0 ;i < list.size();i++) { + System.out.println(list.get(i)); + } + } + + + public void testAddFirst() throws Exception { + list.addFirst("byhieg"); + list.addFirst("123412"); + list.addFirst("byhaieg"); + list.addFirst("byhfadas12ieg"); + list.addFirst("fas"); + for (int i = 0 ; i < list.size();i++) { + System.out.println(list.get(i)); + } + } + + public void testAddLast() throws Exception { + list.addLast("asga"); + list.addLast("124"); + list.addLast("fasd"); + list.addLast("fas"); + list.addLast("gasd2"); + + for (int i = 0 ; i < list.size();i++) { + System.out.println(list.get(i)); + } + + } + + public void testRemoveFirst() throws Exception { + list.addFirst("byhieg"); + list.addFirst("123412"); + list.addFirst("byhaieg"); + list.addFirst("byhfadas12ieg"); + list.addFirst("fas"); + for (int i = 0 ; i < list.size();i++) { + list.removeLast(); + } + + System.out.println(list.size()); + } + + public void testRemoveLast() throws Exception { + list.addLast("asga"); + list.addLast("124"); + list.addLast("fasd"); + list.addLast("fas"); + list.addLast("gasd2"); + for (int i = 0 ; i < list.size();i++) { + list.removeFirst(); + } + + System.out.println(list.size()); + } + + public void testIterator() throws Exception { + list.addLast("asga"); + list.addLast("124"); + list.addLast("fasd"); + list.addLast("fas"); + list.addLast("gasd2"); + + Iterator iterator = list.iterator(); + while (iterator.hasNext()) { + System.out.println(iterator.next()); + } + } + +} \ No newline at end of file diff --git "a/group03/1196051822/2\346\234\21026\346\227\245\344\275\234\344\270\232\347\232\204\344\273\243\347\240\201/test/QueueTest.java" "b/group03/1196051822/2\346\234\21026\346\227\245\344\275\234\344\270\232\347\232\204\344\273\243\347\240\201/test/QueueTest.java" new file mode 100644 index 0000000000..82d0fe2349 --- /dev/null +++ "b/group03/1196051822/2\346\234\21026\346\227\245\344\275\234\344\270\232\347\232\204\344\273\243\347\240\201/test/QueueTest.java" @@ -0,0 +1,34 @@ +package com.byhieg.coding2017test; + +import com.byhieg.coding2017.Queue; +import junit.framework.TestCase; + +/** + * Created by byhieg on 17/2/22. + * Mail to byhieg@gmail.com + */ +public class QueueTest extends TestCase { + Queue queue = new Queue(); + + public void testEnQueue() throws Exception { + queue.enQueue(1); + queue.enQueue("true"); + queue.enQueue(true); + queue.enQueue(null); + queue.enQueue(-12341); + queue.enQueue(Integer.MIN_VALUE - 10000); + + } + + public void testDeQueue() throws Exception { + for (int i = 0 ; i < 10 ; i++) { + queue.enQueue(i); + } + + while (!queue.isEmpty()) { + System.out.println(queue.deQueue()); + } + } + + +} \ No newline at end of file diff --git "a/group03/1196051822/2\346\234\21026\346\227\245\344\275\234\344\270\232\347\232\204\344\273\243\347\240\201/test/StackTest.java" "b/group03/1196051822/2\346\234\21026\346\227\245\344\275\234\344\270\232\347\232\204\344\273\243\347\240\201/test/StackTest.java" new file mode 100644 index 0000000000..a81484251c --- /dev/null +++ "b/group03/1196051822/2\346\234\21026\346\227\245\344\275\234\344\270\232\347\232\204\344\273\243\347\240\201/test/StackTest.java" @@ -0,0 +1,52 @@ +package com.byhieg.coding2017test; + +import com.byhieg.coding2017.Stack; +import junit.framework.TestCase; + +/** + * Created by byhieg on 17/2/22. + * Mail to byhieg@gmail.com + */ +public class StackTest extends TestCase { + Stack stack = new Stack(); + + public void testPush() throws Exception { + stack.push(1); + stack.push("31231"); + stack.push(null); + stack.push(Integer.MAX_VALUE + 1000); + stack.push(Integer.MIN_VALUE - 1000000); + stack.push(true); + stack.push('a'); + } + + public void testPop() throws Exception { + int a = 1; + for (int i = 0; i < 10; i++) { + stack.push(a + i); + } + int size = stack.size(); + while (!stack.isEmpty()){ + System.out.println(stack.pop()); + } + } + + public void testPeek() throws Exception { + char a = 'a'; + for (int i = 0; i < 10; i++) { + stack.push(a + i); + } + + System.out.println("size的大小是" + stack.size()); + System.out.println(stack.peek()); + } + + public void testIsEmpty() throws Exception { + System.out.println(stack.isEmpty()); + stack.push(1); + System.out.println(stack.isEmpty()); + + } + + +} \ No newline at end of file diff --git a/group03/1196051822/README b/group03/1196051822/README new file mode 100644 index 0000000000..c7b21c2ef0 --- /dev/null +++ b/group03/1196051822/README @@ -0,0 +1,2 @@ +# 作业文件夹说明 +src文件夹存放是的作业源码的文件,test文件夹存放的是源码相应的测试文件 From 0ef1bac0f1b8cf72f13c5e4d14bdfdd9f4197f09 Mon Sep 17 00:00:00 2001 From: leijing Date: Thu, 23 Feb 2017 14:59:10 +0800 Subject: [PATCH 021/518] =?UTF-8?q?=E5=88=9B=E5=BB=BA764189149=E7=9A=84?= =?UTF-8?q?=E7=9B=AE=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 创建764189149的目录 --- group07/764189149/.classpath | 6 + group07/764189149/.gitignore | 23 ++ group07/764189149/.project | 17 ++ .../src/firstHomeWork/util/ArrayList.java | 197 ++++++++++++++++++ .../src/firstHomeWork/util/Iterator.java | 30 +++ .../src/firstHomeWork/util/List.java | 87 ++++++++ 6 files changed, 360 insertions(+) create mode 100644 group07/764189149/.classpath create mode 100644 group07/764189149/.gitignore create mode 100644 group07/764189149/.project create mode 100644 group07/764189149/src/firstHomeWork/util/ArrayList.java create mode 100644 group07/764189149/src/firstHomeWork/util/Iterator.java create mode 100644 group07/764189149/src/firstHomeWork/util/List.java diff --git a/group07/764189149/.classpath b/group07/764189149/.classpath new file mode 100644 index 0000000000..fb5011632c --- /dev/null +++ b/group07/764189149/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/group07/764189149/.gitignore b/group07/764189149/.gitignore new file mode 100644 index 0000000000..8d9372e204 --- /dev/null +++ b/group07/764189149/.gitignore @@ -0,0 +1,23 @@ +# Compiled class file +*.class + +# Log file +*.log + +# BlueJ files +*.ctxt + +# Mobile Tools for Java (J2ME) +.mtj.tmp/ + +# Package Files # +*.jar +*.war +*.ear +*.zip +*.tar.gz +*.rar + +# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml +hs_err_pid* +/bin/ diff --git a/group07/764189149/.project b/group07/764189149/.project new file mode 100644 index 0000000000..2076c6b51c --- /dev/null +++ b/group07/764189149/.project @@ -0,0 +1,17 @@ + + + 764189149Learning + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/group07/764189149/src/firstHomeWork/util/ArrayList.java b/group07/764189149/src/firstHomeWork/util/ArrayList.java new file mode 100644 index 0000000000..88b97d828f --- /dev/null +++ b/group07/764189149/src/firstHomeWork/util/ArrayList.java @@ -0,0 +1,197 @@ +package firstHomeWork.util; + +import java.util.NoSuchElementException; + +/** + * @Description: 基于数组的列表 + * @author: leijing + * @date: 2017年2月21日 下午9:03:17 + * @param + */ +public class ArrayList implements List { + private static int initialCapacity = 10 ;//数组默认初始容量 + Object[] elements;//元素的数组 + private int size;//元素的个数 + + public ArrayList(){ + this(initialCapacity); + } + public ArrayList(int capacity){ + elements = new Object[capacity]; + } + private void ensureCapacity(int minCapacity){ + if(minCapacity > 0){ + + } + } + @Override + public boolean add(E e) { + ensureCapacity(size + 1); + elements[size++] = e; + return true; + } + + @Override + public E remove(int index) { + rangeCheck(index); + E oldElement = (E) elements[index]; + //将其后的元素前移 + int needMovedNum = size - index - 1; + move(elements, index+1, elements,index, needMovedNum); + size--; + return oldElement; + } + + /** + * @Description: 移动数组中的元素 + * @param src 原数组 + * @param from 复制元素起始下标 + * @param dest 目标元素数组 + * @param num 要复制的元素个数 + * @return: void + * @author: leijing + * @date: 2017年2月22日 下午7:54:08 + */ + private void move(Object[] src , int srcPosition , Object[] dest , int destPosition, int num){ + for(int i = 0 ; i < num ; i ++){ + dest[destPosition++] = src[srcPosition++]; + } + } + + /** + * @Description: 检查下标是否正确,如果越界抛出异常 + * @param index + * @return: void + * @author: leijing + * @date: 2017年2月22日 下午7:52:59 + */ + private void rangeCheck(int index){ + if(index < 0 || index > size){ + throw new IndexOutOfBoundsException(); + } + } + + @Override + public boolean remove(Object o) { + if(o == null){ + for (int index = 0; index < size; index++) { + if(elements[index] == null){ + remove(index); + return true; + } + } + }else{ + for (int index = 0; index < size; index++) { + if(o.equals(elements[index])){ + remove(index); + return true; + } + } + } + return false; + } + + @Override + public int size() { + return size; + } + + @Override + public boolean isEmpty() { + return size == 0; + } + + @Override + public E get(int index) { + rangeCheck(index); + return (E) elements[index]; + } + + @Override + public E set(int index, E e) { + rangeCheck(index); + E oldElement = (E) elements[index]; + elements[index] = e; + return oldElement; + } + + @Override + public boolean contains(Object o) { + return indexOf(o) >= 0; + } + + private int indexOf(Object o){ + if(o == null){ + for (int index = 0; index < size; index++) { + if(elements[index] == null){ + return index; + } + } + }else{ + for (int index = 0; index < size; index++) { + if(o.equals(elements[index])){ + return index; + } + } + } + return -1; + } + + @Override + public void clear() { + for (int index = 0; index < size; index++) { + elements[index] = null; + } + size = 0; + } + + @Override + public Iterator iterator() { + return new ArraylistIterator(); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + for (int index = 0; index < size; index++) { + if(index == size -1){ + sb.append(elements[index]); + }else{ + sb.append(elements[index]).append(","); + } + + } + return sb.toString(); + } + private class ArraylistIterator implements Iterator{ + private int position; + + @Override + public boolean hasNext() { + return position != size; + } + + @Override + public E next() { + Object[] elements = ArrayList.this.elements; + int i = position; + if(i >= size){ + throw new NoSuchElementException(); + } + position = i + 1; + return (E) elements[i+1]; + } + + @Override + public void remove() { + if(position > size){ + throw new NoSuchElementException(); + } + ArrayList.this.remove(position); + } + + } + + + +} diff --git a/group07/764189149/src/firstHomeWork/util/Iterator.java b/group07/764189149/src/firstHomeWork/util/Iterator.java new file mode 100644 index 0000000000..ecbf3015e0 --- /dev/null +++ b/group07/764189149/src/firstHomeWork/util/Iterator.java @@ -0,0 +1,30 @@ +package firstHomeWork.util; + +/** + * @Description: 迭代器 + * @author: leijing + * @date: 2017年2月21日 下午8:49:10 + * @param + */ +public interface Iterator { + /** + * @Description: 返回迭代器中是否有下一个元素 + * @return: boolean + * @author: leijing + * @date: 2017年2月21日 下午8:49:52 + */ + boolean hasNext(); + /** + * @Description: 返回迭代器中的下一个元素 + * @return: E + * @author: leijing + * @date: 2017年2月21日 下午8:50:35 + */ + E next(); + /** + * @Description: 删除迭代器中的当前元素 + * @author: leijing + * @date: 2017年2月21日 下午8:51:07 + */ + void remove(); +} diff --git a/group07/764189149/src/firstHomeWork/util/List.java b/group07/764189149/src/firstHomeWork/util/List.java new file mode 100644 index 0000000000..fac6efa0cc --- /dev/null +++ b/group07/764189149/src/firstHomeWork/util/List.java @@ -0,0 +1,87 @@ +package firstHomeWork.util; + +/** + * @Description: 定义一组操作有序列表的接口 + * @author: leijing + * @date: 2017年2月21日 下午8:53:52 + * @param + */ +public interface List { + /** + * @Description: 添加元素 + * @param e + * @return: boolean + * @author: leijing + * @date: 2017年2月21日 下午8:55:32 + */ + boolean add(E e); + /** + * @Description: 删除指定索引的元素 + * @param index + * @return: E + * @author: leijing + * @date: 2017年2月21日 下午8:56:08 + */ + E remove(int index); + /** + * @Description: 删除元素 + * @param o + * @return: boolean + * @author: leijing + * @date: 2017年2月21日 下午8:56:28 + */ + boolean remove(Object o); + /** + * @Description: 返回元素个数 + * @return: int + * @author: leijing + * @date: 2017年2月21日 下午8:57:25 + */ + int size(); + /** + * @Description: 判断集合是否为空 + * @return: boolean + * @author: leijing + * @date: 2017年2月21日 下午8:57:51 + */ + boolean isEmpty(); + /** + * @Description: 获取指定位置的元素 + * @param index + * @return: E + * @author: leijing + * @date: 2017年2月21日 下午8:58:27 + */ + E get(int index); + /** + * @Description: 设置指定位置的元素 + * @param index + * @param e + * @return: E + * @author: leijing + * @date: 2017年2月21日 下午8:58:58 + */ + E set(int index , E e); + /** + * @Description: 判断集合是否包含某个元素 + * @param o + * @return: boolean + * @author: leijing + * @date: 2017年2月21日 下午8:59:32 + */ + boolean contains(Object o); + /** + * @Description: 清空集合 + * @return: void + * @author: leijing + * @date: 2017年2月21日 下午9:00:12 + */ + void clear(); + /** + * @Description: 获取集合的迭代器 + * @return: Iterator + * @author: leijing + * @date: 2017年2月21日 下午9:00:47 + */ + Iterator iterator(); +} From 418ba9019dd9cda3409f9b7474018de2cb8106f7 Mon Sep 17 00:00:00 2001 From: leijing Date: Thu, 23 Feb 2017 15:04:30 +0800 Subject: [PATCH 022/518] =?UTF-8?q?=E5=88=9B=E5=BB=BA=E5=90=84=E4=B8=AA?= =?UTF-8?q?=E7=BB=84=E5=91=98=E7=9A=84=E7=9B=AE=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 创建各个组员的目录 --- "group07/1046545622/git\345\221\275\344\273\244.txt" | 11 +++++++++++ "group07/1058267830/git\345\221\275\344\273\244.txt" | 11 +++++++++++ "group07/1070440331/git\345\221\275\344\273\244.txt" | 11 +++++++++++ "group07/1280157271/git\345\221\275\344\273\244.txt" | 11 +++++++++++ "group07/1448276993/git\345\221\275\344\273\244.txt" | 11 +++++++++++ "group07/1519504320/git\345\221\275\344\273\244.txt" | 11 +++++++++++ "group07/1520332119/git\345\221\275\344\273\244.txt" | 11 +++++++++++ "group07/1536161030/git\345\221\275\344\273\244.txt" | 11 +++++++++++ "group07/178007127/git\345\221\275\344\273\244.txt" | 11 +++++++++++ "group07/20409287/git\345\221\275\344\273\244.txt" | 11 +++++++++++ "group07/2306826375/git\345\221\275\344\273\244.txt" | 11 +++++++++++ "group07/2708094737/git\345\221\275\344\273\244.txt" | 11 +++++++++++ "group07/2915553181/git\345\221\275\344\273\244.txt" | 11 +++++++++++ "group07/328536398/git\345\221\275\344\273\244.txt" | 11 +++++++++++ "group07/396868934/git\345\221\275\344\273\244.txt" | 11 +++++++++++ "group07/43819473/git\345\221\275\344\273\244.txt" | 11 +++++++++++ "group07/466199956/git\345\221\275\344\273\244.txt" | 11 +++++++++++ "group07/476770768/git\345\221\275\344\273\244.txt" | 11 +++++++++++ "group07/515372252/git\345\221\275\344\273\244.txt" | 11 +++++++++++ "group07/562247675/git\345\221\275\344\273\244.txt" | 11 +++++++++++ "group07/598812995/git\345\221\275\344\273\244.txt" | 11 +++++++++++ "group07/603622009/git\345\221\275\344\273\244.txt" | 11 +++++++++++ "group07/724319952/git\345\221\275\344\273\244.txt" | 11 +++++++++++ "group07/752262774/git\345\221\275\344\273\244.txt" | 11 +++++++++++ "group07/770164810/git\345\221\275\344\273\244.txt" | 11 +++++++++++ 25 files changed, 275 insertions(+) create mode 100644 "group07/1046545622/git\345\221\275\344\273\244.txt" create mode 100644 "group07/1058267830/git\345\221\275\344\273\244.txt" create mode 100644 "group07/1070440331/git\345\221\275\344\273\244.txt" create mode 100644 "group07/1280157271/git\345\221\275\344\273\244.txt" create mode 100644 "group07/1448276993/git\345\221\275\344\273\244.txt" create mode 100644 "group07/1519504320/git\345\221\275\344\273\244.txt" create mode 100644 "group07/1520332119/git\345\221\275\344\273\244.txt" create mode 100644 "group07/1536161030/git\345\221\275\344\273\244.txt" create mode 100644 "group07/178007127/git\345\221\275\344\273\244.txt" create mode 100644 "group07/20409287/git\345\221\275\344\273\244.txt" create mode 100644 "group07/2306826375/git\345\221\275\344\273\244.txt" create mode 100644 "group07/2708094737/git\345\221\275\344\273\244.txt" create mode 100644 "group07/2915553181/git\345\221\275\344\273\244.txt" create mode 100644 "group07/328536398/git\345\221\275\344\273\244.txt" create mode 100644 "group07/396868934/git\345\221\275\344\273\244.txt" create mode 100644 "group07/43819473/git\345\221\275\344\273\244.txt" create mode 100644 "group07/466199956/git\345\221\275\344\273\244.txt" create mode 100644 "group07/476770768/git\345\221\275\344\273\244.txt" create mode 100644 "group07/515372252/git\345\221\275\344\273\244.txt" create mode 100644 "group07/562247675/git\345\221\275\344\273\244.txt" create mode 100644 "group07/598812995/git\345\221\275\344\273\244.txt" create mode 100644 "group07/603622009/git\345\221\275\344\273\244.txt" create mode 100644 "group07/724319952/git\345\221\275\344\273\244.txt" create mode 100644 "group07/752262774/git\345\221\275\344\273\244.txt" create mode 100644 "group07/770164810/git\345\221\275\344\273\244.txt" diff --git "a/group07/1046545622/git\345\221\275\344\273\244.txt" "b/group07/1046545622/git\345\221\275\344\273\244.txt" new file mode 100644 index 0000000000..6b9ddc2f28 --- /dev/null +++ "b/group07/1046545622/git\345\221\275\344\273\244.txt" @@ -0,0 +1,11 @@ +��װgit gui��������git bash���� +1.��¡ +git clone git@github.com:michaelliao/gitskills.git +2.�����޸ĵ��ļ� +git add -A +3.�ύ���ݴ��� +git commit -m "�ύ***����" +4.����master +git pull origin master +5.�ύ��master +git push origin master \ No newline at end of file diff --git "a/group07/1058267830/git\345\221\275\344\273\244.txt" "b/group07/1058267830/git\345\221\275\344\273\244.txt" new file mode 100644 index 0000000000..6b9ddc2f28 --- /dev/null +++ "b/group07/1058267830/git\345\221\275\344\273\244.txt" @@ -0,0 +1,11 @@ +��װgit gui��������git bash���� +1.��¡ +git clone git@github.com:michaelliao/gitskills.git +2.�����޸ĵ��ļ� +git add -A +3.�ύ���ݴ��� +git commit -m "�ύ***����" +4.����master +git pull origin master +5.�ύ��master +git push origin master \ No newline at end of file diff --git "a/group07/1070440331/git\345\221\275\344\273\244.txt" "b/group07/1070440331/git\345\221\275\344\273\244.txt" new file mode 100644 index 0000000000..6b9ddc2f28 --- /dev/null +++ "b/group07/1070440331/git\345\221\275\344\273\244.txt" @@ -0,0 +1,11 @@ +��װgit gui��������git bash���� +1.��¡ +git clone git@github.com:michaelliao/gitskills.git +2.�����޸ĵ��ļ� +git add -A +3.�ύ���ݴ��� +git commit -m "�ύ***����" +4.����master +git pull origin master +5.�ύ��master +git push origin master \ No newline at end of file diff --git "a/group07/1280157271/git\345\221\275\344\273\244.txt" "b/group07/1280157271/git\345\221\275\344\273\244.txt" new file mode 100644 index 0000000000..6b9ddc2f28 --- /dev/null +++ "b/group07/1280157271/git\345\221\275\344\273\244.txt" @@ -0,0 +1,11 @@ +��װgit gui��������git bash���� +1.��¡ +git clone git@github.com:michaelliao/gitskills.git +2.�����޸ĵ��ļ� +git add -A +3.�ύ���ݴ��� +git commit -m "�ύ***����" +4.����master +git pull origin master +5.�ύ��master +git push origin master \ No newline at end of file diff --git "a/group07/1448276993/git\345\221\275\344\273\244.txt" "b/group07/1448276993/git\345\221\275\344\273\244.txt" new file mode 100644 index 0000000000..6b9ddc2f28 --- /dev/null +++ "b/group07/1448276993/git\345\221\275\344\273\244.txt" @@ -0,0 +1,11 @@ +��װgit gui��������git bash���� +1.��¡ +git clone git@github.com:michaelliao/gitskills.git +2.�����޸ĵ��ļ� +git add -A +3.�ύ���ݴ��� +git commit -m "�ύ***����" +4.����master +git pull origin master +5.�ύ��master +git push origin master \ No newline at end of file diff --git "a/group07/1519504320/git\345\221\275\344\273\244.txt" "b/group07/1519504320/git\345\221\275\344\273\244.txt" new file mode 100644 index 0000000000..6b9ddc2f28 --- /dev/null +++ "b/group07/1519504320/git\345\221\275\344\273\244.txt" @@ -0,0 +1,11 @@ +��װgit gui��������git bash���� +1.��¡ +git clone git@github.com:michaelliao/gitskills.git +2.�����޸ĵ��ļ� +git add -A +3.�ύ���ݴ��� +git commit -m "�ύ***����" +4.����master +git pull origin master +5.�ύ��master +git push origin master \ No newline at end of file diff --git "a/group07/1520332119/git\345\221\275\344\273\244.txt" "b/group07/1520332119/git\345\221\275\344\273\244.txt" new file mode 100644 index 0000000000..6b9ddc2f28 --- /dev/null +++ "b/group07/1520332119/git\345\221\275\344\273\244.txt" @@ -0,0 +1,11 @@ +��װgit gui��������git bash���� +1.��¡ +git clone git@github.com:michaelliao/gitskills.git +2.�����޸ĵ��ļ� +git add -A +3.�ύ���ݴ��� +git commit -m "�ύ***����" +4.����master +git pull origin master +5.�ύ��master +git push origin master \ No newline at end of file diff --git "a/group07/1536161030/git\345\221\275\344\273\244.txt" "b/group07/1536161030/git\345\221\275\344\273\244.txt" new file mode 100644 index 0000000000..6b9ddc2f28 --- /dev/null +++ "b/group07/1536161030/git\345\221\275\344\273\244.txt" @@ -0,0 +1,11 @@ +��װgit gui��������git bash���� +1.��¡ +git clone git@github.com:michaelliao/gitskills.git +2.�����޸ĵ��ļ� +git add -A +3.�ύ���ݴ��� +git commit -m "�ύ***����" +4.����master +git pull origin master +5.�ύ��master +git push origin master \ No newline at end of file diff --git "a/group07/178007127/git\345\221\275\344\273\244.txt" "b/group07/178007127/git\345\221\275\344\273\244.txt" new file mode 100644 index 0000000000..6b9ddc2f28 --- /dev/null +++ "b/group07/178007127/git\345\221\275\344\273\244.txt" @@ -0,0 +1,11 @@ +��װgit gui��������git bash���� +1.��¡ +git clone git@github.com:michaelliao/gitskills.git +2.�����޸ĵ��ļ� +git add -A +3.�ύ���ݴ��� +git commit -m "�ύ***����" +4.����master +git pull origin master +5.�ύ��master +git push origin master \ No newline at end of file diff --git "a/group07/20409287/git\345\221\275\344\273\244.txt" "b/group07/20409287/git\345\221\275\344\273\244.txt" new file mode 100644 index 0000000000..6b9ddc2f28 --- /dev/null +++ "b/group07/20409287/git\345\221\275\344\273\244.txt" @@ -0,0 +1,11 @@ +��װgit gui��������git bash���� +1.��¡ +git clone git@github.com:michaelliao/gitskills.git +2.�����޸ĵ��ļ� +git add -A +3.�ύ���ݴ��� +git commit -m "�ύ***����" +4.����master +git pull origin master +5.�ύ��master +git push origin master \ No newline at end of file diff --git "a/group07/2306826375/git\345\221\275\344\273\244.txt" "b/group07/2306826375/git\345\221\275\344\273\244.txt" new file mode 100644 index 0000000000..6b9ddc2f28 --- /dev/null +++ "b/group07/2306826375/git\345\221\275\344\273\244.txt" @@ -0,0 +1,11 @@ +��װgit gui��������git bash���� +1.��¡ +git clone git@github.com:michaelliao/gitskills.git +2.�����޸ĵ��ļ� +git add -A +3.�ύ���ݴ��� +git commit -m "�ύ***����" +4.����master +git pull origin master +5.�ύ��master +git push origin master \ No newline at end of file diff --git "a/group07/2708094737/git\345\221\275\344\273\244.txt" "b/group07/2708094737/git\345\221\275\344\273\244.txt" new file mode 100644 index 0000000000..6b9ddc2f28 --- /dev/null +++ "b/group07/2708094737/git\345\221\275\344\273\244.txt" @@ -0,0 +1,11 @@ +��װgit gui��������git bash���� +1.��¡ +git clone git@github.com:michaelliao/gitskills.git +2.�����޸ĵ��ļ� +git add -A +3.�ύ���ݴ��� +git commit -m "�ύ***����" +4.����master +git pull origin master +5.�ύ��master +git push origin master \ No newline at end of file diff --git "a/group07/2915553181/git\345\221\275\344\273\244.txt" "b/group07/2915553181/git\345\221\275\344\273\244.txt" new file mode 100644 index 0000000000..6b9ddc2f28 --- /dev/null +++ "b/group07/2915553181/git\345\221\275\344\273\244.txt" @@ -0,0 +1,11 @@ +��װgit gui��������git bash���� +1.��¡ +git clone git@github.com:michaelliao/gitskills.git +2.�����޸ĵ��ļ� +git add -A +3.�ύ���ݴ��� +git commit -m "�ύ***����" +4.����master +git pull origin master +5.�ύ��master +git push origin master \ No newline at end of file diff --git "a/group07/328536398/git\345\221\275\344\273\244.txt" "b/group07/328536398/git\345\221\275\344\273\244.txt" new file mode 100644 index 0000000000..6b9ddc2f28 --- /dev/null +++ "b/group07/328536398/git\345\221\275\344\273\244.txt" @@ -0,0 +1,11 @@ +��װgit gui��������git bash���� +1.��¡ +git clone git@github.com:michaelliao/gitskills.git +2.�����޸ĵ��ļ� +git add -A +3.�ύ���ݴ��� +git commit -m "�ύ***����" +4.����master +git pull origin master +5.�ύ��master +git push origin master \ No newline at end of file diff --git "a/group07/396868934/git\345\221\275\344\273\244.txt" "b/group07/396868934/git\345\221\275\344\273\244.txt" new file mode 100644 index 0000000000..6b9ddc2f28 --- /dev/null +++ "b/group07/396868934/git\345\221\275\344\273\244.txt" @@ -0,0 +1,11 @@ +��װgit gui��������git bash���� +1.��¡ +git clone git@github.com:michaelliao/gitskills.git +2.�����޸ĵ��ļ� +git add -A +3.�ύ���ݴ��� +git commit -m "�ύ***����" +4.����master +git pull origin master +5.�ύ��master +git push origin master \ No newline at end of file diff --git "a/group07/43819473/git\345\221\275\344\273\244.txt" "b/group07/43819473/git\345\221\275\344\273\244.txt" new file mode 100644 index 0000000000..6b9ddc2f28 --- /dev/null +++ "b/group07/43819473/git\345\221\275\344\273\244.txt" @@ -0,0 +1,11 @@ +��װgit gui��������git bash���� +1.��¡ +git clone git@github.com:michaelliao/gitskills.git +2.�����޸ĵ��ļ� +git add -A +3.�ύ���ݴ��� +git commit -m "�ύ***����" +4.����master +git pull origin master +5.�ύ��master +git push origin master \ No newline at end of file diff --git "a/group07/466199956/git\345\221\275\344\273\244.txt" "b/group07/466199956/git\345\221\275\344\273\244.txt" new file mode 100644 index 0000000000..6b9ddc2f28 --- /dev/null +++ "b/group07/466199956/git\345\221\275\344\273\244.txt" @@ -0,0 +1,11 @@ +��װgit gui��������git bash���� +1.��¡ +git clone git@github.com:michaelliao/gitskills.git +2.�����޸ĵ��ļ� +git add -A +3.�ύ���ݴ��� +git commit -m "�ύ***����" +4.����master +git pull origin master +5.�ύ��master +git push origin master \ No newline at end of file diff --git "a/group07/476770768/git\345\221\275\344\273\244.txt" "b/group07/476770768/git\345\221\275\344\273\244.txt" new file mode 100644 index 0000000000..6b9ddc2f28 --- /dev/null +++ "b/group07/476770768/git\345\221\275\344\273\244.txt" @@ -0,0 +1,11 @@ +��װgit gui��������git bash���� +1.��¡ +git clone git@github.com:michaelliao/gitskills.git +2.�����޸ĵ��ļ� +git add -A +3.�ύ���ݴ��� +git commit -m "�ύ***����" +4.����master +git pull origin master +5.�ύ��master +git push origin master \ No newline at end of file diff --git "a/group07/515372252/git\345\221\275\344\273\244.txt" "b/group07/515372252/git\345\221\275\344\273\244.txt" new file mode 100644 index 0000000000..6b9ddc2f28 --- /dev/null +++ "b/group07/515372252/git\345\221\275\344\273\244.txt" @@ -0,0 +1,11 @@ +��װgit gui��������git bash���� +1.��¡ +git clone git@github.com:michaelliao/gitskills.git +2.�����޸ĵ��ļ� +git add -A +3.�ύ���ݴ��� +git commit -m "�ύ***����" +4.����master +git pull origin master +5.�ύ��master +git push origin master \ No newline at end of file diff --git "a/group07/562247675/git\345\221\275\344\273\244.txt" "b/group07/562247675/git\345\221\275\344\273\244.txt" new file mode 100644 index 0000000000..6b9ddc2f28 --- /dev/null +++ "b/group07/562247675/git\345\221\275\344\273\244.txt" @@ -0,0 +1,11 @@ +��װgit gui��������git bash���� +1.��¡ +git clone git@github.com:michaelliao/gitskills.git +2.�����޸ĵ��ļ� +git add -A +3.�ύ���ݴ��� +git commit -m "�ύ***����" +4.����master +git pull origin master +5.�ύ��master +git push origin master \ No newline at end of file diff --git "a/group07/598812995/git\345\221\275\344\273\244.txt" "b/group07/598812995/git\345\221\275\344\273\244.txt" new file mode 100644 index 0000000000..6b9ddc2f28 --- /dev/null +++ "b/group07/598812995/git\345\221\275\344\273\244.txt" @@ -0,0 +1,11 @@ +��װgit gui��������git bash���� +1.��¡ +git clone git@github.com:michaelliao/gitskills.git +2.�����޸ĵ��ļ� +git add -A +3.�ύ���ݴ��� +git commit -m "�ύ***����" +4.����master +git pull origin master +5.�ύ��master +git push origin master \ No newline at end of file diff --git "a/group07/603622009/git\345\221\275\344\273\244.txt" "b/group07/603622009/git\345\221\275\344\273\244.txt" new file mode 100644 index 0000000000..6b9ddc2f28 --- /dev/null +++ "b/group07/603622009/git\345\221\275\344\273\244.txt" @@ -0,0 +1,11 @@ +��װgit gui��������git bash���� +1.��¡ +git clone git@github.com:michaelliao/gitskills.git +2.�����޸ĵ��ļ� +git add -A +3.�ύ���ݴ��� +git commit -m "�ύ***����" +4.����master +git pull origin master +5.�ύ��master +git push origin master \ No newline at end of file diff --git "a/group07/724319952/git\345\221\275\344\273\244.txt" "b/group07/724319952/git\345\221\275\344\273\244.txt" new file mode 100644 index 0000000000..6b9ddc2f28 --- /dev/null +++ "b/group07/724319952/git\345\221\275\344\273\244.txt" @@ -0,0 +1,11 @@ +��װgit gui��������git bash���� +1.��¡ +git clone git@github.com:michaelliao/gitskills.git +2.�����޸ĵ��ļ� +git add -A +3.�ύ���ݴ��� +git commit -m "�ύ***����" +4.����master +git pull origin master +5.�ύ��master +git push origin master \ No newline at end of file diff --git "a/group07/752262774/git\345\221\275\344\273\244.txt" "b/group07/752262774/git\345\221\275\344\273\244.txt" new file mode 100644 index 0000000000..6b9ddc2f28 --- /dev/null +++ "b/group07/752262774/git\345\221\275\344\273\244.txt" @@ -0,0 +1,11 @@ +��װgit gui��������git bash���� +1.��¡ +git clone git@github.com:michaelliao/gitskills.git +2.�����޸ĵ��ļ� +git add -A +3.�ύ���ݴ��� +git commit -m "�ύ***����" +4.����master +git pull origin master +5.�ύ��master +git push origin master \ No newline at end of file diff --git "a/group07/770164810/git\345\221\275\344\273\244.txt" "b/group07/770164810/git\345\221\275\344\273\244.txt" new file mode 100644 index 0000000000..6b9ddc2f28 --- /dev/null +++ "b/group07/770164810/git\345\221\275\344\273\244.txt" @@ -0,0 +1,11 @@ +��װgit gui��������git bash���� +1.��¡ +git clone git@github.com:michaelliao/gitskills.git +2.�����޸ĵ��ļ� +git add -A +3.�ύ���ݴ��� +git commit -m "�ύ***����" +4.����master +git pull origin master +5.�ύ��master +git push origin master \ No newline at end of file From 2d5dc847495fefaab0e649220011dfdf98193719 Mon Sep 17 00:00:00 2001 From: leijing Date: Thu, 23 Feb 2017 15:10:18 +0800 Subject: [PATCH 023/518] =?UTF-8?q?=E4=BF=AE=E6=94=B9git=E5=91=BD=E4=BB=A4?= =?UTF-8?q?.txt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 修改git命令.txt的内容 --- "group07/1046545622/git\345\221\275\344\273\244.txt" | 2 +- "group07/1058267830/git\345\221\275\344\273\244.txt" | 2 +- "group07/1070440331/git\345\221\275\344\273\244.txt" | 2 +- "group07/1280157271/git\345\221\275\344\273\244.txt" | 2 +- "group07/1448276993/git\345\221\275\344\273\244.txt" | 2 +- "group07/1519504320/git\345\221\275\344\273\244.txt" | 2 +- "group07/1520332119/git\345\221\275\344\273\244.txt" | 2 +- "group07/1536161030/git\345\221\275\344\273\244.txt" | 2 +- "group07/178007127/git\345\221\275\344\273\244.txt" | 2 +- "group07/20409287/git\345\221\275\344\273\244.txt" | 2 +- "group07/2306826375/git\345\221\275\344\273\244.txt" | 2 +- "group07/2708094737/git\345\221\275\344\273\244.txt" | 2 +- "group07/2915553181/git\345\221\275\344\273\244.txt" | 2 +- "group07/328536398/git\345\221\275\344\273\244.txt" | 2 +- "group07/396868934/git\345\221\275\344\273\244.txt" | 2 +- "group07/43819473/git\345\221\275\344\273\244.txt" | 2 +- "group07/466199956/git\345\221\275\344\273\244.txt" | 2 +- "group07/476770768/git\345\221\275\344\273\244.txt" | 2 +- "group07/515372252/git\345\221\275\344\273\244.txt" | 2 +- "group07/562247675/git\345\221\275\344\273\244.txt" | 2 +- "group07/598812995/git\345\221\275\344\273\244.txt" | 2 +- "group07/603622009/git\345\221\275\344\273\244.txt" | 2 +- "group07/724319952/git\345\221\275\344\273\244.txt" | 2 +- "group07/752262774/git\345\221\275\344\273\244.txt" | 2 +- "group07/770164810/git\345\221\275\344\273\244.txt" | 2 +- 25 files changed, 25 insertions(+), 25 deletions(-) diff --git "a/group07/1046545622/git\345\221\275\344\273\244.txt" "b/group07/1046545622/git\345\221\275\344\273\244.txt" index 6b9ddc2f28..8bcf2ffa0f 100644 --- "a/group07/1046545622/git\345\221\275\344\273\244.txt" +++ "b/group07/1046545622/git\345\221\275\344\273\244.txt" @@ -1,6 +1,6 @@ ��װgit gui��������git bash���� 1.��¡ -git clone git@github.com:michaelliao/gitskills.git +git clone git@github.com:leijing1992/coding2017.git 2.�����޸ĵ��ļ� git add -A 3.�ύ���ݴ��� diff --git "a/group07/1058267830/git\345\221\275\344\273\244.txt" "b/group07/1058267830/git\345\221\275\344\273\244.txt" index 6b9ddc2f28..8bcf2ffa0f 100644 --- "a/group07/1058267830/git\345\221\275\344\273\244.txt" +++ "b/group07/1058267830/git\345\221\275\344\273\244.txt" @@ -1,6 +1,6 @@ ��װgit gui��������git bash���� 1.��¡ -git clone git@github.com:michaelliao/gitskills.git +git clone git@github.com:leijing1992/coding2017.git 2.�����޸ĵ��ļ� git add -A 3.�ύ���ݴ��� diff --git "a/group07/1070440331/git\345\221\275\344\273\244.txt" "b/group07/1070440331/git\345\221\275\344\273\244.txt" index 6b9ddc2f28..8bcf2ffa0f 100644 --- "a/group07/1070440331/git\345\221\275\344\273\244.txt" +++ "b/group07/1070440331/git\345\221\275\344\273\244.txt" @@ -1,6 +1,6 @@ ��װgit gui��������git bash���� 1.��¡ -git clone git@github.com:michaelliao/gitskills.git +git clone git@github.com:leijing1992/coding2017.git 2.�����޸ĵ��ļ� git add -A 3.�ύ���ݴ��� diff --git "a/group07/1280157271/git\345\221\275\344\273\244.txt" "b/group07/1280157271/git\345\221\275\344\273\244.txt" index 6b9ddc2f28..8bcf2ffa0f 100644 --- "a/group07/1280157271/git\345\221\275\344\273\244.txt" +++ "b/group07/1280157271/git\345\221\275\344\273\244.txt" @@ -1,6 +1,6 @@ ��װgit gui��������git bash���� 1.��¡ -git clone git@github.com:michaelliao/gitskills.git +git clone git@github.com:leijing1992/coding2017.git 2.�����޸ĵ��ļ� git add -A 3.�ύ���ݴ��� diff --git "a/group07/1448276993/git\345\221\275\344\273\244.txt" "b/group07/1448276993/git\345\221\275\344\273\244.txt" index 6b9ddc2f28..8bcf2ffa0f 100644 --- "a/group07/1448276993/git\345\221\275\344\273\244.txt" +++ "b/group07/1448276993/git\345\221\275\344\273\244.txt" @@ -1,6 +1,6 @@ ��װgit gui��������git bash���� 1.��¡ -git clone git@github.com:michaelliao/gitskills.git +git clone git@github.com:leijing1992/coding2017.git 2.�����޸ĵ��ļ� git add -A 3.�ύ���ݴ��� diff --git "a/group07/1519504320/git\345\221\275\344\273\244.txt" "b/group07/1519504320/git\345\221\275\344\273\244.txt" index 6b9ddc2f28..8bcf2ffa0f 100644 --- "a/group07/1519504320/git\345\221\275\344\273\244.txt" +++ "b/group07/1519504320/git\345\221\275\344\273\244.txt" @@ -1,6 +1,6 @@ ��װgit gui��������git bash���� 1.��¡ -git clone git@github.com:michaelliao/gitskills.git +git clone git@github.com:leijing1992/coding2017.git 2.�����޸ĵ��ļ� git add -A 3.�ύ���ݴ��� diff --git "a/group07/1520332119/git\345\221\275\344\273\244.txt" "b/group07/1520332119/git\345\221\275\344\273\244.txt" index 6b9ddc2f28..8bcf2ffa0f 100644 --- "a/group07/1520332119/git\345\221\275\344\273\244.txt" +++ "b/group07/1520332119/git\345\221\275\344\273\244.txt" @@ -1,6 +1,6 @@ ��װgit gui��������git bash���� 1.��¡ -git clone git@github.com:michaelliao/gitskills.git +git clone git@github.com:leijing1992/coding2017.git 2.�����޸ĵ��ļ� git add -A 3.�ύ���ݴ��� diff --git "a/group07/1536161030/git\345\221\275\344\273\244.txt" "b/group07/1536161030/git\345\221\275\344\273\244.txt" index 6b9ddc2f28..8bcf2ffa0f 100644 --- "a/group07/1536161030/git\345\221\275\344\273\244.txt" +++ "b/group07/1536161030/git\345\221\275\344\273\244.txt" @@ -1,6 +1,6 @@ ��װgit gui��������git bash���� 1.��¡ -git clone git@github.com:michaelliao/gitskills.git +git clone git@github.com:leijing1992/coding2017.git 2.�����޸ĵ��ļ� git add -A 3.�ύ���ݴ��� diff --git "a/group07/178007127/git\345\221\275\344\273\244.txt" "b/group07/178007127/git\345\221\275\344\273\244.txt" index 6b9ddc2f28..8bcf2ffa0f 100644 --- "a/group07/178007127/git\345\221\275\344\273\244.txt" +++ "b/group07/178007127/git\345\221\275\344\273\244.txt" @@ -1,6 +1,6 @@ ��װgit gui��������git bash���� 1.��¡ -git clone git@github.com:michaelliao/gitskills.git +git clone git@github.com:leijing1992/coding2017.git 2.�����޸ĵ��ļ� git add -A 3.�ύ���ݴ��� diff --git "a/group07/20409287/git\345\221\275\344\273\244.txt" "b/group07/20409287/git\345\221\275\344\273\244.txt" index 6b9ddc2f28..8bcf2ffa0f 100644 --- "a/group07/20409287/git\345\221\275\344\273\244.txt" +++ "b/group07/20409287/git\345\221\275\344\273\244.txt" @@ -1,6 +1,6 @@ ��װgit gui��������git bash���� 1.��¡ -git clone git@github.com:michaelliao/gitskills.git +git clone git@github.com:leijing1992/coding2017.git 2.�����޸ĵ��ļ� git add -A 3.�ύ���ݴ��� diff --git "a/group07/2306826375/git\345\221\275\344\273\244.txt" "b/group07/2306826375/git\345\221\275\344\273\244.txt" index 6b9ddc2f28..8bcf2ffa0f 100644 --- "a/group07/2306826375/git\345\221\275\344\273\244.txt" +++ "b/group07/2306826375/git\345\221\275\344\273\244.txt" @@ -1,6 +1,6 @@ ��װgit gui��������git bash���� 1.��¡ -git clone git@github.com:michaelliao/gitskills.git +git clone git@github.com:leijing1992/coding2017.git 2.�����޸ĵ��ļ� git add -A 3.�ύ���ݴ��� diff --git "a/group07/2708094737/git\345\221\275\344\273\244.txt" "b/group07/2708094737/git\345\221\275\344\273\244.txt" index 6b9ddc2f28..8bcf2ffa0f 100644 --- "a/group07/2708094737/git\345\221\275\344\273\244.txt" +++ "b/group07/2708094737/git\345\221\275\344\273\244.txt" @@ -1,6 +1,6 @@ ��װgit gui��������git bash���� 1.��¡ -git clone git@github.com:michaelliao/gitskills.git +git clone git@github.com:leijing1992/coding2017.git 2.�����޸ĵ��ļ� git add -A 3.�ύ���ݴ��� diff --git "a/group07/2915553181/git\345\221\275\344\273\244.txt" "b/group07/2915553181/git\345\221\275\344\273\244.txt" index 6b9ddc2f28..8bcf2ffa0f 100644 --- "a/group07/2915553181/git\345\221\275\344\273\244.txt" +++ "b/group07/2915553181/git\345\221\275\344\273\244.txt" @@ -1,6 +1,6 @@ ��װgit gui��������git bash���� 1.��¡ -git clone git@github.com:michaelliao/gitskills.git +git clone git@github.com:leijing1992/coding2017.git 2.�����޸ĵ��ļ� git add -A 3.�ύ���ݴ��� diff --git "a/group07/328536398/git\345\221\275\344\273\244.txt" "b/group07/328536398/git\345\221\275\344\273\244.txt" index 6b9ddc2f28..8bcf2ffa0f 100644 --- "a/group07/328536398/git\345\221\275\344\273\244.txt" +++ "b/group07/328536398/git\345\221\275\344\273\244.txt" @@ -1,6 +1,6 @@ ��װgit gui��������git bash���� 1.��¡ -git clone git@github.com:michaelliao/gitskills.git +git clone git@github.com:leijing1992/coding2017.git 2.�����޸ĵ��ļ� git add -A 3.�ύ���ݴ��� diff --git "a/group07/396868934/git\345\221\275\344\273\244.txt" "b/group07/396868934/git\345\221\275\344\273\244.txt" index 6b9ddc2f28..8bcf2ffa0f 100644 --- "a/group07/396868934/git\345\221\275\344\273\244.txt" +++ "b/group07/396868934/git\345\221\275\344\273\244.txt" @@ -1,6 +1,6 @@ ��װgit gui��������git bash���� 1.��¡ -git clone git@github.com:michaelliao/gitskills.git +git clone git@github.com:leijing1992/coding2017.git 2.�����޸ĵ��ļ� git add -A 3.�ύ���ݴ��� diff --git "a/group07/43819473/git\345\221\275\344\273\244.txt" "b/group07/43819473/git\345\221\275\344\273\244.txt" index 6b9ddc2f28..8bcf2ffa0f 100644 --- "a/group07/43819473/git\345\221\275\344\273\244.txt" +++ "b/group07/43819473/git\345\221\275\344\273\244.txt" @@ -1,6 +1,6 @@ ��װgit gui��������git bash���� 1.��¡ -git clone git@github.com:michaelliao/gitskills.git +git clone git@github.com:leijing1992/coding2017.git 2.�����޸ĵ��ļ� git add -A 3.�ύ���ݴ��� diff --git "a/group07/466199956/git\345\221\275\344\273\244.txt" "b/group07/466199956/git\345\221\275\344\273\244.txt" index 6b9ddc2f28..8bcf2ffa0f 100644 --- "a/group07/466199956/git\345\221\275\344\273\244.txt" +++ "b/group07/466199956/git\345\221\275\344\273\244.txt" @@ -1,6 +1,6 @@ ��װgit gui��������git bash���� 1.��¡ -git clone git@github.com:michaelliao/gitskills.git +git clone git@github.com:leijing1992/coding2017.git 2.�����޸ĵ��ļ� git add -A 3.�ύ���ݴ��� diff --git "a/group07/476770768/git\345\221\275\344\273\244.txt" "b/group07/476770768/git\345\221\275\344\273\244.txt" index 6b9ddc2f28..8bcf2ffa0f 100644 --- "a/group07/476770768/git\345\221\275\344\273\244.txt" +++ "b/group07/476770768/git\345\221\275\344\273\244.txt" @@ -1,6 +1,6 @@ ��װgit gui��������git bash���� 1.��¡ -git clone git@github.com:michaelliao/gitskills.git +git clone git@github.com:leijing1992/coding2017.git 2.�����޸ĵ��ļ� git add -A 3.�ύ���ݴ��� diff --git "a/group07/515372252/git\345\221\275\344\273\244.txt" "b/group07/515372252/git\345\221\275\344\273\244.txt" index 6b9ddc2f28..8bcf2ffa0f 100644 --- "a/group07/515372252/git\345\221\275\344\273\244.txt" +++ "b/group07/515372252/git\345\221\275\344\273\244.txt" @@ -1,6 +1,6 @@ ��װgit gui��������git bash���� 1.��¡ -git clone git@github.com:michaelliao/gitskills.git +git clone git@github.com:leijing1992/coding2017.git 2.�����޸ĵ��ļ� git add -A 3.�ύ���ݴ��� diff --git "a/group07/562247675/git\345\221\275\344\273\244.txt" "b/group07/562247675/git\345\221\275\344\273\244.txt" index 6b9ddc2f28..8bcf2ffa0f 100644 --- "a/group07/562247675/git\345\221\275\344\273\244.txt" +++ "b/group07/562247675/git\345\221\275\344\273\244.txt" @@ -1,6 +1,6 @@ ��װgit gui��������git bash���� 1.��¡ -git clone git@github.com:michaelliao/gitskills.git +git clone git@github.com:leijing1992/coding2017.git 2.�����޸ĵ��ļ� git add -A 3.�ύ���ݴ��� diff --git "a/group07/598812995/git\345\221\275\344\273\244.txt" "b/group07/598812995/git\345\221\275\344\273\244.txt" index 6b9ddc2f28..8bcf2ffa0f 100644 --- "a/group07/598812995/git\345\221\275\344\273\244.txt" +++ "b/group07/598812995/git\345\221\275\344\273\244.txt" @@ -1,6 +1,6 @@ ��װgit gui��������git bash���� 1.��¡ -git clone git@github.com:michaelliao/gitskills.git +git clone git@github.com:leijing1992/coding2017.git 2.�����޸ĵ��ļ� git add -A 3.�ύ���ݴ��� diff --git "a/group07/603622009/git\345\221\275\344\273\244.txt" "b/group07/603622009/git\345\221\275\344\273\244.txt" index 6b9ddc2f28..8bcf2ffa0f 100644 --- "a/group07/603622009/git\345\221\275\344\273\244.txt" +++ "b/group07/603622009/git\345\221\275\344\273\244.txt" @@ -1,6 +1,6 @@ ��װgit gui��������git bash���� 1.��¡ -git clone git@github.com:michaelliao/gitskills.git +git clone git@github.com:leijing1992/coding2017.git 2.�����޸ĵ��ļ� git add -A 3.�ύ���ݴ��� diff --git "a/group07/724319952/git\345\221\275\344\273\244.txt" "b/group07/724319952/git\345\221\275\344\273\244.txt" index 6b9ddc2f28..8bcf2ffa0f 100644 --- "a/group07/724319952/git\345\221\275\344\273\244.txt" +++ "b/group07/724319952/git\345\221\275\344\273\244.txt" @@ -1,6 +1,6 @@ ��װgit gui��������git bash���� 1.��¡ -git clone git@github.com:michaelliao/gitskills.git +git clone git@github.com:leijing1992/coding2017.git 2.�����޸ĵ��ļ� git add -A 3.�ύ���ݴ��� diff --git "a/group07/752262774/git\345\221\275\344\273\244.txt" "b/group07/752262774/git\345\221\275\344\273\244.txt" index 6b9ddc2f28..8bcf2ffa0f 100644 --- "a/group07/752262774/git\345\221\275\344\273\244.txt" +++ "b/group07/752262774/git\345\221\275\344\273\244.txt" @@ -1,6 +1,6 @@ ��װgit gui��������git bash���� 1.��¡ -git clone git@github.com:michaelliao/gitskills.git +git clone git@github.com:leijing1992/coding2017.git 2.�����޸ĵ��ļ� git add -A 3.�ύ���ݴ��� diff --git "a/group07/770164810/git\345\221\275\344\273\244.txt" "b/group07/770164810/git\345\221\275\344\273\244.txt" index 6b9ddc2f28..8bcf2ffa0f 100644 --- "a/group07/770164810/git\345\221\275\344\273\244.txt" +++ "b/group07/770164810/git\345\221\275\344\273\244.txt" @@ -1,6 +1,6 @@ ��װgit gui��������git bash���� 1.��¡ -git clone git@github.com:michaelliao/gitskills.git +git clone git@github.com:leijing1992/coding2017.git 2.�����޸ĵ��ļ� git add -A 3.�ύ���ݴ��� From 5d87cd6dd3a5ba741a51d1070d77bb3cd32ac855 Mon Sep 17 00:00:00 2001 From: jy97799 <977996067@qq.com> Date: Thu, 23 Feb 2017 15:22:11 +0800 Subject: [PATCH 024/518] =?UTF-8?q?3.26=E4=BD=9C=E4=B8=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../1507_977996067/src/task1/MyArrayList.java | 95 +++++++++++++ .../src/task1/MyLinkedList.java | 130 ++++++++++++++++++ group15/1507_977996067/src/task1/MyList.java | 16 +++ group15/1507_977996067/src/task1/MyQueue.java | 25 ++++ group15/1507_977996067/src/task1/MyStack.java | 29 ++++ group15/1507_977996067/src/task1/README.md | 1 + 6 files changed, 296 insertions(+) create mode 100644 group15/1507_977996067/src/task1/MyArrayList.java create mode 100644 group15/1507_977996067/src/task1/MyLinkedList.java create mode 100644 group15/1507_977996067/src/task1/MyList.java create mode 100644 group15/1507_977996067/src/task1/MyQueue.java create mode 100644 group15/1507_977996067/src/task1/MyStack.java create mode 100644 group15/1507_977996067/src/task1/README.md diff --git a/group15/1507_977996067/src/task1/MyArrayList.java b/group15/1507_977996067/src/task1/MyArrayList.java new file mode 100644 index 0000000000..e4d01a2c06 --- /dev/null +++ b/group15/1507_977996067/src/task1/MyArrayList.java @@ -0,0 +1,95 @@ +package task1; + +import java.util.Arrays; +import java.util.Iterator; + +/** + * ArrayList实现 + */ +public class MyArrayList implements MyList { + + //列表元素的个数 + private int size; + //列表存放的元素 + private Object[] elements; + //初始容量10 + private static final int DEFAULT_CAPACITY = 10; + + public MyArrayList() { + elements = new Object[DEFAULT_CAPACITY]; + } + + public MyArrayList(int capacity) { + elements = new Object[capacity <= DEFAULT_CAPACITY ? DEFAULT_CAPACITY : capacity]; + } + + @Override + public void add(T o) { + add(size, o); + } + + @Override + public void add(int index, T o) { + if (index < 0 || index > size) + throw new IndexOutOfBoundsException("index " + index + " 不合法"); + if (size >= elements.length) + ensureCapacity((size >> 1) + size); + elements[index] = o; + size++; + } + + @Override + @SuppressWarnings("unchecked") + public T get(int index) { + if (index < 0 || index >= size) + throw new IndexOutOfBoundsException("index " + index + " 越界"); + return (T) elements[index]; + } + + @Override + @SuppressWarnings("unchecked") + public T remove(int index) { + if (index < 0 || index >= size) + throw new IndexOutOfBoundsException("index " + index + " 越界"); + T removeElement = (T) elements[index]; + System.arraycopy(elements, index + 1, elements, index, elements.length - index - 1); + size--; + return removeElement; + } + + @Override + public int size() { + return size; + } + + public Iterator iterator() { + return new MyItr(); + } + + private void ensureCapacity(int newCapacity) { + elements = Arrays.copyOf(elements, newCapacity); + } + + private class MyItr implements Iterator { + + private int current = 0; + + @Override + public boolean hasNext() { + return current < size; + } + + @Override + @SuppressWarnings("unchecked") + public T next() { + return (T) elements[current++]; + } + + @Override + public void remove() { + if (current == 0) + throw new IllegalStateException("先调用next后才能再调用remove"); + MyArrayList.this.remove(--current); + } + } +} diff --git a/group15/1507_977996067/src/task1/MyLinkedList.java b/group15/1507_977996067/src/task1/MyLinkedList.java new file mode 100644 index 0000000000..fa5d651078 --- /dev/null +++ b/group15/1507_977996067/src/task1/MyLinkedList.java @@ -0,0 +1,130 @@ +package task1; + +import java.util.Iterator; + +/** + * LinkedList 实现 + */ +public class MyLinkedList implements MyList { + + //存放的元素数量 + private int size; + + private Node head; + + public MyLinkedList() { + head = new Node<>(null, null); + } + + @Override + public void add(T o) { + add(size, o); + } + + @Override + public void add(int index, T o) { + if (index < 0 || index > size) + throw new IndexOutOfBoundsException("index " + index + " 不合法"); + Node targetNode = new Node<>(null, o); + Node targetPrevNode = getPrevNode(index); + targetNode.next = targetPrevNode.next; + targetPrevNode.next = targetNode; + size++; + } + + @Override + public T get(int index) { + checkIndexRange(index); + return getPrevNode(index).next.data; + } + + + @Override + public T remove(int index) { + checkIndexRange(index); + Node prevNode = getPrevNode(index); + Node nodeToRemove = prevNode.next; + prevNode.next = nodeToRemove.next; + size--; + return nodeToRemove.data; + } + + @Override + public int size() { + return size; + } + + public void addFirst(T o) { + add(0, o); + + } + + public void addLast(T o) { + add(size, o); + } + + public T removeFirst() { + return remove(0); + } + + public T removeLast() { + return remove(size - 1); + } + + + public Iterator iterator() { + return new MyLinkedItr(); + } + + /** + * 找到位置为index的前一个node + * + * @param index 索引值 + */ + + private Node getPrevNode(int index) { + Node targetPrevNode = head; + for (int i = 0; i < index; i++) { + targetPrevNode = targetPrevNode.next; + } + return targetPrevNode; + } + + /** + * 检查索引是否越界 + * + * @param index 索引值 + */ + private void checkIndexRange(int index) { + if (index < 0 || index >= size) + throw new IndexOutOfBoundsException("index " + index + " 越界"); + } + + private static class Node { + private Node next; + private T data; + + private Node(Node next, T data) { + this.next = next; + this.data = data; + } + } + + private class MyLinkedItr implements Iterator { + + private Node currentNode = head; + + @Override + public boolean hasNext() { + return currentNode.next != null; + } + + @Override + public T next() { + Node nextNode = currentNode.next; + T data = nextNode.data; + currentNode = nextNode; + return data; + } + } +} diff --git a/group15/1507_977996067/src/task1/MyList.java b/group15/1507_977996067/src/task1/MyList.java new file mode 100644 index 0000000000..e68f445174 --- /dev/null +++ b/group15/1507_977996067/src/task1/MyList.java @@ -0,0 +1,16 @@ +package task1; + +/** + * List 接口 + */ +public interface MyList { + public void add(T o); + + public void add(int index, T o); + + public T get(int index); + + public T remove(int index); + + public int size(); +} diff --git a/group15/1507_977996067/src/task1/MyQueue.java b/group15/1507_977996067/src/task1/MyQueue.java new file mode 100644 index 0000000000..2ae3d8529f --- /dev/null +++ b/group15/1507_977996067/src/task1/MyQueue.java @@ -0,0 +1,25 @@ +package task1; + +/** + * Queue 实现 + */ +public class MyQueue { + private MyLinkedList elementData = new MyLinkedList(); + + public void enQueue(T o) { + elementData.addFirst(o); + } + + public T deQueue() { + return elementData.removeLast(); + } + + public boolean isEmpty() { + return elementData.size() == 0; + } + + public int size() { + return elementData.size(); + } + +} diff --git a/group15/1507_977996067/src/task1/MyStack.java b/group15/1507_977996067/src/task1/MyStack.java new file mode 100644 index 0000000000..476caf67e2 --- /dev/null +++ b/group15/1507_977996067/src/task1/MyStack.java @@ -0,0 +1,29 @@ +package task1; + +/** + * Stack 实现 + */ +public class MyStack { + private MyLinkedList elementData = new MyLinkedList(); + + public void push(T o) { + elementData.addFirst(o); + } + + public T pop() { + return elementData.removeFirst(); + } + + public T peek() { + return elementData.get(0); + } + + public boolean isEmpty() { + return elementData.size() == 0; + } + + public int size() { + return elementData.size(); + } + +} diff --git a/group15/1507_977996067/src/task1/README.md b/group15/1507_977996067/src/task1/README.md new file mode 100644 index 0000000000..3f8eb94089 --- /dev/null +++ b/group15/1507_977996067/src/task1/README.md @@ -0,0 +1 @@ +###3.26作业:实现简单的数据结构 \ No newline at end of file From c6f9472d0cb37b5d37c1872835e13988244f5b4b Mon Sep 17 00:00:00 2001 From: jy97799 <977996067@qq.com> Date: Thu, 23 Feb 2017 15:24:21 +0800 Subject: [PATCH 025/518] =?UTF-8?q?3.26=E4=BD=9C=E4=B8=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- group15/1507_977996067/src/README.md | 1 + 1 file changed, 1 insertion(+) create mode 100644 group15/1507_977996067/src/README.md diff --git a/group15/1507_977996067/src/README.md b/group15/1507_977996067/src/README.md new file mode 100644 index 0000000000..78a3f19258 --- /dev/null +++ b/group15/1507_977996067/src/README.md @@ -0,0 +1 @@ +### qq 977996067 的作业文件夹 \ No newline at end of file From ba075eb3e93e4445e9e29bd293c29df4d349c65c Mon Sep 17 00:00:00 2001 From: jy97799 <977996067@qq.com> Date: Thu, 23 Feb 2017 15:25:20 +0800 Subject: [PATCH 026/518] =?UTF-8?q?3.26=E4=BD=9C=E4=B8=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- group15/1507_977996067/{src => }/README.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename group15/1507_977996067/{src => }/README.md (100%) diff --git a/group15/1507_977996067/src/README.md b/group15/1507_977996067/README.md similarity index 100% rename from group15/1507_977996067/src/README.md rename to group15/1507_977996067/README.md From 3888ae8ece8fd7a47cfc8d91329286350e739be3 Mon Sep 17 00:00:00 2001 From: jy97799 <977996067@qq.com> Date: Thu, 23 Feb 2017 15:27:05 +0800 Subject: [PATCH 027/518] =?UTF-8?q?2.26=E4=BD=9C=E4=B8=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- group15/1507_977996067/src/task1/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/group15/1507_977996067/src/task1/README.md b/group15/1507_977996067/src/task1/README.md index 3f8eb94089..d012aef953 100644 --- a/group15/1507_977996067/src/task1/README.md +++ b/group15/1507_977996067/src/task1/README.md @@ -1 +1 @@ -###3.26作业:实现简单的数据结构 \ No newline at end of file +###2.26作业:实现简单的数据结构 \ No newline at end of file From e18643827a86766da8a58f56894795dd9f235ce1 Mon Sep 17 00:00:00 2001 From: Ren650119726 <102228177@qq.com> Date: Thu, 23 Feb 2017 15:27:59 +0800 Subject: [PATCH 028/518] --- group17/102228177/bin/data2_19/ArrayList.class | Bin 2476 -> 0 bytes .../102228177/bin/data2_19/BinaryTreeNode.class | Bin 2283 -> 0 bytes group17/102228177/bin/data2_19/Iterator.class | Bin 168 -> 0 bytes .../102228177/bin/data2_19/LinkedList$Node.class | Bin 589 -> 0 bytes group17/102228177/bin/data2_19/LinkedList.class | Bin 2573 -> 0 bytes group17/102228177/bin/data2_19/List.class | Bin 245 -> 0 bytes group17/102228177/bin/data2_19/Queue.class | Bin 1390 -> 0 bytes group17/102228177/bin/data2_19/Stack.class | Bin 1520 -> 0 bytes 8 files changed, 0 insertions(+), 0 deletions(-) delete mode 100644 group17/102228177/bin/data2_19/ArrayList.class delete mode 100644 group17/102228177/bin/data2_19/BinaryTreeNode.class delete mode 100644 group17/102228177/bin/data2_19/Iterator.class delete mode 100644 group17/102228177/bin/data2_19/LinkedList$Node.class delete mode 100644 group17/102228177/bin/data2_19/LinkedList.class delete mode 100644 group17/102228177/bin/data2_19/List.class delete mode 100644 group17/102228177/bin/data2_19/Queue.class delete mode 100644 group17/102228177/bin/data2_19/Stack.class diff --git a/group17/102228177/bin/data2_19/ArrayList.class b/group17/102228177/bin/data2_19/ArrayList.class deleted file mode 100644 index 160f55d10fa8674cee37a60ff17a26ee731d2486..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 2476 zcmZuzTXz#x7~Q8yGijL8(v~zeEq8620F@L)2vpnBVkA%?rBG2}nhaq|G82*swRXU^r@``h0o`SagjegiOts)jCs zfui9W>6^z+PR`V7#-p57cQphB`qzy6#$?&BOOuPMYi5C~A%Wi3X?ai}R5WkrOj|%? zxjE<9b=R=nWux3M0|bc(gw3*9F>SXlFnA-k*=R-}ShpUVv{W%3Dodf$mTkGy0)fQD zGPmcPq8UK|gF5=q-vfc&I(iY7vtb=O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N~+tp-@_oD^e?|+Af?mwmk^ZwR4x^GflL!Ksh~f0`(wx-HGk|6^?OTmsZbO1*8)^% z{AZkdiSsL?FL2>Gt_)ml;#z97i5pFP-o&jYic+*x6W02hzuFa=rZ`}03&Ucutug!V zvP#NGpu%jik%7bPt6~B7P~uoay+gJ-PnUT=%(23rAuvbL+M#Cq`UeXdggD4OTM6X+ E2NA{D7XSbN diff --git a/group17/102228177/bin/data2_19/BinaryTreeNode.class b/group17/102228177/bin/data2_19/BinaryTreeNode.class deleted file mode 100644 index 9088822d4f510ff17ba4e41b87e6b2ce5d786435..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 2283 zcmaKs%TF6u6vn@68ylM;fO!Q12{>)>D>#Iv36Iba9to|%Z9qg(7u8@UW>Pao!&Kqc0?*3E3rArj-zFPPI&8CaK%4NQX_?NF!eH{lNU2@MS|MHxLG)_S(5Dbg zrgo!H=+_WIr$SHOw2ZCl;htgdcxdr_rKp#8b=#D8e>3D9n8ymLq7W$=&Zulp8`7Mlh7{8DKhTd4q+@QMHWa$I9liM7rheqNA#7U5hRw#`YSr(yz%erBC*CQew8@oGXZmn+{J`;#%;!=kW0Xj0X-W1CiKL6XL(W5aSh^3b7f zS_(tSZyLlbN1PYWGovu&0v-KpBNSZS!okJ7MH zpXSB37qqm1NwNp|>)?MtMvkA8fN0%)Qnh?)Jf}AJe}!-BJP+_0OP`}Boq3D+8`pM# z|5q3V^bXN4O3e@QZOF6cQ)1B%!_2~2#Z`>>F>~%a(2@QX@n2{ZfP@QkTY^d$fuMmO zh9ar~E%`vGC;1d(92o5(<(7lO#v?jcJ-NY)I`!UzryJQM;>lTYxBu|!sV z@1UM%&N022PG`??J6msymu8BZOQMJ0N=Y-}In~ni`MQfzeV;O+sF>e5KgmCSl0qhX zhP$EH7-OO1e<7O5zQy>Pw7f~uQ{-HWfM=2LEfTIp!n5dphkMWCbLUw2LwfIZV&3iM zG!b*?#cd+a5N#GW2$SG9Era{Snd54nt3@p10ameuEj(-}r%)@Wz%%I@Q1Hu<{zcF+ z)HT=@Wtz|F=w0EDM39M{l?HbHhGq6JpXuP@43D2>dWUPP$i*t;FY4ME<=p@)oWoV} ztdV=2jebn#CoZ2i=Cjzq7qrtbg)fD#cbQts`yeS_OVM=ZPbl_Tgwi$cOhBtx8Q2&=RkJTmY$pC1d~q diff --git a/group17/102228177/bin/data2_19/LinkedList$Node.class b/group17/102228177/bin/data2_19/LinkedList$Node.class deleted file mode 100644 index d788f96bca992ae620f269646337c51396c36dc3..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 589 zcmZ`$%Syvg5Ixhz#>Uvz)@rSd**< zp?DOQC;VHh+Z)P$OwiN?Lec(PI^~)#pO{j$=ZP{WbLRSPd`>9W|4TF+7HM;L18FRq z$RbBb*Bee2Y{tX_GU`+`p<|JdXV0=Tdg#gUTJ$`rYz2McIU;mbJWXoxof{D-AXqb+ z&Uf2z4DPm}d>91dDj0=*dEu%?s`YeT2Wk@p^V0Wa*!Dye$wA(j}6&={W?U-;T9a(KfkXVwzw xJj#hE3vea_Du7w*Q}KP~C=;1xYl6zJCi42ooGQMyZ<;GMtGX+A}-~Eo+N&>ari% zf8o`ZCEV=7EgF)UY*&M1cl$S%ExXvo=Av`Y`<+AW2HY%Jnx5}FU%&T#pXYgh^oPH` z`4+$ljQinHIFL0|)6eLm_g*yk#br&D>J*!r~1p!_z8-+KTJN zl7eyFGP4RzsfzP$H(lv`)*9iRqJ76wP}2%kXY8C^8dLE0^v?5_bG#9N7vT_s2-QGg ze+V@Q$nHQ0epD-j3Cv2btt?uFIdgHDp6XKhjJZ5-7HoNU4~^1wyQt8x8xn%>npxs( z=t=#X)=2NXAI%B}_hJx06Iun|A%)~F_PYgisQ1p-(6%jvcHv>pChK%bqT^j_Hr_vzqFRQKDlhISh-RKh#`a(0**h&xv{Kc1TN**3K?t4 zmO7Bia7*^6_*4i@=WC|a4`pf3yx6Gflk5;a0ql!4G*pBafCZB?KR1# zi2Bj=6n;L9KN(Xfz3fu@jsB{5@1h{zgyxg>4jAhQerhO9qrqr4vY#X1(D^yBiB{ns z7yiS(s87zxFcJ0b!E-?8qm9{Wr??%Iwu@|!kWV*@vkSfaBoM<8`Y_I#Jx^uc#4*ix z%t2S?dl5Z4&qS=5d+2e}vIM8nvzLQ z2b=FB*i027pCR}d@r4Z>{Z2%g^^S=cUKJTzj8@FpsAD1ZaS7x9KuOv zV1RiWWZs6DkJIEmOe90hr4whLBx~!tSExGg1vPE-ovRDgW$o~vAnu8>;zl{G6 zhW9b>mA&w9Vq!NMM)r$sBEJZqVIv+joJ=~knq{rZN%DbuL2{T~0-Pnuagsbon6ILZ z3FyESfuARh*O!3Op`d-DBB$eH z46&VtbvvbEeY(nARi(;!P|-(Cy5mMrHJN5mgc?z@!vLxTB;Qh&_0_@qManKFYxUHXder*!FiXi-m#?HL|| a5#Db82-%M^st03ug{%DMHSv2EfxiLg>#O$w diff --git a/group17/102228177/bin/data2_19/List.class b/group17/102228177/bin/data2_19/List.class deleted file mode 100644 index a8d53da1d256bb79a3144df15a71a38b20709614..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 245 zcmZvX%L;-}5QhKBTiSJF&v4u%)hgNtg3uyp8z()8VhL(4dbAcjKo1p-(yH3b2lLM` z-#lOU2Y?kO7J7tHENi(uF4lgSR<#A4FwJBm{ajuWe|O4MR1-8A#{^e|-_gc95N0Cy zA83i>} z!c~EenA4;vLtHvDaMVE2`V91=SD>jP%kH*(Xjc?5?uOdxc6GYEc31_m$r!u4ZT@`0vQ>!N~qVa(NG}U(uG0ensk&@7BR@J2ZazqBvTJNfXh@9V2kY z37q6gD3L?(9KjLprLtepmaC&XyZi+y?bScnq@SZfU^7D`ePn0g79t5i56%)Qlt3YT zK7^+gypHo`051}r`^caXsH6jW8|m#FsYCR1NN->P7eYGw8qz2IXh0L`sSk*0yU|_Z zqCQl~2f80r-xR_!zKu{1oLvrC`H&S;EJX=Y3n<-(D6x>zh#W45&hKfhG#vc_!MOgSljDGh=Ii7oWp^0TWy?1x-^PF>@^E@~I{QL4R0GDy!#*{#=?MCjU?=N1d zHzT+8#D*m>``F!c>s{CH)VFsZt5zhCRbACnesrDD0`ra6S=YkQ-EVk|3f63VDlm8G!w+#f`$CvhE{6c!Arx)|&6g8Chbi6}|A zJ%jU=#Az%!*uqU4-v|_ps>wi!hVG%=*STFfBXC>d9F|zI8+JGvg*Ox|kRIq;AmB8E zVc1ePJUwBKG4O(>!4i>DygyU?<7k>E4kmY-C!A@nS-#z5l;B>hzJRPAAouVEW}joO zntG1H?8*O8E@fjz6oty0=!M&DSj(dpJA>x!aLQ6&rq;_ zn1Ib0jXCPdlVa9DF2rdGBmwX)P7zdSHxuxk1iYld`CqWwBP=&!iZ&@~zma+hT6)Y; z;66{0#W9Xj!jWScXA=%upKv@#oLQ`nQ2qtk1DvNf7ycfntZSOo7|jXVTVgRM$J|*= zXfBypktaUyO~SIyUHhNaRs4#y^)&VLHRiNAIyHusoy5|=IG6DOSKZ4xca4?SSQ;fZ zAVygpLrEtn8GMM3lH?(yb-z{*AXw+ejhgi*J{e)XmX7y7@CDm=V}!5cr(1kF9FUTk nu@!dmEc Date: Thu, 23 Feb 2017 15:30:10 +0800 Subject: [PATCH 029/518] =?UTF-8?q?=E8=BF=AD=E4=BB=A3=E5=99=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- group17/102228177/src/data2_19/ArrayList.java | 38 +++++++++++++++++-- group17/102228177/src/data2_19/List.java | 1 + 2 files changed, 36 insertions(+), 3 deletions(-) diff --git a/group17/102228177/src/data2_19/ArrayList.java b/group17/102228177/src/data2_19/ArrayList.java index a28c29906d..0f0be01806 100644 --- a/group17/102228177/src/data2_19/ArrayList.java +++ b/group17/102228177/src/data2_19/ArrayList.java @@ -1,5 +1,9 @@ package data2_19; +import java.util.ConcurrentModificationException; +import java.util.NoSuchElementException; + + public class ArrayList implements List{ public static final int defLen = 10; private Object[] elements; @@ -97,9 +101,32 @@ public int size(){ return size; } -// public Iterator iterator(){ -// return null; -// } + public Iterator iterator(){ + return new ArrayListIterator(); + } + + private class ArrayListIterator implements Iterator{ + int cursor; + + @Override + public boolean hasNext() { + return cursor != size; + } + + @Override + public Object next() { + int i = cursor; + if(i >= size){ + throw new NoSuchElementException(); + } + if (i >= elements.length){ + throw new ConcurrentModificationException(); + } + cursor = i+1; + return elements[i]; + } + } + public static void main(String[] args) { ArrayList list = new ArrayList(); list.add(0); @@ -112,5 +139,10 @@ public static void main(String[] args) { for (int i = 0; i < list.size(); i++) { System.out.println(i+":"+list.get(i)); } + + Iterator it = list.iterator(); + while (it.hasNext()) { + System.out.println(it.next()); + } } } diff --git a/group17/102228177/src/data2_19/List.java b/group17/102228177/src/data2_19/List.java index 95c32f3b27..9f1a3f5ce6 100644 --- a/group17/102228177/src/data2_19/List.java +++ b/group17/102228177/src/data2_19/List.java @@ -1,6 +1,7 @@ package data2_19; public interface List { + public void add(Object o); public void add(int index, Object o); public Object get(int index); From d8e2d779891b7731d9ff5be6c1ecf2c74f97a3bf Mon Sep 17 00:00:00 2001 From: '1299310140' <'13437282785@163.com'> Date: Thu, 23 Feb 2017 15:45:52 +0800 Subject: [PATCH 030/518] ArrayList;LinkedList;Stack;Queue; --- .../src/com/coding/basic/ArrayList.java | 97 ++++++++++ .../src/com/coding/basic/LinkedList.java | 183 ++++++++++++++++++ .../src/com/coding/basic/Queue.java | 29 +++ .../src/com/coding/basic/Stack.java | 34 ++++ 4 files changed, 343 insertions(+) create mode 100644 group04/1299310140/src/com/coding/basic/ArrayList.java create mode 100644 group04/1299310140/src/com/coding/basic/LinkedList.java create mode 100644 group04/1299310140/src/com/coding/basic/Queue.java create mode 100644 group04/1299310140/src/com/coding/basic/Stack.java diff --git a/group04/1299310140/src/com/coding/basic/ArrayList.java b/group04/1299310140/src/com/coding/basic/ArrayList.java new file mode 100644 index 0000000000..fb484db727 --- /dev/null +++ b/group04/1299310140/src/com/coding/basic/ArrayList.java @@ -0,0 +1,97 @@ +package com.coding.basic; + +public class ArrayList implements List { + + private int size = 0; + private Object[] elementData = new Object[10]; + + public void add(Object o){ + if(size < this.elementData.length){//加至末尾,size+1 + this.elementData[size] = o; + size++; + }else{//扩张数组,然后加至末尾,size+1 + this.elementData = grow(this.elementData,10); + this.elementData[size] = o; + size++; + } + } + + public void add(int index, Object o){//-1 this.size){//index小于0or大于size,参数错误 + return; + } + if(size >= this.elementData.length){//当前数组容量已满,需扩张 + this.elementData = grow(this.elementData, 10); + } + + //此时只需考虑将o加至index处(0= index;i--){ + this.elementData[i] = this.elementData[i-1]; + } + this.elementData[index] = o; + this.size++; + }else{//直接插入o,size+1 + this.elementData[index] = o; + this.size++; + } + + } + + public Object get(int index){//-1= this.size){//index小于0or大于等于size,参数错误 + return null; + } + return this.elementData[index]; + } + + public Object remove(int index){//-1= this.size){//index小于0or大于等于size,参数错误 + return null; + } + + Object o = this.elementData[index];//o保存被移除的值 + //此时只需考虑将index处的o移除 + for(int i = index;i < this.size-1;i++){ + this.elementData[i] = this.elementData[i+1]; + } + this.size--; + return o; + } + + public int size(){ + return this.size; + } + + public Iterator iterator(){ + return null; + } + + /* + * 说明:扩张数组 + * 参数:被扩张的原数组,扩张的增加数(扩张后数组的大小为原数组的长度+增加数) + * 返回值:扩张后的数组 + */ + private static Object[] grow(Object[] src,int size){ +// return Arrays.copyOf(src, src.length + size); + Object[] target = new Object[src.length + size]; + System.arraycopy(src, 0, target, 0, src.length); + return target; + } + + public String toString(){ + String result = "["; + if(this.size == 0){ + result = result + "]"; + return result; + }else{ + for(int i = 0;i < size;i++){ + result = result + this.elementData[i] + ","; + } + result = result.substring(0,result.length()-1); + result = result + "]"; + return result; + } + } + +} diff --git a/group04/1299310140/src/com/coding/basic/LinkedList.java b/group04/1299310140/src/com/coding/basic/LinkedList.java new file mode 100644 index 0000000000..ab330879b7 --- /dev/null +++ b/group04/1299310140/src/com/coding/basic/LinkedList.java @@ -0,0 +1,183 @@ +package com.coding.basic; + +public class LinkedList implements List { + + private Node head; + private int size = 0; + + public void add(Object o){ + if(this.size == 0){//size为0,给head赋值 + this.head = new Node(o); + size++; + }else{//将o加至链表末尾 + Node Last = new Node(o); + Node pres = this.head; + while(pres.next != null){ + pres = pres.next; + } + pres.next = Last; + size++; + } + } + + public void add(int index , Object o){//index:0~size + if(index < 0 || index > this.size){//index小于0or大于size,参数错误 + return; + } + if(index == 0){//将o加至链表头部 + //size为0时,index必为0,执行该分支 + Node first = new Node(o); + first.next = this.head; + this.head = first; + size++; + }else if(index == size){//将o加至链表末尾 + //index == size != 0时,执行该分支 + Node Last = new Node(o); + Node pres = this.head; + while(pres.next != null){ + pres = pres.next; + } + pres.next = Last; + size++; + }else{ + //0= this.size){//index小于0or大于等于size,参数错误 + return null; + } + + Node pres = this.head;//pres指向0 + for(int i = 0;i < index;i++){ + pres = pres.next; + } + //此时pres指向index + return pres.data; + } + + public Object remove(int index){//index:0~size-1 + if(index < 0 || index >= this.size){//index小于0or大于等于size,参数错误 + return null; + } + + Object o = null; + if(index == 0){//删除头节点 + o = this.head.data; + this.head = this.head.next; + size--; + }else{//删除头节点以外的其他节点 + Node pres = this.head;//pres指向0 + for(int i = 0;i < index-1;i++){ + pres = pres.next; + } + + //此时pres指向index-1 + o = pres.next.data; + pres.next = pres.next.next; + size--; + } + return o; + } + + public int size(){ + return this.size; + } + + public void addFirst(Object o){//同add(int 0 , Object o) + Node first = new Node(o); + first.next = this.head; + this.head = first; + size++; + } + + public void addLast(Object o){//同add(int size , Object o) + if(this.size == 0){ + this.head = new Node(o); + size++; + }else{//size>=1 + Node Last = new Node(o); + Node pres = this.head; + while(pres.next != null){ + pres = pres.next; + } + pres.next = Last; + size++; + } + } + + public Object removeFirst(){//同remove(int 0) + if(this.size == 0){ + return null; + } + + Object o = this.head.data; + this.head = this.head.next; + size--; + return o; + } + + public Object removeLast(){ + if(this.size == 0){ + return null; + } + + Object o = null; + if(this.size == 1){//size==1 + o = this.head.data; + this.head = null; + this.size--; + }else{//size>=2 + Node pres = this.head; + while(pres.next.next != null){ + pres = pres.next; + } + o = pres.next.data; + pres.next = null; + size--; + } + return o; + } + + public Iterator iterator(){ + return null; + } + + private static class Node{ + Object data; + Node next; + + public Node(Object data) { + super(); + this.data = data; + } + } + + public String toString(){ + String result = "["; + if(this.size == 0){ + result = result + "]"; + return result; + }else{ + Node pres = this.head; + while(pres != null){ + result = result + pres.data + ","; + pres = pres.next; + } + result = result.substring(0,result.length()-1); + result = result + "]"; + return result; + } + } +} diff --git a/group04/1299310140/src/com/coding/basic/Queue.java b/group04/1299310140/src/com/coding/basic/Queue.java new file mode 100644 index 0000000000..181f0cfcb0 --- /dev/null +++ b/group04/1299310140/src/com/coding/basic/Queue.java @@ -0,0 +1,29 @@ +package com.coding.basic; + +public class Queue { + private LinkedList elementData = new LinkedList(); + + public void enQueue(Object o){ + this.elementData.addLast(o); + } + + public Object deQueue(){ + return this.elementData.removeFirst(); + } + + public boolean isEmpty(){ + if(this.elementData.size() == 0){ + return true; + }else{ + return false; + } + } + + public int size(){ + return this.elementData.size(); + } + + public String toString(){ + return this.elementData.toString(); + } +} diff --git a/group04/1299310140/src/com/coding/basic/Stack.java b/group04/1299310140/src/com/coding/basic/Stack.java new file mode 100644 index 0000000000..c0a3adac8e --- /dev/null +++ b/group04/1299310140/src/com/coding/basic/Stack.java @@ -0,0 +1,34 @@ +package com.coding.basic; + +public class Stack { + private ArrayList elementData = new ArrayList(); + + public void push(Object o){ + this.elementData.add(o); + } + + public Object pop(){ + return this.elementData.remove(this.elementData.size()-1); + } + + public Object peek(){ + return this.elementData.get(this.elementData.size()-1); + } + + public boolean isEmpty(){ + if(this.elementData.size() == 0){ + return true; + }else{ + return false; + } + } + + public int size(){ + return this.elementData.size(); + } + + public String toString(){ + return this.elementData.toString(); + } + +} From 0034894b47718db9b8461f1dfbf9e0ee566d553b Mon Sep 17 00:00:00 2001 From: popking008 Date: Thu, 23 Feb 2017 15:51:15 +0800 Subject: [PATCH 031/518] ggg --- group04/274407594/226/.classpath | 6 ++++++ group04/274407594/226/.gitignore | 1 + group04/274407594/226/.project | 17 +++++++++++++++++ .../226/.settings/org.eclipse.jdt.core.prefs | 11 +++++++++++ 4 files changed, 35 insertions(+) create mode 100644 group04/274407594/226/.classpath create mode 100644 group04/274407594/226/.gitignore create mode 100644 group04/274407594/226/.project create mode 100644 group04/274407594/226/.settings/org.eclipse.jdt.core.prefs diff --git a/group04/274407594/226/.classpath b/group04/274407594/226/.classpath new file mode 100644 index 0000000000..fb565a588d --- /dev/null +++ b/group04/274407594/226/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/group04/274407594/226/.gitignore b/group04/274407594/226/.gitignore new file mode 100644 index 0000000000..5e56e040ec --- /dev/null +++ b/group04/274407594/226/.gitignore @@ -0,0 +1 @@ +/bin diff --git a/group04/274407594/226/.project b/group04/274407594/226/.project new file mode 100644 index 0000000000..1f70b883ee --- /dev/null +++ b/group04/274407594/226/.project @@ -0,0 +1,17 @@ + + + 226 + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/group04/274407594/226/.settings/org.eclipse.jdt.core.prefs b/group04/274407594/226/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000000..7341ab1683 --- /dev/null +++ b/group04/274407594/226/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.7 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.7 From bce5fabccbadaaa6893f4585fdc4704d5839459b Mon Sep 17 00:00:00 2001 From: popking008 Date: Thu, 23 Feb 2017 15:57:20 +0800 Subject: [PATCH 032/518] Revert "ggg" This reverts commit 0034894b47718db9b8461f1dfbf9e0ee566d553b. --- group04/274407594/226/.classpath | 6 ------ group04/274407594/226/.gitignore | 1 - group04/274407594/226/.project | 17 ----------------- .../226/.settings/org.eclipse.jdt.core.prefs | 11 ----------- 4 files changed, 35 deletions(-) delete mode 100644 group04/274407594/226/.classpath delete mode 100644 group04/274407594/226/.gitignore delete mode 100644 group04/274407594/226/.project delete mode 100644 group04/274407594/226/.settings/org.eclipse.jdt.core.prefs diff --git a/group04/274407594/226/.classpath b/group04/274407594/226/.classpath deleted file mode 100644 index fb565a588d..0000000000 --- a/group04/274407594/226/.classpath +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - diff --git a/group04/274407594/226/.gitignore b/group04/274407594/226/.gitignore deleted file mode 100644 index 5e56e040ec..0000000000 --- a/group04/274407594/226/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/bin diff --git a/group04/274407594/226/.project b/group04/274407594/226/.project deleted file mode 100644 index 1f70b883ee..0000000000 --- a/group04/274407594/226/.project +++ /dev/null @@ -1,17 +0,0 @@ - - - 226 - - - - - - org.eclipse.jdt.core.javabuilder - - - - - - org.eclipse.jdt.core.javanature - - diff --git a/group04/274407594/226/.settings/org.eclipse.jdt.core.prefs b/group04/274407594/226/.settings/org.eclipse.jdt.core.prefs deleted file mode 100644 index 7341ab1683..0000000000 --- a/group04/274407594/226/.settings/org.eclipse.jdt.core.prefs +++ /dev/null @@ -1,11 +0,0 @@ -eclipse.preferences.version=1 -org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7 -org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve -org.eclipse.jdt.core.compiler.compliance=1.7 -org.eclipse.jdt.core.compiler.debug.lineNumber=generate -org.eclipse.jdt.core.compiler.debug.localVariable=generate -org.eclipse.jdt.core.compiler.debug.sourceFile=generate -org.eclipse.jdt.core.compiler.problem.assertIdentifier=error -org.eclipse.jdt.core.compiler.problem.enumIdentifier=error -org.eclipse.jdt.core.compiler.source=1.7 From feb49da9c53b562cd59644b77aaabddf0e0dd187 Mon Sep 17 00:00:00 2001 From: popking008 Date: Thu, 23 Feb 2017 15:58:14 +0800 Subject: [PATCH 033/518] Revert "Revert "ggg"" This reverts commit bce5fabccbadaaa6893f4585fdc4704d5839459b. --- group04/274407594/226/.classpath | 6 ++++++ group04/274407594/226/.gitignore | 1 + group04/274407594/226/.project | 17 +++++++++++++++++ .../226/.settings/org.eclipse.jdt.core.prefs | 11 +++++++++++ 4 files changed, 35 insertions(+) create mode 100644 group04/274407594/226/.classpath create mode 100644 group04/274407594/226/.gitignore create mode 100644 group04/274407594/226/.project create mode 100644 group04/274407594/226/.settings/org.eclipse.jdt.core.prefs diff --git a/group04/274407594/226/.classpath b/group04/274407594/226/.classpath new file mode 100644 index 0000000000..fb565a588d --- /dev/null +++ b/group04/274407594/226/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/group04/274407594/226/.gitignore b/group04/274407594/226/.gitignore new file mode 100644 index 0000000000..5e56e040ec --- /dev/null +++ b/group04/274407594/226/.gitignore @@ -0,0 +1 @@ +/bin diff --git a/group04/274407594/226/.project b/group04/274407594/226/.project new file mode 100644 index 0000000000..1f70b883ee --- /dev/null +++ b/group04/274407594/226/.project @@ -0,0 +1,17 @@ + + + 226 + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/group04/274407594/226/.settings/org.eclipse.jdt.core.prefs b/group04/274407594/226/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000000..7341ab1683 --- /dev/null +++ b/group04/274407594/226/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.7 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.7 From 4550485e298ac7f53b6ce81e606d092569f043c6 Mon Sep 17 00:00:00 2001 From: Harry Date: Thu, 23 Feb 2017 16:09:38 +0800 Subject: [PATCH 034/518] Add my first code except BinaryTreeNode --- .../coding2017/basic/ArrayListTest.java | 14 ++ .../HarryHook/coding2017/basic/Iterator.java | 7 + .../coding2017/basic/LinkedListTest.java | 93 ++++++++ .../HarryHook/coding2017/basic/List.java | 14 ++ .../HarryHook/coding2017/basic/ListTest.java | 118 ++++++++++ .../coding2017/basic/MyArrayList.java | 153 ++++++++++++ .../coding2017/basic/MyLinkedList.java | 219 ++++++++++++++++++ .../HarryHook/coding2017/basic/MyQueue.java | 54 +++++ .../HarryHook/coding2017/basic/MyStack.java | 59 +++++ .../HarryHook/coding2017/basic/QueueTest.java | 33 +++ .../HarryHook/coding2017/basic/StackTest.java | 40 ++++ 11 files changed, 804 insertions(+) create mode 100644 group02/727171008/src/com/github/HarryHook/coding2017/basic/ArrayListTest.java create mode 100644 group02/727171008/src/com/github/HarryHook/coding2017/basic/Iterator.java create mode 100644 group02/727171008/src/com/github/HarryHook/coding2017/basic/LinkedListTest.java create mode 100644 group02/727171008/src/com/github/HarryHook/coding2017/basic/List.java create mode 100644 group02/727171008/src/com/github/HarryHook/coding2017/basic/ListTest.java create mode 100644 group02/727171008/src/com/github/HarryHook/coding2017/basic/MyArrayList.java create mode 100644 group02/727171008/src/com/github/HarryHook/coding2017/basic/MyLinkedList.java create mode 100644 group02/727171008/src/com/github/HarryHook/coding2017/basic/MyQueue.java create mode 100644 group02/727171008/src/com/github/HarryHook/coding2017/basic/MyStack.java create mode 100644 group02/727171008/src/com/github/HarryHook/coding2017/basic/QueueTest.java create mode 100644 group02/727171008/src/com/github/HarryHook/coding2017/basic/StackTest.java diff --git a/group02/727171008/src/com/github/HarryHook/coding2017/basic/ArrayListTest.java b/group02/727171008/src/com/github/HarryHook/coding2017/basic/ArrayListTest.java new file mode 100644 index 0000000000..bd15f2a404 --- /dev/null +++ b/group02/727171008/src/com/github/HarryHook/coding2017/basic/ArrayListTest.java @@ -0,0 +1,14 @@ +package com.github.HarryHook.coding2017.basic; + +import org.junit.Before; +import com.github.HarryHook.coding2017.basic.MyArrayList; + + +public class ArrayListTest extends ListTest { + + @Before + public void setUpArrayList() { + aList = new MyArrayList(); + } + +} diff --git a/group02/727171008/src/com/github/HarryHook/coding2017/basic/Iterator.java b/group02/727171008/src/com/github/HarryHook/coding2017/basic/Iterator.java new file mode 100644 index 0000000000..3fae84a22f --- /dev/null +++ b/group02/727171008/src/com/github/HarryHook/coding2017/basic/Iterator.java @@ -0,0 +1,7 @@ +package com.github.HarryHook.coding2017.basic; + +public interface Iterator +{ + public boolean hasNext(); + public Object next(); +} diff --git a/group02/727171008/src/com/github/HarryHook/coding2017/basic/LinkedListTest.java b/group02/727171008/src/com/github/HarryHook/coding2017/basic/LinkedListTest.java new file mode 100644 index 0000000000..314c774dea --- /dev/null +++ b/group02/727171008/src/com/github/HarryHook/coding2017/basic/LinkedListTest.java @@ -0,0 +1,93 @@ +package com.github.HarryHook.coding2017.basic; + +import static org.junit.Assert.*; +import org.junit.Before; +import org.junit.Test; +import com.github.HarryHook.coding2017.basic.MyLinkedList; + +public class LinkedListTest extends ListTest{ + + private MyLinkedList aLinkedList; + + @Before + public void setUpLinkedList() { + aList = new MyLinkedList(); + aLinkedList = new MyLinkedList(); + } + + @Test + public void testAddFirst() { + aLinkedList.addFirst(5); + assertEquals(5, aLinkedList.get(0)); + + aLinkedList.addFirst(6); + assertEquals(6, aLinkedList.get(0)); + assertEquals(5, aLinkedList.get(1)); + assertEquals(2, aLinkedList.size()); + } + + @Test + public void testAddLast() { + aLinkedList.addLast("hello"); + assertEquals("hello", aLinkedList.get(0)); + + aLinkedList.addLast("world"); + assertEquals("hello", aLinkedList.get(0)); + assertEquals("world", aLinkedList.get(1)); + assertEquals(2, aLinkedList.size()); + } + + @Test + public void testRemoveFirst() { + aLinkedList.addLast("hello"); + aLinkedList.addLast("world"); + + aLinkedList.removeFirst(); + assertEquals("world", aLinkedList.get(0)); + assertEquals(1, aLinkedList.size()); + + aLinkedList.removeFirst(); + assertEquals(0, aLinkedList.size()); + } + + @Test + public void testRemoveLast() { + aLinkedList.addFirst("world"); + aLinkedList.addFirst("hello"); + + aLinkedList.removeLast(); + assertEquals("hello", aLinkedList.get(0)); + assertEquals(1, aLinkedList.size()); + + aLinkedList.removeLast(); + assertEquals(0, aLinkedList.size()); + } + + @Test + public void testLinkedListFunctional() { + for (int i=1; i<4; i++) { + aLinkedList.add(i); // [1,2,3] + } + aLinkedList.remove(1); // [1,3] + + aLinkedList.add(1, 0); // [1,0,3] + for (int i=4; i<6; i++) { + aLinkedList.addFirst(i); // [5, 4, 1, 0, 3] + } + assertEquals(5, aLinkedList.size()); + assertEquals(5, aLinkedList.get(0)); + assertEquals(1, aLinkedList.get(2)); + assertEquals(4, aLinkedList.get(3)); + + aLinkedList.remove(3); // [5, 4, 1, 3] + assertEquals(3, aLinkedList.get(aLinkedList.size()-1)); + aLinkedList.removeLast(); // [5, 4, 1] + assertEquals(1, aLinkedList.get(aLinkedList.size()-1)); + aLinkedList.removeFirst(); // [4,1] + + assertEquals(4, aLinkedList.get(0)); + assertEquals(1, aLinkedList.get(1)); + assertEquals(2, aLinkedList.size()); + } + +} diff --git a/group02/727171008/src/com/github/HarryHook/coding2017/basic/List.java b/group02/727171008/src/com/github/HarryHook/coding2017/basic/List.java new file mode 100644 index 0000000000..f2299e8e83 --- /dev/null +++ b/group02/727171008/src/com/github/HarryHook/coding2017/basic/List.java @@ -0,0 +1,14 @@ +package com.github.HarryHook.coding2017.basic; + + +public interface List +{ + public void add(Object o); + public void add(int index, Object o); + public Object get(int index); + public Object remove(int index); + public int size(); + + public Iterator iterator(); +} + diff --git a/group02/727171008/src/com/github/HarryHook/coding2017/basic/ListTest.java b/group02/727171008/src/com/github/HarryHook/coding2017/basic/ListTest.java new file mode 100644 index 0000000000..b5680990ea --- /dev/null +++ b/group02/727171008/src/com/github/HarryHook/coding2017/basic/ListTest.java @@ -0,0 +1,118 @@ +package com.github.HarryHook.coding2017.basic; + +import static org.junit.Assert.*; + +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.ExpectedException; +import com.github.HarryHook.coding2017.basic.Iterator; +import com.github.HarryHook.coding2017.basic.List; + +public class ListTest { + + protected static List aList; + + @Test + public void testFunctional() { + aList.add(1); + aList.add(2); + assertEquals(1, aList.get(0)); + assertEquals(2, aList.get(1)); + + aList.add(3); + aList.add(0, 5); + aList.add(2, 11); + assertEquals(5, aList.get(0)); + assertEquals(11, aList.get(2)); + + aList.add("hi"); + assertEquals("hi", aList.get(5)); + assertEquals(6, aList.size()); + + aList.remove(1); + assertEquals(11, aList.get(1)); + assertEquals(2, aList.get(2)); + + assertEquals(5, aList.size()); + } + + @Test + public void testAdd() { + for (int i=0; i<100; i++) + aList.add(i); + assertEquals(0, aList.get(0)); + assertEquals(99, aList.get(99)); + assertEquals(44, aList.get(44)); + } + + @Test + public void testRemove() { + aList.add(1); + aList.add(2); + aList.add(3); + int u = (Integer)aList.remove(2); + assertEquals(3, u); + assertEquals(2, aList.size()); + + aList.add(1, 5); + u = (Integer)aList.remove(0); + assertEquals(1, u); + assertEquals(5, aList.get(0)); + assertEquals(2, aList.get(1)); + assertEquals(2, aList.size()); + + aList.remove(0); + aList.remove(0); + assertEquals(0, aList.size()); + + + } + + @Test + public void testSize() { + for (int i=0; i<10; i++) + aList.add(i*2); + assertEquals(10, aList.size()); + } + + @Rule + public ExpectedException expectedEx = ExpectedException.none(); + + @Test + public void testException() { + expectedEx.expect(Exception.class); + aList.remove(1); + aList.add(3); + aList.add(2, 5); + expectedEx.expect(Exception.class); + } + + @Test + //protected static List aList; + + public void testIterator() { + Iterator it = aList.iterator(); + assertEquals(false, it.hasNext()); + + aList.add(1); + aList.add(2); + aList.add(3); + + it = aList.iterator(); + assertEquals(true, it.hasNext()); + assertEquals(1, it.next()); + assertEquals(2, it.next()); + assertEquals(3, it.next()); + assertEquals(false, it.hasNext()); + + aList.remove(1); + it = aList.iterator(); + assertEquals(true, it.hasNext()); + assertEquals(1, it.next()); + assertEquals(3, it.next()); + assertEquals(false, it.hasNext()); + } + + + +} diff --git a/group02/727171008/src/com/github/HarryHook/coding2017/basic/MyArrayList.java b/group02/727171008/src/com/github/HarryHook/coding2017/basic/MyArrayList.java new file mode 100644 index 0000000000..3ceb922c53 --- /dev/null +++ b/group02/727171008/src/com/github/HarryHook/coding2017/basic/MyArrayList.java @@ -0,0 +1,153 @@ +/* + * created by Harry 2017-2-20 18:53:38 + * 实现简单的ArrayList,具有基本的增删改查功能 + */ +package com.github.HarryHook.coding2017.basic; + +import java.util.Arrays; + +public class MyArrayList implements List +{ + private int size = 0; //数组元素个数 + + private Object[] elementData = new Object[10]; //初始化数组大小为10 + + //将元素添加到数组尾部 + public void add(Object o) + { //需要判断数组空间是否够用 + ensureCapacity(size + 1); + elementData[size++] = o; + } + //在指定位置添加元素 + public void add(int index, Object o) + { + //判断下标记是否越界 + if (index > size || index < 0) + throw new IndexOutOfBoundsException( + "Index: " + index + ", Size: " + size); + ensureCapacity(size + 1); + //判断当前位置是否有元素,没有元素添加到当前位置;若有,当前元素及之后元素向右移 + if(elementData[index] == null) + { + elementData[index] = o; + } + else + { + for(int i=elementData.length-1; i>index; i--) + { + elementData[i] = elementData[i-1]; + } + elementData[index] = o; + } + size++; + /* + //判断索引位置是否正确 + if (index > size || index < 0) + throw new IndexOutOfBoundsException( + "Index: " + index + ", Size: " + size); + //扩容检测 + ensureCapacity(size+1); + /* + * 对源数组进行复制处理(位移),从index + 1到size-index。 + * 主要目的就是空出index位置供数据插入, + * 即向右移动当前位于该位置的元素以及所有后续元素。 + + System.arraycopy(elementData, index, elementData, index + 1, + size - index); + //在指定位置赋值 + elementData[index] = 0; + size++; + + */ + } + + public Object get(int index) + { + return elementData[index]; + } + + public Object remove(int index) + { //涉及到元素移位 + Object oldValue = elementData[index]; + for(int i=index; i oldCapacity) + { + Object oldData[] = elementData; //防止copyof()执行的过程中新内存或者其他进程分配内存时占用旧内存 + int newCapacity = (oldCapacity * 3)/2 + 1; //增加50%+1 + if (newCapacity < minCapacity) + newCapacity = minCapacity; + // minCapacity is usually close to size, so this is a win: + elementData = Arrays.copyOf(elementData, newCapacity); + } + } + + //返回数组的大小 + public int size() + { + return size; + } + + public Iterator iterator() + { + return new MyArrayListIterator(); + } + + private class MyArrayListIterator implements Iterator + { + private int cursor = 0; //记录索引位置 + public boolean hasNext() + { + return cursor != size; + } + public Object next() + { + Object next = get(cursor); + cursor ++; + return next; + } + } + + public static void main(String[] args) + { + MyArrayList myArrays = new MyArrayList(); + + for(int i = 0; i < 19; i++) + myArrays.add(i, 55); + + myArrays.add(3); + myArrays.add(0, 11); + myArrays.add(1, 2); + myArrays.add(3, 5); + myArrays.add(2, 1); + myArrays.add(7); + System.out.println("获取指定位置元素: " + myArrays.get(2)); + System.out.println("删除指定位置元素: " + myArrays.remove(1)); + System.out.println("当前元素个数:" + myArrays.size()); + + Print(myArrays); + + } + public static void Print(MyArrayList myArrays) + { + Iterator it = myArrays.iterator(); + System.out.println("对链表中的元素进行打印:"); + while(it.hasNext()) + System.out.print(it.next() + " "); + System.out.println(""); + System.out.println("当前元素个数: " + myArrays.size()); + + } + +} + diff --git a/group02/727171008/src/com/github/HarryHook/coding2017/basic/MyLinkedList.java b/group02/727171008/src/com/github/HarryHook/coding2017/basic/MyLinkedList.java new file mode 100644 index 0000000000..5aeab57496 --- /dev/null +++ b/group02/727171008/src/com/github/HarryHook/coding2017/basic/MyLinkedList.java @@ -0,0 +1,219 @@ +/* + * created by Harry 2017-2-21 14:43:41 + * 实现简单的LinkedList + */ + +package com.github.HarryHook.coding2017.basic; + +public class MyLinkedList implements List +{ + private Node head = null; //头指针 + private int size = 0; + private static class Node + { + Object data; + Node next; + } + public void add(Object o) + { + addLast(o); + } + //在指定位置添加元素 + public void add(int index , Object o) + { + + if (index > size || index < 0) + throw new IndexOutOfBoundsException("Index: " + index + ", Size: " + size); + //存在插入头结点的情况 + if(index == 0) + addFirst(o); + else + { //即 index != 0 的情况 + // p保存待插入节点的前一节点,x指向要插入的节点 + Node x = head; + Node p = null; + int i = 0; + while(i < index) + { + p = x; + x = x.next; + i++; + } + Node n = new Node(); + p.next = n; + n.next = x; + n.data = o; + size++; + } + + } + //返回指定位置元素 + public Object get(int index) + { + Node x = head; + int i = 0; + while(i < index && x != null) + { + x = x.next; + i++; + } + return x.data; + } + + //移除指定位置节点 + public Object remove(int index) + { + if (index > size || index < 0) + throw new IndexOutOfBoundsException("Index: " + index + ", Size: " + size); + //先判断是否是头节点 + if( index == 0) + { + return removeFirst(); + } + else + { + Node x = head; + Node pre = null; + int i = 0; + while(i < index) + { + pre = x; + x = x.next; + i++; + } + Object Data = pre.next.data; + pre.next = x.next; + x = null; + size--; + return Data; + } + + } + //头部添加节点 + public void addFirst(Object o) + { + Node n = new Node(); + n.next = head; + head = n; + n.data = o; + size++; + } + //尾部添加节点 + public void addLast(Object o) + { + if (head == null) + { + head = new Node(); + head.data = o; + } + else + { + Node x = head; + while(x.next != null) + { + x = x.next; + } + Node n = new Node(); + x.next = n; + n.next = null; + n.data = o; + } + size++; + } + //移除第一个节点 + public Object removeFirst() + { + Node n = head; + Object Data = n.data; + head = head.next; + n = null; + size--; + return Data; + } + + //移除最后一个节点 + //removeLast()方法存在bug + public Object removeLast() + { + Node x = head; + Node p = null; + if(x.next == null) + { + return removeFirst(); + } + else + { + while(x.next != null) + { + p = x; + x = x.next; + } + Object Data = x.data; + p.next = null; + x = null; //删除最后一个节点 + size--; + return Data; + } + } + public int size(){ + return size; + } + public Iterator iterator() + { + return new MyLinkedListIterator(); + } + private class MyLinkedListIterator implements Iterator + { + private int cursor = 0; //记录索引位置 + public boolean hasNext() + { + return cursor != size; + } + public Object next() + { + Object next = get(cursor); + cursor ++; + return next; + } + } + public static void main(String[] args) + { + MyLinkedList myList = new MyLinkedList(); + myList.add(3); + myList.add(5); + myList.add(0, 4); + myList.add(2, 7); + myList.addFirst(1); + myList.addLast(6); + + Print(myList); + + System.out.println("当前指定位置元素: " + myList.get(1)); + System.out.println("移除指定位置元素: " + myList.remove(4)); + Print(myList); + + System.out.println("移除第一个节点元素: " + myList.removeLast()); + Print(myList); + System.out.println("移除最后一个节点元素: " + myList.removeLast()); + Print(myList); + System.out.println("移除最后一个节点元素: " + myList.removeLast()); + Print(myList); + System.out.println("移除最后一个节点元素: " + myList.removeLast()); + Print(myList); + System.out.println("移除最后一个节点元素: " + myList.removeLast()); + Print(myList); + + } + public static void Print(MyLinkedList myList) + { + Iterator it = myList.iterator(); + System.out.println("对链表中的元素进行打印:"); + while(it.hasNext()) + System.out.print(it.next() + " "); + System.out.println(""); + System.out.println("当前元素个数: " + myList.size()); + System.out.println(""); + } + + +} diff --git a/group02/727171008/src/com/github/HarryHook/coding2017/basic/MyQueue.java b/group02/727171008/src/com/github/HarryHook/coding2017/basic/MyQueue.java new file mode 100644 index 0000000000..9b713eaea9 --- /dev/null +++ b/group02/727171008/src/com/github/HarryHook/coding2017/basic/MyQueue.java @@ -0,0 +1,54 @@ +/* + * created by Harry 2017-2-22 13:06:43 + * 实现简单的队列 + */ +package com.github.HarryHook.coding2017.basic; +import java.util.*; +public class MyQueue +{ + private MyArrayList elementData = new MyArrayList(); + private int size = 0; + //入队 + public void enQueue(Object o) + { + elementData.add(o); + size++; + } + //出队 + public Object deQueue() + { + if(isEmpty()) + throw new NoSuchElementException(); + Object Data = elementData.remove(0); + size--; + return Data; + } + //判断队列是否为空 + public boolean isEmpty() + { + return size() == 0; + } + //队列中元素个数 + public int size() + { + return size; + } + public static void main(String[] args) + { + MyQueue mq = new MyQueue(); + mq.enQueue(1); + mq.enQueue(2); + mq.enQueue(3); + mq.enQueue(4); + System.out.println("队列出栈,出栈元素为: " + mq.deQueue()); + System.out.println("队列中元素个数: " + mq.size()); + System.out.println("队列出栈,出栈元素为: " + mq.deQueue()); + System.out.println("队列中元素个数: " + mq.size()); + System.out.println("队列出栈,出栈元素为: " + mq.deQueue()); + System.out.println("队列中元素个数: " + mq.size()); + System.out.println("队列出栈,出栈元素为: " + mq.deQueue()); + System.out.println("队列中元素个数: " + mq.size()); + //System.out.println("队列出栈,出栈元素为: " + mq.deQueue()); + //System.out.println("队列中元素个数: " + mq.size()); + } +} diff --git a/group02/727171008/src/com/github/HarryHook/coding2017/basic/MyStack.java b/group02/727171008/src/com/github/HarryHook/coding2017/basic/MyStack.java new file mode 100644 index 0000000000..c7f87c04e6 --- /dev/null +++ b/group02/727171008/src/com/github/HarryHook/coding2017/basic/MyStack.java @@ -0,0 +1,59 @@ +/* + * created by Harry 2017-2-22 10:48:34 + * 实现简单的Stack + */ +package com.github.HarryHook.coding2017.basic; + +import java.util.*; + +public class MyStack +{ + private MyArrayList elementData = new MyArrayList(); + private int size = 0; + + //入栈操作 + public void push(Object o) + { + elementData.add(o); + size++; + } + //出栈操作 + public Object pop() + { + Object obj = peek(); + elementData.remove(size() - 1); + size--; + return obj; + } + //获取当前栈顶元素,不用出栈 + public Object peek() + { + if(isEmpty()) + throw new EmptyStackException(); + return elementData.get(size() - 1); + } + //判断栈是否为空 + public boolean isEmpty() + { + return size() == 0; + } + //返回栈内元素个数 + public int size(){ + return size; + } + + public static void main(String[] args) + { + MyStack ms = new MyStack(); + + ms.push(1); + ms.push(2); + ms.push(13); + System.out.println("当前栈顶元素是: " + ms.peek()); + System.out.println("出栈元素是: " + ms.pop()); + System.out.println("出栈元素是: " + ms.pop()); + ms.push(12); + System.out.println("出栈元素是: " + ms.pop()); + System.out.println("当前栈顶元素是: " + ms.peek()); + } +} diff --git a/group02/727171008/src/com/github/HarryHook/coding2017/basic/QueueTest.java b/group02/727171008/src/com/github/HarryHook/coding2017/basic/QueueTest.java new file mode 100644 index 0000000000..340f79d240 --- /dev/null +++ b/group02/727171008/src/com/github/HarryHook/coding2017/basic/QueueTest.java @@ -0,0 +1,33 @@ +package com.github.HarryHook.coding2017.basic; + +import static org.junit.Assert.*; +import org.junit.Before; +import org.junit.Test; +import com.github.HarryHook.coding2017.basic.MyQueue; + +public class QueueTest { + private MyQueue queue; + + @Before + public void setUpQueue() { + queue = new MyQueue(); + } + + @Test + public void testQueueFunctional() { + assertEquals(true, queue.isEmpty()); + queue.enQueue(4); + queue.enQueue(2); + assertEquals(2, queue.size()); + assertEquals(false, queue.isEmpty()); + + int i = (Integer)queue.deQueue(); + assertEquals(4, i); + i = (Integer)queue.deQueue(); + assertEquals(2, i); + + assertEquals(0, queue.size()); + assertEquals(true, queue.isEmpty()); + } + +} diff --git a/group02/727171008/src/com/github/HarryHook/coding2017/basic/StackTest.java b/group02/727171008/src/com/github/HarryHook/coding2017/basic/StackTest.java new file mode 100644 index 0000000000..26160faef6 --- /dev/null +++ b/group02/727171008/src/com/github/HarryHook/coding2017/basic/StackTest.java @@ -0,0 +1,40 @@ +package com.github.HarryHook.coding2017.basic; + +import static org.junit.Assert.*; + +import org.junit.Before; +import org.junit.Test; + +import com.github.HarryHook.coding2017.basic.MyStack; + +public class StackTest { + + private MyStack stack; + + @Before + public void setUpStack() { + stack = new MyStack(); + } + + @Test + public void testStackFunctional() { + assertEquals(true, stack.isEmpty()); + stack.push(4); + stack.push(2); + assertEquals(2, stack.size()); + assertEquals(false, stack.isEmpty()); + + int i = (Integer)stack.pop(); + assertEquals(2, i); + + i = (Integer)stack.peek(); + assertEquals(4, i); + + i = (Integer)stack.pop(); + assertEquals(4, i); + + assertEquals(0, stack.size()); + assertEquals(true, stack.isEmpty()); + } + +} From ec6412330824ea8f7c7c91c8645135867d02d180 Mon Sep 17 00:00:00 2001 From: zoakerc Date: Thu, 23 Feb 2017 17:00:45 +0800 Subject: [PATCH 035/518] =?UTF-8?q?=E5=88=9D=E5=A7=8B=E5=8C=96homework?= =?UTF-8?q?=E4=BD=9C=E4=B8=9A=E7=9B=AE=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- group07/562247675/homework/.gitignore | 22 ++++++++++++++++++++++ group07/562247675/homework/readme.md | 1 + 2 files changed, 23 insertions(+) create mode 100644 group07/562247675/homework/.gitignore create mode 100644 group07/562247675/homework/readme.md diff --git a/group07/562247675/homework/.gitignore b/group07/562247675/homework/.gitignore new file mode 100644 index 0000000000..df3ade545c --- /dev/null +++ b/group07/562247675/homework/.gitignore @@ -0,0 +1,22 @@ +rebel.xml +.idea/ +*.iml +target/ +*.class +*.jar +*.war +*.ear +hs_err_pid* +*.DS_Store +._* +.Trashes +.TemporaryItems +desktop.ini +Thumbs.db +$RECYCLE.BIN/ +*.lnk +.metadata +.settings +.classpath +.mymetadata +.project \ No newline at end of file diff --git a/group07/562247675/homework/readme.md b/group07/562247675/homework/readme.md new file mode 100644 index 0000000000..2a54b7ef9a --- /dev/null +++ b/group07/562247675/homework/readme.md @@ -0,0 +1 @@ +# Homework \ No newline at end of file From 2d70c98a1cc5e0f69a7ca92249d1259b55d5f408 Mon Sep 17 00:00:00 2001 From: zoakerc Date: Thu, 23 Feb 2017 17:01:02 +0800 Subject: [PATCH 036/518] =?UTF-8?q?=E5=88=9D=E5=A7=8B=E5=8C=96homework?= =?UTF-8?q?=E9=A1=B9=E7=9B=AE=E7=BB=93=E6=9E=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- group07/562247675/homework/pom.xml | 53 ++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 group07/562247675/homework/pom.xml diff --git a/group07/562247675/homework/pom.xml b/group07/562247675/homework/pom.xml new file mode 100644 index 0000000000..17a2c5f0fd --- /dev/null +++ b/group07/562247675/homework/pom.xml @@ -0,0 +1,53 @@ + + + + 4.0.0 + + com.coding2017.group7 + homework + 1.0-SNAPSHOT + + + homework-0226 + + + pom + + UTF-8 + 1.6 + 1.6 + + + + + junit + junit + 4.12 + + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + + ${maven.compiler.source} + ${maven.compiler.target} + ${project.build.sourceEncoding} + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + + + + From b76c841d8aeb8a8c65b9b849e371b0016a4dc938 Mon Sep 17 00:00:00 2001 From: zoakerc Date: Thu, 23 Feb 2017 17:02:32 +0800 Subject: [PATCH 037/518] =?UTF-8?q?=E5=88=9D=E5=A7=8B=E5=8C=960226?= =?UTF-8?q?=E4=BD=9C=E4=B8=9A=E6=A8=A1=E5=9D=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../562247675/homework/homework-0226/pom.xml | 22 ++++++++ .../group7/homework/c0226/ArrayList.java | 33 ++++++++++++ .../group7/homework/c0226/BinaryTreeNode.java | 37 +++++++++++++ .../group7/homework/c0226/Iterator.java | 8 +++ .../group7/homework/c0226/LinkedList.java | 53 +++++++++++++++++++ .../group7/homework/c0226/List.java | 13 +++++ .../group7/homework/c0226/Queue.java | 19 +++++++ .../group7/homework/c0226/Stack.java | 24 +++++++++ .../src/main/resources/readme.md | 0 .../src/test/resources/readme.md | 0 group07/562247675/notebook/readme.md | 1 + 11 files changed, 210 insertions(+) create mode 100644 group07/562247675/homework/homework-0226/pom.xml create mode 100644 group07/562247675/homework/homework-0226/src/main/java/com/coding2017/group7/homework/c0226/ArrayList.java create mode 100644 group07/562247675/homework/homework-0226/src/main/java/com/coding2017/group7/homework/c0226/BinaryTreeNode.java create mode 100644 group07/562247675/homework/homework-0226/src/main/java/com/coding2017/group7/homework/c0226/Iterator.java create mode 100644 group07/562247675/homework/homework-0226/src/main/java/com/coding2017/group7/homework/c0226/LinkedList.java create mode 100644 group07/562247675/homework/homework-0226/src/main/java/com/coding2017/group7/homework/c0226/List.java create mode 100644 group07/562247675/homework/homework-0226/src/main/java/com/coding2017/group7/homework/c0226/Queue.java create mode 100644 group07/562247675/homework/homework-0226/src/main/java/com/coding2017/group7/homework/c0226/Stack.java create mode 100644 group07/562247675/homework/homework-0226/src/main/resources/readme.md create mode 100644 group07/562247675/homework/homework-0226/src/test/resources/readme.md create mode 100644 group07/562247675/notebook/readme.md diff --git a/group07/562247675/homework/homework-0226/pom.xml b/group07/562247675/homework/homework-0226/pom.xml new file mode 100644 index 0000000000..f6a6002f6d --- /dev/null +++ b/group07/562247675/homework/homework-0226/pom.xml @@ -0,0 +1,22 @@ + + + + com.coding2017.group7 + homework + 1.0-SNAPSHOT + + 4.0.0 + + com.coding2017.group7 + homework-0226 + + + junit + junit + + + + \ No newline at end of file diff --git a/group07/562247675/homework/homework-0226/src/main/java/com/coding2017/group7/homework/c0226/ArrayList.java b/group07/562247675/homework/homework-0226/src/main/java/com/coding2017/group7/homework/c0226/ArrayList.java new file mode 100644 index 0000000000..3381bbee8b --- /dev/null +++ b/group07/562247675/homework/homework-0226/src/main/java/com/coding2017/group7/homework/c0226/ArrayList.java @@ -0,0 +1,33 @@ +package com.coding2017.group7.homework.c0226; + +public class ArrayList implements List { + + private int size = 0; + + private Object[] elementData = new Object[100]; + + 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 Iterator iterator() { + return null; + } + +} diff --git a/group07/562247675/homework/homework-0226/src/main/java/com/coding2017/group7/homework/c0226/BinaryTreeNode.java b/group07/562247675/homework/homework-0226/src/main/java/com/coding2017/group7/homework/c0226/BinaryTreeNode.java new file mode 100644 index 0000000000..b666a31c31 --- /dev/null +++ b/group07/562247675/homework/homework-0226/src/main/java/com/coding2017/group7/homework/c0226/BinaryTreeNode.java @@ -0,0 +1,37 @@ +package com.coding2017.group7.homework.c0226; + +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/group07/562247675/homework/homework-0226/src/main/java/com/coding2017/group7/homework/c0226/Iterator.java b/group07/562247675/homework/homework-0226/src/main/java/com/coding2017/group7/homework/c0226/Iterator.java new file mode 100644 index 0000000000..f97b7dfdd3 --- /dev/null +++ b/group07/562247675/homework/homework-0226/src/main/java/com/coding2017/group7/homework/c0226/Iterator.java @@ -0,0 +1,8 @@ +package com.coding2017.group7.homework.c0226; + +public interface Iterator { + public boolean hasNext(); + + public Object next(); + +} diff --git a/group07/562247675/homework/homework-0226/src/main/java/com/coding2017/group7/homework/c0226/LinkedList.java b/group07/562247675/homework/homework-0226/src/main/java/com/coding2017/group7/homework/c0226/LinkedList.java new file mode 100644 index 0000000000..4c2ed0c5dc --- /dev/null +++ b/group07/562247675/homework/homework-0226/src/main/java/com/coding2017/group7/homework/c0226/LinkedList.java @@ -0,0 +1,53 @@ +package com.coding2017.group7.homework.c0226; + +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; + + } +} diff --git a/group07/562247675/homework/homework-0226/src/main/java/com/coding2017/group7/homework/c0226/List.java b/group07/562247675/homework/homework-0226/src/main/java/com/coding2017/group7/homework/c0226/List.java new file mode 100644 index 0000000000..5d462e3ebd --- /dev/null +++ b/group07/562247675/homework/homework-0226/src/main/java/com/coding2017/group7/homework/c0226/List.java @@ -0,0 +1,13 @@ +package com.coding2017.group7.homework.c0226; + +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/group07/562247675/homework/homework-0226/src/main/java/com/coding2017/group7/homework/c0226/Queue.java b/group07/562247675/homework/homework-0226/src/main/java/com/coding2017/group7/homework/c0226/Queue.java new file mode 100644 index 0000000000..6ce10c6cef --- /dev/null +++ b/group07/562247675/homework/homework-0226/src/main/java/com/coding2017/group7/homework/c0226/Queue.java @@ -0,0 +1,19 @@ +package com.coding2017.group7.homework.c0226; + +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/group07/562247675/homework/homework-0226/src/main/java/com/coding2017/group7/homework/c0226/Stack.java b/group07/562247675/homework/homework-0226/src/main/java/com/coding2017/group7/homework/c0226/Stack.java new file mode 100644 index 0000000000..b75c78b8fd --- /dev/null +++ b/group07/562247675/homework/homework-0226/src/main/java/com/coding2017/group7/homework/c0226/Stack.java @@ -0,0 +1,24 @@ +package com.coding2017.group7.homework.c0226; + +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/group07/562247675/homework/homework-0226/src/main/resources/readme.md b/group07/562247675/homework/homework-0226/src/main/resources/readme.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/group07/562247675/homework/homework-0226/src/test/resources/readme.md b/group07/562247675/homework/homework-0226/src/test/resources/readme.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/group07/562247675/notebook/readme.md b/group07/562247675/notebook/readme.md new file mode 100644 index 0000000000..d36f4b9c53 --- /dev/null +++ b/group07/562247675/notebook/readme.md @@ -0,0 +1 @@ +# Notebook \ No newline at end of file From b9d53571f55c2b0946469139766b8b7ae6469988 Mon Sep 17 00:00:00 2001 From: zoakerc Date: Thu, 23 Feb 2017 17:02:53 +0800 Subject: [PATCH 038/518] =?UTF-8?q?=E5=88=9D=E5=A7=8B=E5=8C=96ArrayList?= =?UTF-8?q?=E6=B5=8B=E8=AF=95=E7=B1=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../group7/homework/c0226/ArrayListTest.java | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 group07/562247675/homework/homework-0226/src/test/java/com/coding2017/group7/homework/c0226/ArrayListTest.java diff --git a/group07/562247675/homework/homework-0226/src/test/java/com/coding2017/group7/homework/c0226/ArrayListTest.java b/group07/562247675/homework/homework-0226/src/test/java/com/coding2017/group7/homework/c0226/ArrayListTest.java new file mode 100644 index 0000000000..3a3a4fb045 --- /dev/null +++ b/group07/562247675/homework/homework-0226/src/test/java/com/coding2017/group7/homework/c0226/ArrayListTest.java @@ -0,0 +1,11 @@ +package com.coding2017.group7.homework.c0226; + +import org.junit.Test; + +public class ArrayListTest { + @Test + public void add() throws Exception { + + } + +} \ No newline at end of file From 11f922265f2532e7aad2b651894871ccb7617f03 Mon Sep 17 00:00:00 2001 From: JayXu Date: Thu, 23 Feb 2017 17:03:23 +0800 Subject: [PATCH 039/518] commit --- group15/1511_714512544/.idea/workspace.xml | 800 +++++++++++++++++++++ 1 file changed, 800 insertions(+) create mode 100644 group15/1511_714512544/.idea/workspace.xml diff --git a/group15/1511_714512544/.idea/workspace.xml b/group15/1511_714512544/.idea/workspace.xml new file mode 100644 index 0000000000..8df02d2252 --- /dev/null +++ b/group15/1511_714512544/.idea/workspace.xml @@ -0,0 +1,800 @@ + + + + + + + + + + + + + + + + + + + + + + + + true + DEFINITION_ORDER + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + project + + + + + + + + + + + + + + + + project + + + true + + + + DIRECTORY + + false + + + + + + + + + + + + + + + + + + + + + + + + + + 1487829138626 + + + 1487829266287 + + + 1487829432867 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + No facets are configured + + + + + + + + + + + + + + + 1.8 + + + + + + + + 1511_714512544 + + + + + + + + 1.8 + + + + + + + + + + + + + + + \ No newline at end of file From 9f1df17e632be18aacd30ed801defb083f30b9d2 Mon Sep 17 00:00:00 2001 From: guodongym Date: Thu, 23 Feb 2017 17:24:13 +0800 Subject: [PATCH 040/518] =?UTF-8?q?=E9=93=BE=E8=A1=A8=E5=AE=9E=E7=8E=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/guodong/datastructure/LinkedList.java | 166 +++++++++++++++--- 1 file changed, 144 insertions(+), 22 deletions(-) diff --git a/group12/377401843/learning_1/src/com/guodong/datastructure/LinkedList.java b/group12/377401843/learning_1/src/com/guodong/datastructure/LinkedList.java index fc801505f1..7616768930 100644 --- a/group12/377401843/learning_1/src/com/guodong/datastructure/LinkedList.java +++ b/group12/377401843/learning_1/src/com/guodong/datastructure/LinkedList.java @@ -1,45 +1,167 @@ package com.guodong.datastructure; public class LinkedList implements List { - + + private int size; + private Node head; - - public void add(Object o){ - + + private Node last; + + /** + * 向 链表尾端插入元素 + * + * @Method add + * @param o + * @see com.guodong.datastructure.List#add(java.lang.Object) + */ + public void add(Object o) { + linkLast(o); } - public void add(int index , Object o){ - + + /** + * 向链表指定位置插入元素 + * + * @Method add + * @param index + * @param o + * @see com.guodong.datastructure.List#add(int, java.lang.Object) + */ + public void add(int index, Object o) { + checkIndexForAdd(index); + + if (index == size) { + linkLast(o); + } else { + Node prevNode = getNodeByIndex(index - 1); // 取到当前下标的前一个节点 + Node currentNode = getNodeByIndex(index); // 取到当前下标节点 + Node newNode = new Node(o, currentNode); // 创建新节点,新节点的下一个节点为当前下标节点 + + if (prevNode == null) { // 如果前一个节点为空,说明从头部插入 + head = newNode; + } else { + prevNode.next = newNode; + } + size++; + } } - public Object get(int index){ - return null; + + /** + * 根据下标获取链表中元素 + * + * @Method get + * @param index + * @return + * @see com.guodong.datastructure.List#get(int) + */ + public Object get(int index) { + checkIndexForGet(index); + return getNodeByIndex(index).data; } - public Object remove(int index){ + + public Object remove(int index) { return null; } - - public int size(){ - return -1; + + public int size() { + return size; } - - public void addFirst(Object o){ - + + public void addFirst(Object o) { + } - public void addLast(Object o){ - + + public void addLast(Object o) { + linkLast(o); } - public Object removeFirst(){ + + public Object removeFirst() { return null; } - public Object removeLast(){ + + public Object removeLast() { return null; } - public Iterator iterator(){ + + public Iterator iterator() { return null; } + + /** + * 根据下标获取对应的节点 + * + * @MethodName getNodeByIndex + * @author zhaogd + * @date 2017年2月23日 下午3:32:48 + * @param index + * @return + */ + private Node getNodeByIndex(int index) { + Node n = head; + for (int i = 0; i < index; i++) { + n = n.next; + } + return n; + } + + /** + * 在链表尾端插入节点 + * + * @MethodName linkLast + * @author zhaogd + * @date 2017年2月23日 下午3:14:28 + * @param o + */ + private void linkLast(Object o) { + Node n = last; // 取出原尾端数据 + Node newNode = new Node(o, null); // 创建新节点 + last = newNode; // 把新节点放入链表尾端 + // 如果原尾端为空,说明链表为空,把新节点也放入链表头部 + // 如果不为空,把原尾端节点指向新节点 + if (n == null) { + head = newNode; + } else { + n.next = newNode; + } + + size++; + } + + /** + * 检查下标是否合法 + * + * @MethodName checkIndexForAdd + * @author zhaogd + * @date 2017年2月23日 下午3:05:07 + * @param index + */ + private void checkIndexForAdd(int index) { + if (index < 0 || index > size) { + throw new IndexOutOfBoundsException("Index:" + index + ",Size:" + size); + } + } - - private static class Node{ + /** + * 检查下标是否合法 + * + * @MethodName checkIndexForGet + * @author zhaogd + * @date 2017年2月23日 下午4:21:35 + * @param index + */ + private void checkIndexForGet(int index) { + if (index < 0 || index >= size) { + throw new IndexOutOfBoundsException("Index:" + index + ",Size:" + size); + } + } + + private static class Node { Object data; Node next; + + Node(Object data, Node next) { + this.data = data; + this.next = next; + } } } From f5f52858da37ec1829516543911238d9b286d194 Mon Sep 17 00:00:00 2001 From: '1299310140' <'13437282785@163.com'> Date: Thu, 23 Feb 2017 17:31:38 +0800 Subject: [PATCH 041/518] BinaryTreeNode --- .../src/com/coding/basic/BinaryTreeNode.java | 73 +++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100644 group04/1299310140/src/com/coding/basic/BinaryTreeNode.java diff --git a/group04/1299310140/src/com/coding/basic/BinaryTreeNode.java b/group04/1299310140/src/com/coding/basic/BinaryTreeNode.java new file mode 100644 index 0000000000..dd539df626 --- /dev/null +++ b/group04/1299310140/src/com/coding/basic/BinaryTreeNode.java @@ -0,0 +1,73 @@ +package com.coding.basic; + +public class BinaryTreeNode { + + private Object data; + private BinaryTreeNode left; + private BinaryTreeNode right; + + public Object getData() { + return data; + } + + public void setData(Object data) { + this.data = data; + } + + public BinaryTreeNode getLeft() { + return left; + } + + public void setLeft(BinaryTreeNode left) { + this.left = left; + } + + public BinaryTreeNode getRight() { + return right; + } + + public void setRight(BinaryTreeNode right) { + this.right = right; + } + + public BinaryTreeNode insert(Object o){ + if(this.data == null){//根节点为空 + this.data = o; + }else{//根节点非空 + BinaryTreeNode pres = this; + BinaryTreeNode insertNode = new BinaryTreeNode(); + insertNode.setData(o); + while(pres != null){ + if((int)o < (int)pres.data){//插入值<当前值,pres向左移动,或者将插入节点挂在当前节点左边 + if(pres.left == null){ + pres.left = insertNode; + break; + } + pres = pres.left; + }else{//插入值>=当前值,pres向右移动,或者将插入节点挂在当前节点右边 + if(pres.right == null){ + pres.right = insertNode; + break; + } + pres = pres.right; + } + } + } + return null; + } + + public void print(){ + if(this.data == null){ + return; + }else{ + if(this.left !=null){ + this.left.print(); + } + System.out.print(this.data); + System.out.print(" "); + if(this.right != null){ + this.right.print(); + } + } + } +} From 84afca6aec0d4c5842199e723d412646cb20a88b Mon Sep 17 00:00:00 2001 From: gaodekui <13526428940@163.com> Date: Thu, 23 Feb 2017 17:42:31 +0800 Subject: [PATCH 042/518] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../org.eclipse.core.resources.prefs | 2 + .../src/com/coding/basic/ArrayList.java | 39 ++++ .../src/com/coding/basic/BinaryTreeNode.java | 29 +++ .../src/com/coding/basic/Iterator.java | 6 + .../src/com/coding/basic/LinkedList.java | 62 ++++++ .../1924332561/src/com/coding/basic/List.java | 9 + .../src/com/coding/basic/Queue.java | 23 +++ .../src/com/coding/basic/Stack.java | 29 +++ group16/214074094/readme.txt | 1 + .../src/com/coding/basic/ArrayList.java | 60 ++++++ .../src/com/coding/basic/BinaryTreeNode.java | 32 +++ .../src/com/coding/basic/Iterator.java | 7 + .../src/com/coding/basic/LinkedList.java | 46 +++++ .../214074094/src/com/coding/basic/List.java | 15 ++ .../214074094/src/com/coding/basic/Queue.java | 19 ++ .../214074094/src/com/coding/basic/Stack.java | 22 ++ .../src/com/coding/basic/ArrayList.java | 100 +++++++++ .../src/com/coding/basic/BinaryTreeNode.java | 67 ++++++ .../src/com/coding/basic/Iterator.java | 7 + .../src/com/coding/basic/LinkedList.java | 195 ++++++++++++++++++ .../2562124714/src/com/coding/basic/List.java | 9 + .../src/com/coding/basic/Queue.java | 24 +++ .../src/com/coding/basic/Stack.java | 34 +++ .../src/com/coding/basic/TreeData.java | 26 +++ 24 files changed, 863 insertions(+) create mode 100644 group16/1924332561/.settings/org.eclipse.core.resources.prefs create mode 100644 group16/1924332561/src/com/coding/basic/ArrayList.java create mode 100644 group16/1924332561/src/com/coding/basic/BinaryTreeNode.java create mode 100644 group16/1924332561/src/com/coding/basic/Iterator.java create mode 100644 group16/1924332561/src/com/coding/basic/LinkedList.java create mode 100644 group16/1924332561/src/com/coding/basic/List.java create mode 100644 group16/1924332561/src/com/coding/basic/Queue.java create mode 100644 group16/1924332561/src/com/coding/basic/Stack.java create mode 100644 group16/214074094/readme.txt create mode 100644 group16/214074094/src/com/coding/basic/ArrayList.java create mode 100644 group16/214074094/src/com/coding/basic/BinaryTreeNode.java create mode 100644 group16/214074094/src/com/coding/basic/Iterator.java create mode 100644 group16/214074094/src/com/coding/basic/LinkedList.java create mode 100644 group16/214074094/src/com/coding/basic/List.java create mode 100644 group16/214074094/src/com/coding/basic/Queue.java create mode 100644 group16/214074094/src/com/coding/basic/Stack.java create mode 100644 group16/2562124714/src/com/coding/basic/ArrayList.java create mode 100644 group16/2562124714/src/com/coding/basic/BinaryTreeNode.java create mode 100644 group16/2562124714/src/com/coding/basic/Iterator.java create mode 100644 group16/2562124714/src/com/coding/basic/LinkedList.java create mode 100644 group16/2562124714/src/com/coding/basic/List.java create mode 100644 group16/2562124714/src/com/coding/basic/Queue.java create mode 100644 group16/2562124714/src/com/coding/basic/Stack.java create mode 100644 group16/2562124714/src/com/coding/basic/TreeData.java diff --git a/group16/1924332561/.settings/org.eclipse.core.resources.prefs b/group16/1924332561/.settings/org.eclipse.core.resources.prefs new file mode 100644 index 0000000000..99f26c0203 --- /dev/null +++ b/group16/1924332561/.settings/org.eclipse.core.resources.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +encoding/=UTF-8 diff --git a/group16/1924332561/src/com/coding/basic/ArrayList.java b/group16/1924332561/src/com/coding/basic/ArrayList.java new file mode 100644 index 0000000000..9e20bf25c4 --- /dev/null +++ b/group16/1924332561/src/com/coding/basic/ArrayList.java @@ -0,0 +1,39 @@ +package com.coding.basic; + +public class ArrayList implements List{ + private int size = 0; + + private Object[] elementDate = new Object[100]; + + + @Override + public void add(Object o) { + + } + + @Override + public void add(int index, Object o) { + + } + + @Override + public Object get(int dex) { + + return null; + } + + @Override + public Object remove(int index) { + return null; + } + + @Override + public int size() { + return -1; + } + + public Iterator iterator(){ + return null; + } + +} diff --git a/group16/1924332561/src/com/coding/basic/BinaryTreeNode.java b/group16/1924332561/src/com/coding/basic/BinaryTreeNode.java new file mode 100644 index 0000000000..e7d9e43e24 --- /dev/null +++ b/group16/1924332561/src/com/coding/basic/BinaryTreeNode.java @@ -0,0 +1,29 @@ +package com.coding.basic; + +public class BinaryTreeNode { + private Object date; + private BinaryTreeNode left; + private BinaryTreeNode right; + public Object getDate() { + return date; + } + public void setDate(Object date) { + this.date = date; + } + 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/group16/1924332561/src/com/coding/basic/Iterator.java b/group16/1924332561/src/com/coding/basic/Iterator.java new file mode 100644 index 0000000000..e7cbd474ec --- /dev/null +++ b/group16/1924332561/src/com/coding/basic/Iterator.java @@ -0,0 +1,6 @@ +package com.coding.basic; + +public interface Iterator { + public boolean hasNext(); + public Object next(); +} diff --git a/group16/1924332561/src/com/coding/basic/LinkedList.java b/group16/1924332561/src/com/coding/basic/LinkedList.java new file mode 100644 index 0000000000..d39557be29 --- /dev/null +++ b/group16/1924332561/src/com/coding/basic/LinkedList.java @@ -0,0 +1,62 @@ +package com.coding.basic; + +public class LinkedList implements List { + + private static class Node{ + Object date; + Node next; + } + + private Node head; + + + @Override + public void add(Object o) { + + } + + @Override + public void add(int index, Object o) { + + } + + @Override + public Object get(int dex) { + return null; + } + + @Override + public Object remove(int index) { + return null; + } + + @Override + public int size() { + + return 0; + } + + 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; + } + +} diff --git a/group16/1924332561/src/com/coding/basic/List.java b/group16/1924332561/src/com/coding/basic/List.java new file mode 100644 index 0000000000..9be54168b6 --- /dev/null +++ b/group16/1924332561/src/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 dex); + public Object remove(int index); + public int size(); +} diff --git a/group16/1924332561/src/com/coding/basic/Queue.java b/group16/1924332561/src/com/coding/basic/Queue.java new file mode 100644 index 0000000000..7dc7b4820a --- /dev/null +++ b/group16/1924332561/src/com/coding/basic/Queue.java @@ -0,0 +1,23 @@ +package com.coding.basic; + +public class Queue { + + public void enQueue(){ + + + } + public Object deQueue(){ + + return null; + } + + public boolean isEmpty(){ + + return false; + } + + public int size(){ + + return -1; + } +} diff --git a/group16/1924332561/src/com/coding/basic/Stack.java b/group16/1924332561/src/com/coding/basic/Stack.java new file mode 100644 index 0000000000..7a49c48279 --- /dev/null +++ b/group16/1924332561/src/com/coding/basic/Stack.java @@ -0,0 +1,29 @@ +package com.coding.basic; + +public class Stack { + private ArrayList elementDate = 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/group16/214074094/readme.txt b/group16/214074094/readme.txt new file mode 100644 index 0000000000..c1b06ddcc2 --- /dev/null +++ b/group16/214074094/readme.txt @@ -0,0 +1 @@ +I am 北京-Shane diff --git a/group16/214074094/src/com/coding/basic/ArrayList.java b/group16/214074094/src/com/coding/basic/ArrayList.java new file mode 100644 index 0000000000..a50055225b --- /dev/null +++ b/group16/214074094/src/com/coding/basic/ArrayList.java @@ -0,0 +1,60 @@ +package com.coding.basic; + +public class ArrayList implements List { + + private int size = 0; + + private final static Object[] EMPTY_ELEMENTDATA = {}; + + /** + * 默认容量 + */ + private static int DEFAULT_CAPACITY = 10; + + private Object[] elementData; + + public ArrayList() { + this.elementData = EMPTY_ELEMENTDATA; + } + + public static void main(String[] args) { + ArrayList list = new ArrayList(); + System.out.println(list.elementData == list.EMPTY_ELEMENTDATA); + } + + public void add(Object o) { + if (elementData == EMPTY_ELEMENTDATA) { + elementData = new Object[DEFAULT_CAPACITY]; + }else if(size < elementData.length){ + size++; + }else{ + _grow(); + } + elementData[size] = o; + } + + private void _grow() { + + } + + 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 Iterator iterator() { + return null; + } + +} diff --git a/group16/214074094/src/com/coding/basic/BinaryTreeNode.java b/group16/214074094/src/com/coding/basic/BinaryTreeNode.java new file mode 100644 index 0000000000..d7ac820192 --- /dev/null +++ b/group16/214074094/src/com/coding/basic/BinaryTreeNode.java @@ -0,0 +1,32 @@ +package com.coding.basic; + +public class BinaryTreeNode { + + private Object data; + private BinaryTreeNode left; + private BinaryTreeNode right; + + public Object getData() { + return data; + } + public void setData(Object data) { + this.data = data; + } + public BinaryTreeNode getLeft() { + return left; + } + public void setLeft(BinaryTreeNode left) { + this.left = left; + } + public BinaryTreeNode getRight() { + return right; + } + public void setRight(BinaryTreeNode right) { + this.right = right; + } + + public BinaryTreeNode insert(Object o){ + return null; + } + +} diff --git a/group16/214074094/src/com/coding/basic/Iterator.java b/group16/214074094/src/com/coding/basic/Iterator.java new file mode 100644 index 0000000000..06ef6311b2 --- /dev/null +++ b/group16/214074094/src/com/coding/basic/Iterator.java @@ -0,0 +1,7 @@ +package com.coding.basic; + +public interface Iterator { + public boolean hasNext(); + public Object next(); + +} diff --git a/group16/214074094/src/com/coding/basic/LinkedList.java b/group16/214074094/src/com/coding/basic/LinkedList.java new file mode 100644 index 0000000000..e2c4e5e795 --- /dev/null +++ b/group16/214074094/src/com/coding/basic/LinkedList.java @@ -0,0 +1,46 @@ +package com.coding.basic; + +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; + + } +} diff --git a/group16/214074094/src/com/coding/basic/List.java b/group16/214074094/src/com/coding/basic/List.java new file mode 100644 index 0000000000..fdaf43f86f --- /dev/null +++ b/group16/214074094/src/com/coding/basic/List.java @@ -0,0 +1,15 @@ +package com.coding.basic; + +public interface List { + + void add(Object o); + + void add(int index, Object o); + + Object get(int index); + + Object remove(int index); + + int size(); + +} diff --git a/group16/214074094/src/com/coding/basic/Queue.java b/group16/214074094/src/com/coding/basic/Queue.java new file mode 100644 index 0000000000..36e516e266 --- /dev/null +++ b/group16/214074094/src/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/group16/214074094/src/com/coding/basic/Stack.java b/group16/214074094/src/com/coding/basic/Stack.java new file mode 100644 index 0000000000..a5a04de76d --- /dev/null +++ b/group16/214074094/src/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/group16/2562124714/src/com/coding/basic/ArrayList.java b/group16/2562124714/src/com/coding/basic/ArrayList.java new file mode 100644 index 0000000000..f1d5a9fdd9 --- /dev/null +++ b/group16/2562124714/src/com/coding/basic/ArrayList.java @@ -0,0 +1,100 @@ +package com.coding.basic; + +public class ArrayList implements List { + + private int size = 0; + + private int Scale; //每次扩展大小 + + private Object[] elementData = new Object[100]; + + public ArrayList() + { + this.Scale = 10; + } + + public ArrayList(int i) + { + this.Scale = i; + } + + public void add(Object o){ + if (this.size == elementData.length) + { + DoEnlage(); + } + elementData[size] = o; + this.size++; + } + + private void DoEnlage() + { + if (this.Scale >= 1 && this.Scale <= 10000) + { + Object[] NewElementData = new Object[this.elementData.length + this.Scale]; + System.arraycopy(this.elementData,0,NewElementData,0,this.elementData.length); + + this.elementData = NewElementData; + } + + } + + //index从1开始 位置1,2,3,4,5,6 + public void add(int index, Object o){ + if (this.size == elementData.length) + { + DoEnlage(); + } + int i = 0; + //遍历赋值 + for(i = this.size; i >= index;i--) + { + this.elementData[i] = this.elementData[i - 1]; + } + + this.elementData[i] = o; + this.size++; + + } + + public Object get(int index){ + if (index >= 1 && index <= this.size) + { + return this.elementData[index - 1]; + } + else { + return null; + } + + + } + + public Object remove(int index){ + if (index >= 1 && index <= this.size) + { + int i = 0; + Object DelElement = this.elementData[index - 1]; + for(i = index; i <= this.size; i++) + { + this.elementData[i - 1] = this.elementData[i]; + } + this.elementData[i] = null; + this.size--; + + return DelElement; + + } + else { + return null; + } + } + + public int size(){ + return this.size; + } + + public Iterator iterator(){ + return null; + } + +} diff --git a/group16/2562124714/src/com/coding/basic/BinaryTreeNode.java b/group16/2562124714/src/com/coding/basic/BinaryTreeNode.java new file mode 100644 index 0000000000..680c20c419 --- /dev/null +++ b/group16/2562124714/src/com/coding/basic/BinaryTreeNode.java @@ -0,0 +1,67 @@ +package com.coding.basic; + +public class BinaryTreeNode { + + private TreeData treeData; + //private Object data; + private BinaryTreeNode left; + private BinaryTreeNode right; + + public TreeData getData() { + return treeData; + } + public void setData(TreeData data) { + this.treeData = 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(TreeData o){ + + //遍历寻找元素应该插入的位置 + if (o.compareTo(this.treeData) < 0) + { + if (this.left != null) + { + this.left.insert(o); + } + else + { + BinaryTreeNode NewNode = new BinaryTreeNode(); + NewNode.setData(o); + NewNode.setLeft(null); + NewNode.setRight(null); + this.left = NewNode; + } + } + else + { + if (this.right != null) + { + this.right.insert(o); + } + else + { + BinaryTreeNode NewNode = new BinaryTreeNode(); + NewNode.setData(o); + NewNode.setLeft(null); + NewNode.setRight(null); + this.right = NewNode; + } + } + + + return null; + } + +} diff --git a/group16/2562124714/src/com/coding/basic/Iterator.java b/group16/2562124714/src/com/coding/basic/Iterator.java new file mode 100644 index 0000000000..06ef6311b2 --- /dev/null +++ b/group16/2562124714/src/com/coding/basic/Iterator.java @@ -0,0 +1,7 @@ +package com.coding.basic; + +public interface Iterator { + public boolean hasNext(); + public Object next(); + +} diff --git a/group16/2562124714/src/com/coding/basic/LinkedList.java b/group16/2562124714/src/com/coding/basic/LinkedList.java new file mode 100644 index 0000000000..8ef49d108a --- /dev/null +++ b/group16/2562124714/src/com/coding/basic/LinkedList.java @@ -0,0 +1,195 @@ +package com.coding.basic; + +import com.sun.org.apache.bcel.internal.generic.NEW; + +import java.awt.*; + +public class LinkedList implements List { + + private Node head; + private int Size; + + public void add(Object o){ + Node NewNode = new Node(o); + + if (this.head == null) + { + head = NewNode; + } + else + { + Node node; + for (node = head; node.next != null; node = node.next) + { + } + node.next = NewNode; + } + this.Size++; + + } + //index为位置1,2,3,4,5,6,7 + public void add(int index , Object o){ + Node NewNode = new Node(o); + + if (1 == index) + { + NewNode.next = head; + head = NewNode; + } + else { + Node node; + int i = 0; + for (i = 1, node = head; i < index - 1; i++, node = node.next) { + } + NewNode.next = node.next; + node.next = NewNode; + } + this.Size++; + + } + public Object get(int index){ + Node node; + int i = 0; + + for (i = 1, node = head; i < index ; i++, node = node.next) { + } + + return node.data; +// return null; + } + public Object remove(int index){ + Node node; + int i = 0; + + if (1 == index) + { + if (head.next == null) + { + Object DelData = head.data; + head = null; + this.Size--; + return DelData; + } + else + { + Node DelNode = head; + head = DelNode.next; + DelNode.next = null; + this.Size--; + return DelNode.data; + + } + } + else { + + for (i = 1, node = head; i < index - 1; i++, node = node.next) { + } + Node DelNode = node.next; + node.next = DelNode.next; + DelNode.next = null; + this.Size--; + return DelNode.data; + } + } + + public int size(){ + + return this.Size; + } + + public void addFirst(Object o){ + Node NewNode = new Node(0); + + if (null == this.head) + { + NewNode.next = null; + head = NewNode; + } + else + { + NewNode.next = head; + head = NewNode; + } + + this.Size++; + + } + public void addLast(Object o){ + Node NewNode = new Node(o); + + if (this.Size == 0) + { + NewNode.next = null; + head = NewNode; + } + else + { +// int i = 0; + Node node; + for (node = head; node.next != null; node = node.next) { + + } + node.next = NewNode; + } + + this.Size++; + + } + public Object removeFirst(){ + Node DelFirst; + + if (1 == this.Size) + { + DelFirst = this.head; + DelFirst.next = null; + head = null; + } + else + { + DelFirst = this.head; + head = head.next; + DelFirst.next = null; + } + this.Size--; + + return DelFirst.data; + } + public Object removeLast(){ + Node DelLast; + + if (1 == this.Size) + { + DelLast = head; + DelLast.next = null; + head = null; + } + else + { + Node node; + for (node = head; node.next.next != null; node = node.next) { + + } + DelLast = node.next; + node.next = null; + } + this.Size--; + + return DelLast.data; + } + public Iterator iterator(){ + return null; + } + + + private static class Node{ + Object data; + Node next; + + public Node(Object o) + { + this.data = o; + this.next = null; + } + + } +} diff --git a/group16/2562124714/src/com/coding/basic/List.java b/group16/2562124714/src/com/coding/basic/List.java new file mode 100644 index 0000000000..10d13b5832 --- /dev/null +++ b/group16/2562124714/src/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/group16/2562124714/src/com/coding/basic/Queue.java b/group16/2562124714/src/com/coding/basic/Queue.java new file mode 100644 index 0000000000..40b8f22607 --- /dev/null +++ b/group16/2562124714/src/com/coding/basic/Queue.java @@ -0,0 +1,24 @@ +package com.coding.basic; + +public class Queue { + private ArrayList elementData = new ArrayList(); + + public void enQueue(Object o){ + elementData.add(o); + } + + public Object deQueue(){ + + + return elementData.get(1); + } + + public boolean isEmpty(){ + + return elementData.size() == 0 ? true : false; + } + + public int size(){ + return elementData.size(); + } +} diff --git a/group16/2562124714/src/com/coding/basic/Stack.java b/group16/2562124714/src/com/coding/basic/Stack.java new file mode 100644 index 0000000000..61c92b2fe7 --- /dev/null +++ b/group16/2562124714/src/com/coding/basic/Stack.java @@ -0,0 +1,34 @@ +package com.coding.basic; + +public class Stack { + private ArrayList elementData = new ArrayList(); + +// public Stack() +// { +// elementData +// } + + public void push(Object o){ + elementData.add(0); + } + + public Object pop(){ + Object o = elementData.remove(elementData.size()); + return o; + } + + public Object peek(){ + Object o = elementData.get(elementData.size()); + return o; + } + public boolean isEmpty(){ + if (elementData.size() == 0) + { + return true; + } + return false; + } + public int size(){ + return elementData.size(); + } +} diff --git a/group16/2562124714/src/com/coding/basic/TreeData.java b/group16/2562124714/src/com/coding/basic/TreeData.java new file mode 100644 index 0000000000..3c39539b28 --- /dev/null +++ b/group16/2562124714/src/com/coding/basic/TreeData.java @@ -0,0 +1,26 @@ +package com.coding.basic; + +/** + * Created by zhangwj on 2017/2/22. + */ +public class TreeData> implements Comparable>{ + private int s; + private T t; + + public T getT() + { + return t; + } + + @Override + public int compareTo(TreeData o) { + return getT().compareTo(o.getT()); + } + +// public int compareTo(TreeData o) +// { +// +// } + + +} From 3b9b110f2e0e6a3dc7f25d4db004c4499a120f3a Mon Sep 17 00:00:00 2001 From: gaodekui <13526428940@163.com> Date: Thu, 23 Feb 2017 17:42:45 +0800 Subject: [PATCH 043/518] =?UTF-8?q?Revert=20"=E6=9B=B4=E6=96=B0=E6=8F=90?= =?UTF-8?q?=E4=BA=A4"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit 84afca6aec0d4c5842199e723d412646cb20a88b. --- .../org.eclipse.core.resources.prefs | 2 - .../src/com/coding/basic/ArrayList.java | 39 ---- .../src/com/coding/basic/BinaryTreeNode.java | 29 --- .../src/com/coding/basic/Iterator.java | 6 - .../src/com/coding/basic/LinkedList.java | 62 ------ .../1924332561/src/com/coding/basic/List.java | 9 - .../src/com/coding/basic/Queue.java | 23 --- .../src/com/coding/basic/Stack.java | 29 --- group16/214074094/readme.txt | 1 - .../src/com/coding/basic/ArrayList.java | 60 ------ .../src/com/coding/basic/BinaryTreeNode.java | 32 --- .../src/com/coding/basic/Iterator.java | 7 - .../src/com/coding/basic/LinkedList.java | 46 ----- .../214074094/src/com/coding/basic/List.java | 15 -- .../214074094/src/com/coding/basic/Queue.java | 19 -- .../214074094/src/com/coding/basic/Stack.java | 22 -- .../src/com/coding/basic/ArrayList.java | 100 --------- .../src/com/coding/basic/BinaryTreeNode.java | 67 ------ .../src/com/coding/basic/Iterator.java | 7 - .../src/com/coding/basic/LinkedList.java | 195 ------------------ .../2562124714/src/com/coding/basic/List.java | 9 - .../src/com/coding/basic/Queue.java | 24 --- .../src/com/coding/basic/Stack.java | 34 --- .../src/com/coding/basic/TreeData.java | 26 --- 24 files changed, 863 deletions(-) delete mode 100644 group16/1924332561/.settings/org.eclipse.core.resources.prefs delete mode 100644 group16/1924332561/src/com/coding/basic/ArrayList.java delete mode 100644 group16/1924332561/src/com/coding/basic/BinaryTreeNode.java delete mode 100644 group16/1924332561/src/com/coding/basic/Iterator.java delete mode 100644 group16/1924332561/src/com/coding/basic/LinkedList.java delete mode 100644 group16/1924332561/src/com/coding/basic/List.java delete mode 100644 group16/1924332561/src/com/coding/basic/Queue.java delete mode 100644 group16/1924332561/src/com/coding/basic/Stack.java delete mode 100644 group16/214074094/readme.txt delete mode 100644 group16/214074094/src/com/coding/basic/ArrayList.java delete mode 100644 group16/214074094/src/com/coding/basic/BinaryTreeNode.java delete mode 100644 group16/214074094/src/com/coding/basic/Iterator.java delete mode 100644 group16/214074094/src/com/coding/basic/LinkedList.java delete mode 100644 group16/214074094/src/com/coding/basic/List.java delete mode 100644 group16/214074094/src/com/coding/basic/Queue.java delete mode 100644 group16/214074094/src/com/coding/basic/Stack.java delete mode 100644 group16/2562124714/src/com/coding/basic/ArrayList.java delete mode 100644 group16/2562124714/src/com/coding/basic/BinaryTreeNode.java delete mode 100644 group16/2562124714/src/com/coding/basic/Iterator.java delete mode 100644 group16/2562124714/src/com/coding/basic/LinkedList.java delete mode 100644 group16/2562124714/src/com/coding/basic/List.java delete mode 100644 group16/2562124714/src/com/coding/basic/Queue.java delete mode 100644 group16/2562124714/src/com/coding/basic/Stack.java delete mode 100644 group16/2562124714/src/com/coding/basic/TreeData.java diff --git a/group16/1924332561/.settings/org.eclipse.core.resources.prefs b/group16/1924332561/.settings/org.eclipse.core.resources.prefs deleted file mode 100644 index 99f26c0203..0000000000 --- a/group16/1924332561/.settings/org.eclipse.core.resources.prefs +++ /dev/null @@ -1,2 +0,0 @@ -eclipse.preferences.version=1 -encoding/=UTF-8 diff --git a/group16/1924332561/src/com/coding/basic/ArrayList.java b/group16/1924332561/src/com/coding/basic/ArrayList.java deleted file mode 100644 index 9e20bf25c4..0000000000 --- a/group16/1924332561/src/com/coding/basic/ArrayList.java +++ /dev/null @@ -1,39 +0,0 @@ -package com.coding.basic; - -public class ArrayList implements List{ - private int size = 0; - - private Object[] elementDate = new Object[100]; - - - @Override - public void add(Object o) { - - } - - @Override - public void add(int index, Object o) { - - } - - @Override - public Object get(int dex) { - - return null; - } - - @Override - public Object remove(int index) { - return null; - } - - @Override - public int size() { - return -1; - } - - public Iterator iterator(){ - return null; - } - -} diff --git a/group16/1924332561/src/com/coding/basic/BinaryTreeNode.java b/group16/1924332561/src/com/coding/basic/BinaryTreeNode.java deleted file mode 100644 index e7d9e43e24..0000000000 --- a/group16/1924332561/src/com/coding/basic/BinaryTreeNode.java +++ /dev/null @@ -1,29 +0,0 @@ -package com.coding.basic; - -public class BinaryTreeNode { - private Object date; - private BinaryTreeNode left; - private BinaryTreeNode right; - public Object getDate() { - return date; - } - public void setDate(Object date) { - this.date = date; - } - 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/group16/1924332561/src/com/coding/basic/Iterator.java b/group16/1924332561/src/com/coding/basic/Iterator.java deleted file mode 100644 index e7cbd474ec..0000000000 --- a/group16/1924332561/src/com/coding/basic/Iterator.java +++ /dev/null @@ -1,6 +0,0 @@ -package com.coding.basic; - -public interface Iterator { - public boolean hasNext(); - public Object next(); -} diff --git a/group16/1924332561/src/com/coding/basic/LinkedList.java b/group16/1924332561/src/com/coding/basic/LinkedList.java deleted file mode 100644 index d39557be29..0000000000 --- a/group16/1924332561/src/com/coding/basic/LinkedList.java +++ /dev/null @@ -1,62 +0,0 @@ -package com.coding.basic; - -public class LinkedList implements List { - - private static class Node{ - Object date; - Node next; - } - - private Node head; - - - @Override - public void add(Object o) { - - } - - @Override - public void add(int index, Object o) { - - } - - @Override - public Object get(int dex) { - return null; - } - - @Override - public Object remove(int index) { - return null; - } - - @Override - public int size() { - - return 0; - } - - 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; - } - -} diff --git a/group16/1924332561/src/com/coding/basic/List.java b/group16/1924332561/src/com/coding/basic/List.java deleted file mode 100644 index 9be54168b6..0000000000 --- a/group16/1924332561/src/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 dex); - public Object remove(int index); - public int size(); -} diff --git a/group16/1924332561/src/com/coding/basic/Queue.java b/group16/1924332561/src/com/coding/basic/Queue.java deleted file mode 100644 index 7dc7b4820a..0000000000 --- a/group16/1924332561/src/com/coding/basic/Queue.java +++ /dev/null @@ -1,23 +0,0 @@ -package com.coding.basic; - -public class Queue { - - public void enQueue(){ - - - } - public Object deQueue(){ - - return null; - } - - public boolean isEmpty(){ - - return false; - } - - public int size(){ - - return -1; - } -} diff --git a/group16/1924332561/src/com/coding/basic/Stack.java b/group16/1924332561/src/com/coding/basic/Stack.java deleted file mode 100644 index 7a49c48279..0000000000 --- a/group16/1924332561/src/com/coding/basic/Stack.java +++ /dev/null @@ -1,29 +0,0 @@ -package com.coding.basic; - -public class Stack { - private ArrayList elementDate = 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/group16/214074094/readme.txt b/group16/214074094/readme.txt deleted file mode 100644 index c1b06ddcc2..0000000000 --- a/group16/214074094/readme.txt +++ /dev/null @@ -1 +0,0 @@ -I am 北京-Shane diff --git a/group16/214074094/src/com/coding/basic/ArrayList.java b/group16/214074094/src/com/coding/basic/ArrayList.java deleted file mode 100644 index a50055225b..0000000000 --- a/group16/214074094/src/com/coding/basic/ArrayList.java +++ /dev/null @@ -1,60 +0,0 @@ -package com.coding.basic; - -public class ArrayList implements List { - - private int size = 0; - - private final static Object[] EMPTY_ELEMENTDATA = {}; - - /** - * 默认容量 - */ - private static int DEFAULT_CAPACITY = 10; - - private Object[] elementData; - - public ArrayList() { - this.elementData = EMPTY_ELEMENTDATA; - } - - public static void main(String[] args) { - ArrayList list = new ArrayList(); - System.out.println(list.elementData == list.EMPTY_ELEMENTDATA); - } - - public void add(Object o) { - if (elementData == EMPTY_ELEMENTDATA) { - elementData = new Object[DEFAULT_CAPACITY]; - }else if(size < elementData.length){ - size++; - }else{ - _grow(); - } - elementData[size] = o; - } - - private void _grow() { - - } - - 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 Iterator iterator() { - return null; - } - -} diff --git a/group16/214074094/src/com/coding/basic/BinaryTreeNode.java b/group16/214074094/src/com/coding/basic/BinaryTreeNode.java deleted file mode 100644 index d7ac820192..0000000000 --- a/group16/214074094/src/com/coding/basic/BinaryTreeNode.java +++ /dev/null @@ -1,32 +0,0 @@ -package com.coding.basic; - -public class BinaryTreeNode { - - private Object data; - private BinaryTreeNode left; - private BinaryTreeNode right; - - public Object getData() { - return data; - } - public void setData(Object data) { - this.data = data; - } - public BinaryTreeNode getLeft() { - return left; - } - public void setLeft(BinaryTreeNode left) { - this.left = left; - } - public BinaryTreeNode getRight() { - return right; - } - public void setRight(BinaryTreeNode right) { - this.right = right; - } - - public BinaryTreeNode insert(Object o){ - return null; - } - -} diff --git a/group16/214074094/src/com/coding/basic/Iterator.java b/group16/214074094/src/com/coding/basic/Iterator.java deleted file mode 100644 index 06ef6311b2..0000000000 --- a/group16/214074094/src/com/coding/basic/Iterator.java +++ /dev/null @@ -1,7 +0,0 @@ -package com.coding.basic; - -public interface Iterator { - public boolean hasNext(); - public Object next(); - -} diff --git a/group16/214074094/src/com/coding/basic/LinkedList.java b/group16/214074094/src/com/coding/basic/LinkedList.java deleted file mode 100644 index e2c4e5e795..0000000000 --- a/group16/214074094/src/com/coding/basic/LinkedList.java +++ /dev/null @@ -1,46 +0,0 @@ -package com.coding.basic; - -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; - - } -} diff --git a/group16/214074094/src/com/coding/basic/List.java b/group16/214074094/src/com/coding/basic/List.java deleted file mode 100644 index fdaf43f86f..0000000000 --- a/group16/214074094/src/com/coding/basic/List.java +++ /dev/null @@ -1,15 +0,0 @@ -package com.coding.basic; - -public interface List { - - void add(Object o); - - void add(int index, Object o); - - Object get(int index); - - Object remove(int index); - - int size(); - -} diff --git a/group16/214074094/src/com/coding/basic/Queue.java b/group16/214074094/src/com/coding/basic/Queue.java deleted file mode 100644 index 36e516e266..0000000000 --- a/group16/214074094/src/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/group16/214074094/src/com/coding/basic/Stack.java b/group16/214074094/src/com/coding/basic/Stack.java deleted file mode 100644 index a5a04de76d..0000000000 --- a/group16/214074094/src/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/group16/2562124714/src/com/coding/basic/ArrayList.java b/group16/2562124714/src/com/coding/basic/ArrayList.java deleted file mode 100644 index f1d5a9fdd9..0000000000 --- a/group16/2562124714/src/com/coding/basic/ArrayList.java +++ /dev/null @@ -1,100 +0,0 @@ -package com.coding.basic; - -public class ArrayList implements List { - - private int size = 0; - - private int Scale; //每次扩展大小 - - private Object[] elementData = new Object[100]; - - public ArrayList() - { - this.Scale = 10; - } - - public ArrayList(int i) - { - this.Scale = i; - } - - public void add(Object o){ - if (this.size == elementData.length) - { - DoEnlage(); - } - elementData[size] = o; - this.size++; - } - - private void DoEnlage() - { - if (this.Scale >= 1 && this.Scale <= 10000) - { - Object[] NewElementData = new Object[this.elementData.length + this.Scale]; - System.arraycopy(this.elementData,0,NewElementData,0,this.elementData.length); - - this.elementData = NewElementData; - } - - } - - //index从1开始 位置1,2,3,4,5,6 - public void add(int index, Object o){ - if (this.size == elementData.length) - { - DoEnlage(); - } - int i = 0; - //遍历赋值 - for(i = this.size; i >= index;i--) - { - this.elementData[i] = this.elementData[i - 1]; - } - - this.elementData[i] = o; - this.size++; - - } - - public Object get(int index){ - if (index >= 1 && index <= this.size) - { - return this.elementData[index - 1]; - } - else { - return null; - } - - - } - - public Object remove(int index){ - if (index >= 1 && index <= this.size) - { - int i = 0; - Object DelElement = this.elementData[index - 1]; - for(i = index; i <= this.size; i++) - { - this.elementData[i - 1] = this.elementData[i]; - } - this.elementData[i] = null; - this.size--; - - return DelElement; - - } - else { - return null; - } - } - - public int size(){ - return this.size; - } - - public Iterator iterator(){ - return null; - } - -} diff --git a/group16/2562124714/src/com/coding/basic/BinaryTreeNode.java b/group16/2562124714/src/com/coding/basic/BinaryTreeNode.java deleted file mode 100644 index 680c20c419..0000000000 --- a/group16/2562124714/src/com/coding/basic/BinaryTreeNode.java +++ /dev/null @@ -1,67 +0,0 @@ -package com.coding.basic; - -public class BinaryTreeNode { - - private TreeData treeData; - //private Object data; - private BinaryTreeNode left; - private BinaryTreeNode right; - - public TreeData getData() { - return treeData; - } - public void setData(TreeData data) { - this.treeData = 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(TreeData o){ - - //遍历寻找元素应该插入的位置 - if (o.compareTo(this.treeData) < 0) - { - if (this.left != null) - { - this.left.insert(o); - } - else - { - BinaryTreeNode NewNode = new BinaryTreeNode(); - NewNode.setData(o); - NewNode.setLeft(null); - NewNode.setRight(null); - this.left = NewNode; - } - } - else - { - if (this.right != null) - { - this.right.insert(o); - } - else - { - BinaryTreeNode NewNode = new BinaryTreeNode(); - NewNode.setData(o); - NewNode.setLeft(null); - NewNode.setRight(null); - this.right = NewNode; - } - } - - - return null; - } - -} diff --git a/group16/2562124714/src/com/coding/basic/Iterator.java b/group16/2562124714/src/com/coding/basic/Iterator.java deleted file mode 100644 index 06ef6311b2..0000000000 --- a/group16/2562124714/src/com/coding/basic/Iterator.java +++ /dev/null @@ -1,7 +0,0 @@ -package com.coding.basic; - -public interface Iterator { - public boolean hasNext(); - public Object next(); - -} diff --git a/group16/2562124714/src/com/coding/basic/LinkedList.java b/group16/2562124714/src/com/coding/basic/LinkedList.java deleted file mode 100644 index 8ef49d108a..0000000000 --- a/group16/2562124714/src/com/coding/basic/LinkedList.java +++ /dev/null @@ -1,195 +0,0 @@ -package com.coding.basic; - -import com.sun.org.apache.bcel.internal.generic.NEW; - -import java.awt.*; - -public class LinkedList implements List { - - private Node head; - private int Size; - - public void add(Object o){ - Node NewNode = new Node(o); - - if (this.head == null) - { - head = NewNode; - } - else - { - Node node; - for (node = head; node.next != null; node = node.next) - { - } - node.next = NewNode; - } - this.Size++; - - } - //index为位置1,2,3,4,5,6,7 - public void add(int index , Object o){ - Node NewNode = new Node(o); - - if (1 == index) - { - NewNode.next = head; - head = NewNode; - } - else { - Node node; - int i = 0; - for (i = 1, node = head; i < index - 1; i++, node = node.next) { - } - NewNode.next = node.next; - node.next = NewNode; - } - this.Size++; - - } - public Object get(int index){ - Node node; - int i = 0; - - for (i = 1, node = head; i < index ; i++, node = node.next) { - } - - return node.data; -// return null; - } - public Object remove(int index){ - Node node; - int i = 0; - - if (1 == index) - { - if (head.next == null) - { - Object DelData = head.data; - head = null; - this.Size--; - return DelData; - } - else - { - Node DelNode = head; - head = DelNode.next; - DelNode.next = null; - this.Size--; - return DelNode.data; - - } - } - else { - - for (i = 1, node = head; i < index - 1; i++, node = node.next) { - } - Node DelNode = node.next; - node.next = DelNode.next; - DelNode.next = null; - this.Size--; - return DelNode.data; - } - } - - public int size(){ - - return this.Size; - } - - public void addFirst(Object o){ - Node NewNode = new Node(0); - - if (null == this.head) - { - NewNode.next = null; - head = NewNode; - } - else - { - NewNode.next = head; - head = NewNode; - } - - this.Size++; - - } - public void addLast(Object o){ - Node NewNode = new Node(o); - - if (this.Size == 0) - { - NewNode.next = null; - head = NewNode; - } - else - { -// int i = 0; - Node node; - for (node = head; node.next != null; node = node.next) { - - } - node.next = NewNode; - } - - this.Size++; - - } - public Object removeFirst(){ - Node DelFirst; - - if (1 == this.Size) - { - DelFirst = this.head; - DelFirst.next = null; - head = null; - } - else - { - DelFirst = this.head; - head = head.next; - DelFirst.next = null; - } - this.Size--; - - return DelFirst.data; - } - public Object removeLast(){ - Node DelLast; - - if (1 == this.Size) - { - DelLast = head; - DelLast.next = null; - head = null; - } - else - { - Node node; - for (node = head; node.next.next != null; node = node.next) { - - } - DelLast = node.next; - node.next = null; - } - this.Size--; - - return DelLast.data; - } - public Iterator iterator(){ - return null; - } - - - private static class Node{ - Object data; - Node next; - - public Node(Object o) - { - this.data = o; - this.next = null; - } - - } -} diff --git a/group16/2562124714/src/com/coding/basic/List.java b/group16/2562124714/src/com/coding/basic/List.java deleted file mode 100644 index 10d13b5832..0000000000 --- a/group16/2562124714/src/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/group16/2562124714/src/com/coding/basic/Queue.java b/group16/2562124714/src/com/coding/basic/Queue.java deleted file mode 100644 index 40b8f22607..0000000000 --- a/group16/2562124714/src/com/coding/basic/Queue.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.coding.basic; - -public class Queue { - private ArrayList elementData = new ArrayList(); - - public void enQueue(Object o){ - elementData.add(o); - } - - public Object deQueue(){ - - - return elementData.get(1); - } - - public boolean isEmpty(){ - - return elementData.size() == 0 ? true : false; - } - - public int size(){ - return elementData.size(); - } -} diff --git a/group16/2562124714/src/com/coding/basic/Stack.java b/group16/2562124714/src/com/coding/basic/Stack.java deleted file mode 100644 index 61c92b2fe7..0000000000 --- a/group16/2562124714/src/com/coding/basic/Stack.java +++ /dev/null @@ -1,34 +0,0 @@ -package com.coding.basic; - -public class Stack { - private ArrayList elementData = new ArrayList(); - -// public Stack() -// { -// elementData -// } - - public void push(Object o){ - elementData.add(0); - } - - public Object pop(){ - Object o = elementData.remove(elementData.size()); - return o; - } - - public Object peek(){ - Object o = elementData.get(elementData.size()); - return o; - } - public boolean isEmpty(){ - if (elementData.size() == 0) - { - return true; - } - return false; - } - public int size(){ - return elementData.size(); - } -} diff --git a/group16/2562124714/src/com/coding/basic/TreeData.java b/group16/2562124714/src/com/coding/basic/TreeData.java deleted file mode 100644 index 3c39539b28..0000000000 --- a/group16/2562124714/src/com/coding/basic/TreeData.java +++ /dev/null @@ -1,26 +0,0 @@ -package com.coding.basic; - -/** - * Created by zhangwj on 2017/2/22. - */ -public class TreeData> implements Comparable>{ - private int s; - private T t; - - public T getT() - { - return t; - } - - @Override - public int compareTo(TreeData o) { - return getT().compareTo(o.getT()); - } - -// public int compareTo(TreeData o) -// { -// -// } - - -} From 1e1d6a8e7e46c2cf42b3b6ecbc61048abf780f42 Mon Sep 17 00:00:00 2001 From: gaodekui <13526428940@163.com> Date: Thu, 23 Feb 2017 17:43:59 +0800 Subject: [PATCH 044/518] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../org.eclipse.core.resources.prefs | 2 + .../src/com/coding/basic/ArrayList.java | 39 ++++ .../src/com/coding/basic/BinaryTreeNode.java | 29 +++ .../src/com/coding/basic/Iterator.java | 6 + .../src/com/coding/basic/LinkedList.java | 62 ++++++ .../1924332561/src/com/coding/basic/List.java | 9 + .../src/com/coding/basic/Queue.java | 23 +++ .../src/com/coding/basic/Stack.java | 29 +++ group16/214074094/readme.txt | 1 + .../src/com/coding/basic/ArrayList.java | 60 ++++++ .../src/com/coding/basic/BinaryTreeNode.java | 32 +++ .../src/com/coding/basic/Iterator.java | 7 + .../src/com/coding/basic/LinkedList.java | 46 +++++ .../214074094/src/com/coding/basic/List.java | 15 ++ .../214074094/src/com/coding/basic/Queue.java | 19 ++ .../214074094/src/com/coding/basic/Stack.java | 22 ++ .../src/com/coding/basic/ArrayList.java | 100 +++++++++ .../src/com/coding/basic/BinaryTreeNode.java | 67 ++++++ .../src/com/coding/basic/Iterator.java | 7 + .../src/com/coding/basic/LinkedList.java | 195 ++++++++++++++++++ .../2562124714/src/com/coding/basic/List.java | 9 + .../src/com/coding/basic/Queue.java | 24 +++ .../src/com/coding/basic/Stack.java | 34 +++ .../src/com/coding/basic/TreeData.java | 26 +++ 24 files changed, 863 insertions(+) create mode 100644 group16/1924332561/.settings/org.eclipse.core.resources.prefs create mode 100644 group16/1924332561/src/com/coding/basic/ArrayList.java create mode 100644 group16/1924332561/src/com/coding/basic/BinaryTreeNode.java create mode 100644 group16/1924332561/src/com/coding/basic/Iterator.java create mode 100644 group16/1924332561/src/com/coding/basic/LinkedList.java create mode 100644 group16/1924332561/src/com/coding/basic/List.java create mode 100644 group16/1924332561/src/com/coding/basic/Queue.java create mode 100644 group16/1924332561/src/com/coding/basic/Stack.java create mode 100644 group16/214074094/readme.txt create mode 100644 group16/214074094/src/com/coding/basic/ArrayList.java create mode 100644 group16/214074094/src/com/coding/basic/BinaryTreeNode.java create mode 100644 group16/214074094/src/com/coding/basic/Iterator.java create mode 100644 group16/214074094/src/com/coding/basic/LinkedList.java create mode 100644 group16/214074094/src/com/coding/basic/List.java create mode 100644 group16/214074094/src/com/coding/basic/Queue.java create mode 100644 group16/214074094/src/com/coding/basic/Stack.java create mode 100644 group16/2562124714/src/com/coding/basic/ArrayList.java create mode 100644 group16/2562124714/src/com/coding/basic/BinaryTreeNode.java create mode 100644 group16/2562124714/src/com/coding/basic/Iterator.java create mode 100644 group16/2562124714/src/com/coding/basic/LinkedList.java create mode 100644 group16/2562124714/src/com/coding/basic/List.java create mode 100644 group16/2562124714/src/com/coding/basic/Queue.java create mode 100644 group16/2562124714/src/com/coding/basic/Stack.java create mode 100644 group16/2562124714/src/com/coding/basic/TreeData.java diff --git a/group16/1924332561/.settings/org.eclipse.core.resources.prefs b/group16/1924332561/.settings/org.eclipse.core.resources.prefs new file mode 100644 index 0000000000..99f26c0203 --- /dev/null +++ b/group16/1924332561/.settings/org.eclipse.core.resources.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +encoding/=UTF-8 diff --git a/group16/1924332561/src/com/coding/basic/ArrayList.java b/group16/1924332561/src/com/coding/basic/ArrayList.java new file mode 100644 index 0000000000..9e20bf25c4 --- /dev/null +++ b/group16/1924332561/src/com/coding/basic/ArrayList.java @@ -0,0 +1,39 @@ +package com.coding.basic; + +public class ArrayList implements List{ + private int size = 0; + + private Object[] elementDate = new Object[100]; + + + @Override + public void add(Object o) { + + } + + @Override + public void add(int index, Object o) { + + } + + @Override + public Object get(int dex) { + + return null; + } + + @Override + public Object remove(int index) { + return null; + } + + @Override + public int size() { + return -1; + } + + public Iterator iterator(){ + return null; + } + +} diff --git a/group16/1924332561/src/com/coding/basic/BinaryTreeNode.java b/group16/1924332561/src/com/coding/basic/BinaryTreeNode.java new file mode 100644 index 0000000000..e7d9e43e24 --- /dev/null +++ b/group16/1924332561/src/com/coding/basic/BinaryTreeNode.java @@ -0,0 +1,29 @@ +package com.coding.basic; + +public class BinaryTreeNode { + private Object date; + private BinaryTreeNode left; + private BinaryTreeNode right; + public Object getDate() { + return date; + } + public void setDate(Object date) { + this.date = date; + } + 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/group16/1924332561/src/com/coding/basic/Iterator.java b/group16/1924332561/src/com/coding/basic/Iterator.java new file mode 100644 index 0000000000..e7cbd474ec --- /dev/null +++ b/group16/1924332561/src/com/coding/basic/Iterator.java @@ -0,0 +1,6 @@ +package com.coding.basic; + +public interface Iterator { + public boolean hasNext(); + public Object next(); +} diff --git a/group16/1924332561/src/com/coding/basic/LinkedList.java b/group16/1924332561/src/com/coding/basic/LinkedList.java new file mode 100644 index 0000000000..d39557be29 --- /dev/null +++ b/group16/1924332561/src/com/coding/basic/LinkedList.java @@ -0,0 +1,62 @@ +package com.coding.basic; + +public class LinkedList implements List { + + private static class Node{ + Object date; + Node next; + } + + private Node head; + + + @Override + public void add(Object o) { + + } + + @Override + public void add(int index, Object o) { + + } + + @Override + public Object get(int dex) { + return null; + } + + @Override + public Object remove(int index) { + return null; + } + + @Override + public int size() { + + return 0; + } + + 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; + } + +} diff --git a/group16/1924332561/src/com/coding/basic/List.java b/group16/1924332561/src/com/coding/basic/List.java new file mode 100644 index 0000000000..9be54168b6 --- /dev/null +++ b/group16/1924332561/src/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 dex); + public Object remove(int index); + public int size(); +} diff --git a/group16/1924332561/src/com/coding/basic/Queue.java b/group16/1924332561/src/com/coding/basic/Queue.java new file mode 100644 index 0000000000..7dc7b4820a --- /dev/null +++ b/group16/1924332561/src/com/coding/basic/Queue.java @@ -0,0 +1,23 @@ +package com.coding.basic; + +public class Queue { + + public void enQueue(){ + + + } + public Object deQueue(){ + + return null; + } + + public boolean isEmpty(){ + + return false; + } + + public int size(){ + + return -1; + } +} diff --git a/group16/1924332561/src/com/coding/basic/Stack.java b/group16/1924332561/src/com/coding/basic/Stack.java new file mode 100644 index 0000000000..7a49c48279 --- /dev/null +++ b/group16/1924332561/src/com/coding/basic/Stack.java @@ -0,0 +1,29 @@ +package com.coding.basic; + +public class Stack { + private ArrayList elementDate = 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/group16/214074094/readme.txt b/group16/214074094/readme.txt new file mode 100644 index 0000000000..c1b06ddcc2 --- /dev/null +++ b/group16/214074094/readme.txt @@ -0,0 +1 @@ +I am 北京-Shane diff --git a/group16/214074094/src/com/coding/basic/ArrayList.java b/group16/214074094/src/com/coding/basic/ArrayList.java new file mode 100644 index 0000000000..a50055225b --- /dev/null +++ b/group16/214074094/src/com/coding/basic/ArrayList.java @@ -0,0 +1,60 @@ +package com.coding.basic; + +public class ArrayList implements List { + + private int size = 0; + + private final static Object[] EMPTY_ELEMENTDATA = {}; + + /** + * 默认容量 + */ + private static int DEFAULT_CAPACITY = 10; + + private Object[] elementData; + + public ArrayList() { + this.elementData = EMPTY_ELEMENTDATA; + } + + public static void main(String[] args) { + ArrayList list = new ArrayList(); + System.out.println(list.elementData == list.EMPTY_ELEMENTDATA); + } + + public void add(Object o) { + if (elementData == EMPTY_ELEMENTDATA) { + elementData = new Object[DEFAULT_CAPACITY]; + }else if(size < elementData.length){ + size++; + }else{ + _grow(); + } + elementData[size] = o; + } + + private void _grow() { + + } + + 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 Iterator iterator() { + return null; + } + +} diff --git a/group16/214074094/src/com/coding/basic/BinaryTreeNode.java b/group16/214074094/src/com/coding/basic/BinaryTreeNode.java new file mode 100644 index 0000000000..d7ac820192 --- /dev/null +++ b/group16/214074094/src/com/coding/basic/BinaryTreeNode.java @@ -0,0 +1,32 @@ +package com.coding.basic; + +public class BinaryTreeNode { + + private Object data; + private BinaryTreeNode left; + private BinaryTreeNode right; + + public Object getData() { + return data; + } + public void setData(Object data) { + this.data = data; + } + public BinaryTreeNode getLeft() { + return left; + } + public void setLeft(BinaryTreeNode left) { + this.left = left; + } + public BinaryTreeNode getRight() { + return right; + } + public void setRight(BinaryTreeNode right) { + this.right = right; + } + + public BinaryTreeNode insert(Object o){ + return null; + } + +} diff --git a/group16/214074094/src/com/coding/basic/Iterator.java b/group16/214074094/src/com/coding/basic/Iterator.java new file mode 100644 index 0000000000..06ef6311b2 --- /dev/null +++ b/group16/214074094/src/com/coding/basic/Iterator.java @@ -0,0 +1,7 @@ +package com.coding.basic; + +public interface Iterator { + public boolean hasNext(); + public Object next(); + +} diff --git a/group16/214074094/src/com/coding/basic/LinkedList.java b/group16/214074094/src/com/coding/basic/LinkedList.java new file mode 100644 index 0000000000..e2c4e5e795 --- /dev/null +++ b/group16/214074094/src/com/coding/basic/LinkedList.java @@ -0,0 +1,46 @@ +package com.coding.basic; + +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; + + } +} diff --git a/group16/214074094/src/com/coding/basic/List.java b/group16/214074094/src/com/coding/basic/List.java new file mode 100644 index 0000000000..fdaf43f86f --- /dev/null +++ b/group16/214074094/src/com/coding/basic/List.java @@ -0,0 +1,15 @@ +package com.coding.basic; + +public interface List { + + void add(Object o); + + void add(int index, Object o); + + Object get(int index); + + Object remove(int index); + + int size(); + +} diff --git a/group16/214074094/src/com/coding/basic/Queue.java b/group16/214074094/src/com/coding/basic/Queue.java new file mode 100644 index 0000000000..36e516e266 --- /dev/null +++ b/group16/214074094/src/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/group16/214074094/src/com/coding/basic/Stack.java b/group16/214074094/src/com/coding/basic/Stack.java new file mode 100644 index 0000000000..a5a04de76d --- /dev/null +++ b/group16/214074094/src/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/group16/2562124714/src/com/coding/basic/ArrayList.java b/group16/2562124714/src/com/coding/basic/ArrayList.java new file mode 100644 index 0000000000..f1d5a9fdd9 --- /dev/null +++ b/group16/2562124714/src/com/coding/basic/ArrayList.java @@ -0,0 +1,100 @@ +package com.coding.basic; + +public class ArrayList implements List { + + private int size = 0; + + private int Scale; //每次扩展大小 + + private Object[] elementData = new Object[100]; + + public ArrayList() + { + this.Scale = 10; + } + + public ArrayList(int i) + { + this.Scale = i; + } + + public void add(Object o){ + if (this.size == elementData.length) + { + DoEnlage(); + } + elementData[size] = o; + this.size++; + } + + private void DoEnlage() + { + if (this.Scale >= 1 && this.Scale <= 10000) + { + Object[] NewElementData = new Object[this.elementData.length + this.Scale]; + System.arraycopy(this.elementData,0,NewElementData,0,this.elementData.length); + + this.elementData = NewElementData; + } + + } + + //index从1开始 位置1,2,3,4,5,6 + public void add(int index, Object o){ + if (this.size == elementData.length) + { + DoEnlage(); + } + int i = 0; + //遍历赋值 + for(i = this.size; i >= index;i--) + { + this.elementData[i] = this.elementData[i - 1]; + } + + this.elementData[i] = o; + this.size++; + + } + + public Object get(int index){ + if (index >= 1 && index <= this.size) + { + return this.elementData[index - 1]; + } + else { + return null; + } + + + } + + public Object remove(int index){ + if (index >= 1 && index <= this.size) + { + int i = 0; + Object DelElement = this.elementData[index - 1]; + for(i = index; i <= this.size; i++) + { + this.elementData[i - 1] = this.elementData[i]; + } + this.elementData[i] = null; + this.size--; + + return DelElement; + + } + else { + return null; + } + } + + public int size(){ + return this.size; + } + + public Iterator iterator(){ + return null; + } + +} diff --git a/group16/2562124714/src/com/coding/basic/BinaryTreeNode.java b/group16/2562124714/src/com/coding/basic/BinaryTreeNode.java new file mode 100644 index 0000000000..680c20c419 --- /dev/null +++ b/group16/2562124714/src/com/coding/basic/BinaryTreeNode.java @@ -0,0 +1,67 @@ +package com.coding.basic; + +public class BinaryTreeNode { + + private TreeData treeData; + //private Object data; + private BinaryTreeNode left; + private BinaryTreeNode right; + + public TreeData getData() { + return treeData; + } + public void setData(TreeData data) { + this.treeData = 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(TreeData o){ + + //遍历寻找元素应该插入的位置 + if (o.compareTo(this.treeData) < 0) + { + if (this.left != null) + { + this.left.insert(o); + } + else + { + BinaryTreeNode NewNode = new BinaryTreeNode(); + NewNode.setData(o); + NewNode.setLeft(null); + NewNode.setRight(null); + this.left = NewNode; + } + } + else + { + if (this.right != null) + { + this.right.insert(o); + } + else + { + BinaryTreeNode NewNode = new BinaryTreeNode(); + NewNode.setData(o); + NewNode.setLeft(null); + NewNode.setRight(null); + this.right = NewNode; + } + } + + + return null; + } + +} diff --git a/group16/2562124714/src/com/coding/basic/Iterator.java b/group16/2562124714/src/com/coding/basic/Iterator.java new file mode 100644 index 0000000000..06ef6311b2 --- /dev/null +++ b/group16/2562124714/src/com/coding/basic/Iterator.java @@ -0,0 +1,7 @@ +package com.coding.basic; + +public interface Iterator { + public boolean hasNext(); + public Object next(); + +} diff --git a/group16/2562124714/src/com/coding/basic/LinkedList.java b/group16/2562124714/src/com/coding/basic/LinkedList.java new file mode 100644 index 0000000000..8ef49d108a --- /dev/null +++ b/group16/2562124714/src/com/coding/basic/LinkedList.java @@ -0,0 +1,195 @@ +package com.coding.basic; + +import com.sun.org.apache.bcel.internal.generic.NEW; + +import java.awt.*; + +public class LinkedList implements List { + + private Node head; + private int Size; + + public void add(Object o){ + Node NewNode = new Node(o); + + if (this.head == null) + { + head = NewNode; + } + else + { + Node node; + for (node = head; node.next != null; node = node.next) + { + } + node.next = NewNode; + } + this.Size++; + + } + //index为位置1,2,3,4,5,6,7 + public void add(int index , Object o){ + Node NewNode = new Node(o); + + if (1 == index) + { + NewNode.next = head; + head = NewNode; + } + else { + Node node; + int i = 0; + for (i = 1, node = head; i < index - 1; i++, node = node.next) { + } + NewNode.next = node.next; + node.next = NewNode; + } + this.Size++; + + } + public Object get(int index){ + Node node; + int i = 0; + + for (i = 1, node = head; i < index ; i++, node = node.next) { + } + + return node.data; +// return null; + } + public Object remove(int index){ + Node node; + int i = 0; + + if (1 == index) + { + if (head.next == null) + { + Object DelData = head.data; + head = null; + this.Size--; + return DelData; + } + else + { + Node DelNode = head; + head = DelNode.next; + DelNode.next = null; + this.Size--; + return DelNode.data; + + } + } + else { + + for (i = 1, node = head; i < index - 1; i++, node = node.next) { + } + Node DelNode = node.next; + node.next = DelNode.next; + DelNode.next = null; + this.Size--; + return DelNode.data; + } + } + + public int size(){ + + return this.Size; + } + + public void addFirst(Object o){ + Node NewNode = new Node(0); + + if (null == this.head) + { + NewNode.next = null; + head = NewNode; + } + else + { + NewNode.next = head; + head = NewNode; + } + + this.Size++; + + } + public void addLast(Object o){ + Node NewNode = new Node(o); + + if (this.Size == 0) + { + NewNode.next = null; + head = NewNode; + } + else + { +// int i = 0; + Node node; + for (node = head; node.next != null; node = node.next) { + + } + node.next = NewNode; + } + + this.Size++; + + } + public Object removeFirst(){ + Node DelFirst; + + if (1 == this.Size) + { + DelFirst = this.head; + DelFirst.next = null; + head = null; + } + else + { + DelFirst = this.head; + head = head.next; + DelFirst.next = null; + } + this.Size--; + + return DelFirst.data; + } + public Object removeLast(){ + Node DelLast; + + if (1 == this.Size) + { + DelLast = head; + DelLast.next = null; + head = null; + } + else + { + Node node; + for (node = head; node.next.next != null; node = node.next) { + + } + DelLast = node.next; + node.next = null; + } + this.Size--; + + return DelLast.data; + } + public Iterator iterator(){ + return null; + } + + + private static class Node{ + Object data; + Node next; + + public Node(Object o) + { + this.data = o; + this.next = null; + } + + } +} diff --git a/group16/2562124714/src/com/coding/basic/List.java b/group16/2562124714/src/com/coding/basic/List.java new file mode 100644 index 0000000000..10d13b5832 --- /dev/null +++ b/group16/2562124714/src/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/group16/2562124714/src/com/coding/basic/Queue.java b/group16/2562124714/src/com/coding/basic/Queue.java new file mode 100644 index 0000000000..40b8f22607 --- /dev/null +++ b/group16/2562124714/src/com/coding/basic/Queue.java @@ -0,0 +1,24 @@ +package com.coding.basic; + +public class Queue { + private ArrayList elementData = new ArrayList(); + + public void enQueue(Object o){ + elementData.add(o); + } + + public Object deQueue(){ + + + return elementData.get(1); + } + + public boolean isEmpty(){ + + return elementData.size() == 0 ? true : false; + } + + public int size(){ + return elementData.size(); + } +} diff --git a/group16/2562124714/src/com/coding/basic/Stack.java b/group16/2562124714/src/com/coding/basic/Stack.java new file mode 100644 index 0000000000..61c92b2fe7 --- /dev/null +++ b/group16/2562124714/src/com/coding/basic/Stack.java @@ -0,0 +1,34 @@ +package com.coding.basic; + +public class Stack { + private ArrayList elementData = new ArrayList(); + +// public Stack() +// { +// elementData +// } + + public void push(Object o){ + elementData.add(0); + } + + public Object pop(){ + Object o = elementData.remove(elementData.size()); + return o; + } + + public Object peek(){ + Object o = elementData.get(elementData.size()); + return o; + } + public boolean isEmpty(){ + if (elementData.size() == 0) + { + return true; + } + return false; + } + public int size(){ + return elementData.size(); + } +} diff --git a/group16/2562124714/src/com/coding/basic/TreeData.java b/group16/2562124714/src/com/coding/basic/TreeData.java new file mode 100644 index 0000000000..3c39539b28 --- /dev/null +++ b/group16/2562124714/src/com/coding/basic/TreeData.java @@ -0,0 +1,26 @@ +package com.coding.basic; + +/** + * Created by zhangwj on 2017/2/22. + */ +public class TreeData> implements Comparable>{ + private int s; + private T t; + + public T getT() + { + return t; + } + + @Override + public int compareTo(TreeData o) { + return getT().compareTo(o.getT()); + } + +// public int compareTo(TreeData o) +// { +// +// } + + +} From 77348a7293058cc6b2aacd8b4f92c3f49d5facd1 Mon Sep 17 00:00:00 2001 From: zj <2258659044@qq.com> Date: Thu, 23 Feb 2017 17:45:10 +0800 Subject: [PATCH 045/518] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E5=8D=95=E5=85=83?= =?UTF-8?q?=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../test/com/coding/basic/ArrayListTest.java | 22 +- .../test/com/coding/basic/LinkedListTest.java | 218 +++++++++--------- 2 files changed, 120 insertions(+), 120 deletions(-) diff --git a/group12/2258659044/zj-2017/src/test/com/coding/basic/ArrayListTest.java b/group12/2258659044/zj-2017/src/test/com/coding/basic/ArrayListTest.java index e7613ee689..badcb2968f 100644 --- a/group12/2258659044/zj-2017/src/test/com/coding/basic/ArrayListTest.java +++ b/group12/2258659044/zj-2017/src/test/com/coding/basic/ArrayListTest.java @@ -1,7 +1,5 @@ package test.com.coding.basic; -import java.util.NoSuchElementException; - import org.junit.Assert; import org.junit.Before; import org.junit.Test; @@ -36,7 +34,7 @@ public void add(){ /** * 两个参数的add方法 */ - @Test(expected = IndexOutOfBoundsException.class) + @Test//(expected = IndexOutOfBoundsException.class) public void add4ToPramter(){ ls.add(0, 0); @@ -49,22 +47,23 @@ public void add4ToPramter(){ Assert.assertEquals(ls.size(), 14); Assert.assertEquals(ls.get(3), 9); Assert.assertEquals(ls.get(13), 3); - ls.add(15, "a"); + //打开下面操作抛出异常 + //ls.add(15, "a"); } /** * get(i) */ - @Test(expected = IndexOutOfBoundsException.class) + @Test//(expected = IndexOutOfBoundsException.class) public void get(){ for (int i = 0; i < 10; i++) { ls.add(i); } - ls.add(11,11); - Assert.assertEquals(ls.get(9), 9); - Assert.assertEquals(ls.get(10),null); - ls.get(12); + + Assert.assertEquals(ls.get(9), 9); + //打开下面操作抛出异常 + //ls.get(12); } @Test @@ -92,7 +91,7 @@ public void size(){ } - @Test(expected = NoSuchElementException.class) + @Test//(expected = NoSuchElementException.class) public void iterator(){ for (int i = 0; i < 10; i++) { @@ -104,6 +103,7 @@ public void iterator(){ it.next(); } Assert.assertEquals(it.hasNext(),false); - it.next(); + //打开下面操作抛出异常 + //it.next(); } } diff --git a/group12/2258659044/zj-2017/src/test/com/coding/basic/LinkedListTest.java b/group12/2258659044/zj-2017/src/test/com/coding/basic/LinkedListTest.java index e7b56eccff..a55b2d5a3f 100644 --- a/group12/2258659044/zj-2017/src/test/com/coding/basic/LinkedListTest.java +++ b/group12/2258659044/zj-2017/src/test/com/coding/basic/LinkedListTest.java @@ -1,109 +1,109 @@ -package test.com.coding.basic; - -import java.util.NoSuchElementException; - -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; - -import com.coding.basic.Iterator; -import com.coding.basic.LinkedList; - -public class LinkedListTest { - - LinkedList ls ; - @Before - public void setup() { - ls = new LinkedList(); - } - - /** - * 测试一个参数的add方法 - * ArrayList当数据超过10时进行第一次扩容 - */ - @Test - public void add(){ - - ls.add(3); - ls.add("a"); - for (int i = 0; i < 10; i++) { - ls.add(i); - } - Assert.assertEquals(ls.size(), 12); - Assert.assertEquals(ls.get(1), "a"); - } - - /** - * 两个参数的add方法 - */ - @Test(expected = IndexOutOfBoundsException.class) - public void add4ToPramter(){ - - ls.add(0, 0); - ls.add(1,1); - ls.add(2, 2); - ls.add(3,3); - for (int i = 0; i < 10; i++) { - ls.add(3,i); - } - Assert.assertEquals(ls.size(), 14); - Assert.assertEquals(ls.get(3), 9); - Assert.assertEquals(ls.get(13), 3); - ls.add(15, "a"); - } - - /** - * get(i) - */ - @Test(expected = IndexOutOfBoundsException.class) - public void get(){ - - for (int i = 0; i < 10; i++) { - ls.add(i); - } - ls.add(11,11); - Assert.assertEquals(ls.get(9), 9); - Assert.assertEquals(ls.get(10),null); - ls.get(12); - } - - @Test - public void remove(){ - - for (int i = 0; i < 10; i++) { - ls.add(i); - } - Assert.assertEquals(ls.remove(5),5); - Assert.assertEquals(ls.size(),9); - Assert.assertEquals(ls.remove(8),9); - Assert.assertEquals(ls.size(),8); - } - - @Test - public void size(){ - - Assert.assertEquals(ls.size(),0); - ls.add("a"); - Assert.assertEquals(ls.size(),1); - ls.add(0,0); - Assert.assertEquals(ls.size(),2); - ls.remove(0); - Assert.assertEquals(ls.size(),1); - - } - - @Test(expected = NoSuchElementException.class) - public void iterator(){ - - for (int i = 0; i < 10; i++) { - ls.add(i); - } - Iterator it = ls.iterator(); - Assert.assertEquals(it.hasNext(),true); - for (int i = 0; i < 10; i++) { - it.next(); - } - Assert.assertEquals(it.hasNext(),false); - it.next(); - } -} +package test.com.coding.basic; + +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; + +import com.coding.basic.Iterator; +import com.coding.basic.LinkedList; + +public class LinkedListTest { + + LinkedList ls ; + @Before + public void setup() { + ls = new LinkedList(); + } + + /** + * 测试一个参数的add方法 + * ArrayList当数据超过10时进行第一次扩容 + */ + @Test + public void add(){ + + ls.add(3); + ls.add("a"); + for (int i = 0; i < 10; i++) { + ls.add(i); + } + Assert.assertEquals(ls.size(), 12); + Assert.assertEquals(ls.get(1), "a"); + } + + /** + * 两个参数的add方法 + */ + @Test//(expected = IndexOutOfBoundsException.class) + public void add4ToPramter(){ + + ls.add(0, 0); + ls.add(1,1); + ls.add(2, 2); + ls.add(3,3); + for (int i = 0; i < 10; i++) { + ls.add(3,i); + } + Assert.assertEquals(ls.size(), 14); + Assert.assertEquals(ls.get(3), 9); + Assert.assertEquals(ls.get(13), 3); + //打开下面操作抛出异常 + //ls.add(15, "a"); + } + + /** + * get(i) + */ + @Test//(expected = IndexOutOfBoundsException.class) + public void get(){ + + for (int i = 0; i < 10; i++) { + ls.add(i); + } + + Assert.assertEquals(ls.get(9), 9); + //打开下面操作抛出异常 + //ls.get(12); + } + + @Test + public void remove(){ + + for (int i = 0; i < 10; i++) { + ls.add(i); + } + Assert.assertEquals(ls.remove(5),5); + Assert.assertEquals(ls.size(),9); + Assert.assertEquals(ls.remove(8),9); + Assert.assertEquals(ls.size(),8); + } + + @Test + public void size(){ + + Assert.assertEquals(ls.size(),0); + ls.add("a"); + Assert.assertEquals(ls.size(),1); + ls.add(0,0); + Assert.assertEquals(ls.size(),2); + ls.remove(0); + Assert.assertEquals(ls.size(),1); + + } + + @Test//(expected = NoSuchElementException.class) + public void iterator(){ + + for (int i = 0; i < 10; i++) { + ls.add(i); + } + Iterator it = ls.iterator(); + Assert.assertEquals(it.hasNext(),true); + for (int i = 0; i < 10; i++) { + it.next(); + } + Assert.assertEquals(it.hasNext(),false); + //打开下面操作抛出异常 + //it.next(); + } +} From 96e69df6b2822f52ab3f81772eb64d88530c4b31 Mon Sep 17 00:00:00 2001 From: ikook <935542673@qq.com> Date: Thu, 23 Feb 2017 17:46:58 +0800 Subject: [PATCH 046/518] ikook --- group18/935542673/Coding/.classpath | 8 ++++++++ group18/935542673/Coding/.gitignore | 1 + group18/935542673/Coding/.project | 17 +++++++++++++++++ 3 files changed, 26 insertions(+) create mode 100644 group18/935542673/Coding/.classpath create mode 100644 group18/935542673/Coding/.gitignore create mode 100644 group18/935542673/Coding/.project diff --git a/group18/935542673/Coding/.classpath b/group18/935542673/Coding/.classpath new file mode 100644 index 0000000000..63024e81ef --- /dev/null +++ b/group18/935542673/Coding/.classpath @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/group18/935542673/Coding/.gitignore b/group18/935542673/Coding/.gitignore new file mode 100644 index 0000000000..ae3c172604 --- /dev/null +++ b/group18/935542673/Coding/.gitignore @@ -0,0 +1 @@ +/bin/ diff --git a/group18/935542673/Coding/.project b/group18/935542673/Coding/.project new file mode 100644 index 0000000000..8b11575db2 --- /dev/null +++ b/group18/935542673/Coding/.project @@ -0,0 +1,17 @@ + + + Coding + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + From 794fea5d2ca5ba19538f6d7e448247d7bb017ef9 Mon Sep 17 00:00:00 2001 From: ikook <935542673@qq.com> Date: Thu, 23 Feb 2017 17:50:30 +0800 Subject: [PATCH 047/518] ArrayList(The ikook implementation) --- .../basic_data_structure/MyArrayListTest.java | 75 +++++++++ .../basic_data_structure/MyArrayList.java | 158 ++++++++++++++++++ 2 files changed, 233 insertions(+) create mode 100644 group18/935542673/Coding/junit/com/ikook/basic_data_structure/MyArrayListTest.java create mode 100644 group18/935542673/Coding/src/com/ikook/basic_data_structure/MyArrayList.java diff --git a/group18/935542673/Coding/junit/com/ikook/basic_data_structure/MyArrayListTest.java b/group18/935542673/Coding/junit/com/ikook/basic_data_structure/MyArrayListTest.java new file mode 100644 index 0000000000..b1094f3583 --- /dev/null +++ b/group18/935542673/Coding/junit/com/ikook/basic_data_structure/MyArrayListTest.java @@ -0,0 +1,75 @@ +package com.ikook.basic_data_structure; + +import static org.junit.Assert.*; + +import java.util.Date; + +import org.junit.Before; +import org.junit.Test; + +/** + * 此单元测试只测试了正常情况,一些异常情况没有测试。 + * @author ikook + */ +public class MyArrayListTest { + + private MyArrayList list; + + @Before + public void setUp() { + list = new MyArrayList(); + list.add("111"); + list.add("222"); + list.add(33); + list.add("444"); + list.add(new Date()); + list.add("666"); + list.add("777"); + list.add("888"); + list.add("999"); + } + + @Test + public void testAdd() { + //测试add(Object obj)方法 + list.add(100); + assertEquals(10, list.size()); + + //测试add(int index, Object obj)方法 + list.add(3, 444); + assertEquals(444, list.get(3)); + + assertEquals("444", list.get(4)); + assertEquals(11, list.size()); + } + + @Test + public void testIsEmpty() { + + assertEquals(false, list.isEmpty()); + } + + @Test + public void testGet() { + assertEquals(new Date(), list.get(4)); + } + + @Test + public void testRemove() { + + // 测试remove(int index)方法 + assertEquals(33, list.remove(2)); + assertEquals("444", list.get(2)); + + // 测试remove(Object obj)方法 + assertEquals(true, list.remove("222")); + assertEquals("444", list.get(1)); + } + + @Test + public void testSet() { + assertEquals(33, list.set(2, "333")); + assertEquals("333", list.get(2)); + } + +} diff --git a/group18/935542673/Coding/src/com/ikook/basic_data_structure/MyArrayList.java b/group18/935542673/Coding/src/com/ikook/basic_data_structure/MyArrayList.java new file mode 100644 index 0000000000..39de481f0f --- /dev/null +++ b/group18/935542673/Coding/src/com/ikook/basic_data_structure/MyArrayList.java @@ -0,0 +1,158 @@ +package com.ikook.basic_data_structure; + +/** + * @author ikook; QQ号码: 935542673 + */ +public class MyArrayList implements MyList{ + + private Object[] elementData; + + private int size; + + /** + * 使Object[]的长度默认为10; + */ + public MyArrayList() { + this(10); + } + + /** + * 在构造函数中初始化集合的长度 + * @param initialCapacity + */ + public MyArrayList(int initialCapacity) { + if(initialCapacity < 0) { + try { + throw new Exception(); + } catch (Exception e) { + e.printStackTrace(); + } + } + this.elementData = new Object[initialCapacity]; + } + + /** + * 在集合中添加元素 + * @param obj + */ + public void add(Object obj) { + + ensureCapacity(); + elementData[size++] = obj; + + } + + /** + * 添加元素到集合的指定位置 + * @param index + * @param obj + */ + public void add(int index, Object obj) { + rangeCheck(index); + ensureCapacity(); + + System.arraycopy(elementData, index, elementData, index + 1, size-index); + elementData[index] = obj; + size++; + } + + /** + * 返回集合的长度 + * @return + */ + public int size() { + return size; + } + + /** + * 判断集合是非为空 + * @return + */ + public boolean isEmpty() { + return size == 0; + } + + /** + * 获取集合指定位置的元素 + * @param index + * @return + */ + public Object get(int index) { + rangeCheck(index); + return elementData[index]; + } + + /** + * 删除指定位置的对象 + * @param index + */ + public Object remove(int index) { + + rangeCheck(index); + + Object oldValue = elementData[index]; + + int numMoved = size - index - 1; + if (numMoved > 0){ + System.arraycopy(elementData, index+1, elementData, index, + numMoved); + } + elementData[--size] = null; + + return oldValue; + } + + /** + * 删除指定的对象(Object 对象) + * @param obj + */ + public boolean remove(Object obj){ + for(int i = 0; i < size; i++) { + if(get(i).equals(obj)) { + remove(i); + return true; + } + } + return false; + } + + /** + * 更改集合中指定位置的元素,并返回原来的对象 + * @param index + * @param obj + * @return + */ + public Object set(int index, Object obj) { + rangeCheck(index); + + Object oldValue = elementData[index]; + elementData[index] = obj; + + return oldValue; + } + + /** + * 集合扩容封装类 + */ + private void ensureCapacity() { + if(size == elementData.length) { + Object[] newArray = new Object[size * 2 + 1]; + System.arraycopy(elementData, 0, newArray, 0, elementData.length); + elementData = newArray; + } + } + + /** + * 判断集合范围是否越界的封装类 + * @param index + */ + private void rangeCheck(int index) { + if(index < 0 || index >= size) { + try { + throw new Exception("索引异常"); + } catch (Exception e) { + e.printStackTrace(); + } + } + } +} \ No newline at end of file From e5596de72793da0f59b9b96028cb9a46b17c2bf6 Mon Sep 17 00:00:00 2001 From: ikook <935542673@qq.com> Date: Thu, 23 Feb 2017 17:51:52 +0800 Subject: [PATCH 048/518] LinkedList(The madman implementation) --- .../MyLinkedListTest.java | 115 +++++++ .../basic_data_structure/MyLinkedList.java | 303 ++++++++++++++++++ 2 files changed, 418 insertions(+) create mode 100644 group18/935542673/Coding/junit/com/ikook/basic_data_structure/MyLinkedListTest.java create mode 100644 group18/935542673/Coding/src/com/ikook/basic_data_structure/MyLinkedList.java diff --git a/group18/935542673/Coding/junit/com/ikook/basic_data_structure/MyLinkedListTest.java b/group18/935542673/Coding/junit/com/ikook/basic_data_structure/MyLinkedListTest.java new file mode 100644 index 0000000000..4e3a5d7a22 --- /dev/null +++ b/group18/935542673/Coding/junit/com/ikook/basic_data_structure/MyLinkedListTest.java @@ -0,0 +1,115 @@ +package com.ikook.basic_data_structure; + +import static org.junit.Assert.*; + +import java.util.Date; + +import org.junit.Before; +import org.junit.Test; + +/** + * 此单元测试只测试了正常情况,一些异常情况没有测试。 + * @author ikook + */ +public class MyLinkedListTest { + + private MyLinkedList list; + + @Before + public void setUp() { + list = new MyLinkedList(); + list.add("111"); + list.add(222); + list.add("333"); + } + + @Test + public void testAddFirst() { + list.addFirst(444); + assertEquals(4, list.size()); + assertEquals(444, list.get(0)); + assertEquals(444, list.getFirst()); + + } + + @Test + public void testAddLast() { + list.addLast("444"); + assertEquals(4, list.size()); + assertEquals("444", list.getLast()); + assertEquals("444", list.get(3)); + } + + @Test + public void testAddObject() { + list.add(new Date()); + assertEquals(new Date(), list.get(3)); + } + + @Test + public void testAddIntObject() { + list.add(1, "222"); + assertEquals("222", list.get(1)); + assertEquals(4, list.size()); + } + + @Test + public void testSize() { + assertEquals(3, list.size()); + } + + @Test + public void testIsEmpty() { + assertEquals(false, list.isEmpty()); + + MyLinkedList list = new MyLinkedList(); + assertEquals(true, list.isEmpty()); + } + + @Test + public void testGetFirst() { + assertEquals("111", list.getFirst()); + } + + @Test + public void testGetLast() { + assertEquals("333", list.getLast()); + } + + @Test + public void testGet() { + assertEquals(222, list.get(1)); + } + + @Test + public void testSet() { + assertEquals(222, list.set(1, new Date())); + assertEquals(new Date(), list.get(1)); + } + + @Test + public void testRemoveFirst() { + assertEquals("111", list.removeFirst()); + assertEquals(222, list.getFirst()); + } + + @Test + public void testRemoveLast() { + assertEquals("333", list.removeLast()); + assertEquals(222, list.getLast()); + } + + @Test + public void testRemoveObject() { + assertEquals(true, list.remove((Integer) 222)); + assertEquals("333", list.get(1)); + } + + @Test + public void testRemoveInt() { + assertEquals(222, list.remove(1)); + assertEquals("333", list.get(1)); + + } + +} diff --git a/group18/935542673/Coding/src/com/ikook/basic_data_structure/MyLinkedList.java b/group18/935542673/Coding/src/com/ikook/basic_data_structure/MyLinkedList.java new file mode 100644 index 0000000000..2377509c27 --- /dev/null +++ b/group18/935542673/Coding/src/com/ikook/basic_data_structure/MyLinkedList.java @@ -0,0 +1,303 @@ +package com.ikook.basic_data_structure; + +import java.util.NoSuchElementException; + +/** + * @author ikook; QQ号码: 935542673 + */ +public class MyLinkedList implements MyList{ + + private Node first; + private Node last; + private int size; + + /** + * 在链表的头部插入新的元素 + * @param obj + */ + public void addFirst(Object obj) { + final Node f = first; + final Node newNode = new Node(null, obj, f); + first = newNode; + if (f == null) + last = newNode; + else + f.previous = newNode; + size++; + } + + /** + * 在链表尾部插入新的元素 + * @param obj + */ + public void addLast(Object obj) { + final Node l = last; + final Node newNode = new Node(l, obj, null); + last = newNode; + if (l == null) + first = newNode; + else + l.next = newNode; + size++; + } + + /** + * 在链表中插入新的元素 + * @param obj + */ + public void add(Object obj) { + addLast(obj); + } + + /** + * 在指定位置插入新的元素 + * @param index + * @param obj + */ + public void add(int index, Object obj) { + if (!(index >= 0 && index <= size)) { + throw new IndexOutOfBoundsException("索引位置越界"); + } + + if (index == size) { + addLast(obj); + } else { + Node temp = node(index); + final Node pred = temp.previous; + final Node newNode = new Node(pred, obj, temp); + temp.previous = newNode; + if (pred == null) + first = newNode; + else + pred.next = newNode; + size++; + } + } + + /** + * 返回集合的size。 + * @return + */ + public int size() { + return size; + } + + /** + * 判断集合是非为空 + * @return + */ + public boolean isEmpty() { + return size == 0; + } + + /** + * 获取链表头部的元素 + * @return + */ + public Object getFirst() { + final Node f = first; + if (f == null) { + throw new NoSuchElementException("没有找到指定的元素"); + } + + return f.data; + } + + /** + * 获取链表尾部的元素 + * @return + */ + public Object getLast() { + final Node l = last; + if (l == null) { + throw new NoSuchElementException("没有找到指定的元素"); + } + + return l.data; + } + + /** + * 获取指定位置的元素 + * @param index + * @return + */ + public Object get(int index) { + rangeCheckElementIndex(index); + return node(index).data; + } + + /** + * 更改指定位置的元素 + * @param index + * @param element + * @return + */ + public Object set(int index, Object element) { + rangeCheckElementIndex(index); + Node temp = node(index); + Object oldValue = temp.data; + temp.data = element; + return oldValue; + } + + + /** + * 删除链表头部的元素 + * @return + */ + public Object removeFirst() { + final Node f = first; + if (f == null) { + throw new NoSuchElementException("没有找到指定的元素"); + } + + final Object element = f.data; + final Node next = f.next; + f.data = null; + f.next = null; + first = next; + if (next == null) { + last = null; + } else { + next.previous = null; + } + size--; + + return element; + } + + /** + * 删除链表尾部的元素 + * @return + */ + public Object removeLast() { + final Node l = last; + if (l == null){ + throw new NoSuchElementException("没有找到指定的元素"); + } + + final Object element = l.data; + final Node prev = l.previous; + l.data = null; + l.previous = null; + last = prev; + if (prev == null) { + first = null; + } else { + prev.next = null; + } + size--; + + return element; + } + + /** + * 删除指定元素 + * @param o + * @return + */ + public boolean remove(Object o) { + if (o == null) { + for (Node temp = first; temp != null; temp = temp.next) { + if (temp.data == null) { + deleteElement(temp); + return true; + } + } + } else { + for (Node temp = first; temp != null; temp = temp.next) { + if (o.equals(temp.data)) { + deleteElement(temp); + return true; + } + } + } + return false; + } + + /** + * 删除指定位置的元素 + * @param index + * @return + */ + public Object remove(int index) { + rangeCheckElementIndex(index); + return deleteElement(node(index)); + } + + /** + * 删除指定节点元素 + * @param temp + * @return + */ + private Object deleteElement(Node temp) { + final Object element = temp.data; + final Node next = temp.next; + final Node prev = temp.previous; + + if (prev == null) { + first = next; + } else { + prev.next = next; + temp.previous = null; + } + + if (next == null) { + last = prev; + } else { + next.previous = prev; + temp.next = null; + } + + temp.data = null; + size--; + + return element; + } + + /** + * 检查索引元素的范围 + * @param index + */ + private void rangeCheckElementIndex(int index) { + if (!(index >= 0 && index < size)) { + throw new IndexOutOfBoundsException("索引越界"); + } + } + + /** + * 返回指定索引位置的节点 + * @param index + * @return + */ + Node node(int index) { + if (index < (size >> 1)) { + Node temp = first; + for (int i = 0; i < index; i++) + temp = temp.next; + return temp; + } else { + Node temp = last; + for (int i = size - 1; i > index; i--) + temp = temp.previous; + return temp; + } + } + + /** + * 用于表示一个节点 + * @author ikook + */ + private static class Node { + Node previous; // 上一个节点 + Object data; + Node next; // 下一个节点 + + public Node(Node previous, Object data, Node next) { + super(); + this.previous = previous; + this.data = data; + this.next = next; + } + } +} From b896ee318fa433c30e48c205e204d4dd2024b4a5 Mon Sep 17 00:00:00 2001 From: gaodekui <13526428940@163.com> Date: Thu, 23 Feb 2017 17:53:51 +0800 Subject: [PATCH 049/518] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- group16/1154151360/.classpath | 6 + group16/1154151360/.gitignore | 1 + group16/1154151360/.project | 17 ++ .../org.eclipse.core.resources.prefs | 2 + .../1154151360/src/com/list/ArrayList.java | 93 +++++++++++ .../1154151360/src/com/list/LinkedList.java | 158 ++++++++++++++++++ group16/1154151360/src/com/list/Stack.java | 35 ++++ 7 files changed, 312 insertions(+) create mode 100644 group16/1154151360/.classpath create mode 100644 group16/1154151360/.gitignore create mode 100644 group16/1154151360/.project create mode 100644 group16/1154151360/.settings/org.eclipse.core.resources.prefs create mode 100644 group16/1154151360/src/com/list/ArrayList.java create mode 100644 group16/1154151360/src/com/list/LinkedList.java create mode 100644 group16/1154151360/src/com/list/Stack.java diff --git a/group16/1154151360/.classpath b/group16/1154151360/.classpath new file mode 100644 index 0000000000..fb5011632c --- /dev/null +++ b/group16/1154151360/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/group16/1154151360/.gitignore b/group16/1154151360/.gitignore new file mode 100644 index 0000000000..ae3c172604 --- /dev/null +++ b/group16/1154151360/.gitignore @@ -0,0 +1 @@ +/bin/ diff --git a/group16/1154151360/.project b/group16/1154151360/.project new file mode 100644 index 0000000000..f88388f6d7 --- /dev/null +++ b/group16/1154151360/.project @@ -0,0 +1,17 @@ + + + DataStructure2 + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/group16/1154151360/.settings/org.eclipse.core.resources.prefs b/group16/1154151360/.settings/org.eclipse.core.resources.prefs new file mode 100644 index 0000000000..99f26c0203 --- /dev/null +++ b/group16/1154151360/.settings/org.eclipse.core.resources.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +encoding/=UTF-8 diff --git a/group16/1154151360/src/com/list/ArrayList.java b/group16/1154151360/src/com/list/ArrayList.java new file mode 100644 index 0000000000..bf19212fbf --- /dev/null +++ b/group16/1154151360/src/com/list/ArrayList.java @@ -0,0 +1,93 @@ +package com.list; + + + +public class ArrayList { + + private int size; + + private Object [] elementData = new Object[10]; + + public boolean add(Object data){ + + getRow(size+1); + elementData[size++] = data; + return true; + } + + public boolean add(int index, Object data){ + if (index < 0 || index > elementData.length){ + throw new IndexOutOfBoundsException("�±�Խ��"); + } + getRow(size + 1); + Object object = elementData [index]; + System.arraycopy(elementData, index,elementData , index + 1,size - index ); + elementData[index] = data; + size++; + return true; + } + + public Object get(int index){ + if (index < 0 || index > elementData.length){ + throw new IndexOutOfBoundsException("下标越界"); + } + return elementData[index]; + } + + public Object remove(int index){ + if (index < 0 || index > elementData.length){ + throw new IndexOutOfBoundsException("下标越界"); + } + Object object = elementData [index]; + System.arraycopy(elementData, index + 1 , elementData, index, size - 1 - index); + elementData[size--]= null; + return object; + } + + + private void getRow(int num){ + if (num > elementData.length ){ + int oldLength = elementData.length; + int newLength = ((num + elementData.length) * 3) >> 2; + Object [] oldelements = elementData; + elementData = new Object[newLength]; + System.arraycopy(oldelements, 0, elementData, 0, size); + } + } + + public int size(){ + return size; + } + + public int length(){ + return elementData.length; + } + public static void main(String[] args) { + ArrayList list = new ArrayList(); + + list.add("A"); + list.add("B"); + list.add("C"); + list.add("D"); + list.add("E"); + list.add("F"); + list.add("G"); + list.add("H"); + list.add("I"); + list.add("J"); + list.add("K"); + list.add("L"); + list.add(2, 1); + System.out.println("elementsData.Length: "+list.length()); + System.out.println("elementsData.size: "+list.size()); + for (int i = 0; i < list.size; i++){ + System.out.print(list.get(i)+ " "); + } + System.out.println(" "); + list.remove(2); + + for (int i = 0; i < list.size; i++){ + System.out.print(list.get(i)+ " "); + } + } +} diff --git a/group16/1154151360/src/com/list/LinkedList.java b/group16/1154151360/src/com/list/LinkedList.java new file mode 100644 index 0000000000..46f61fb667 --- /dev/null +++ b/group16/1154151360/src/com/list/LinkedList.java @@ -0,0 +1,158 @@ +package com.list; + +public class LinkedList { + + private int size; + + private Node head;//头节点 + + Node current; //当前节点 + + public LinkedList(){ + this.head = current = new Node(null); + this.size = 0; + } + + + private boolean add(Object object){ + addAfter(object); + size++; + return true; + } + + + private boolean add(int index,Object object) throws Exception{ + index(index - 1); + current.nextNode = new Node(object,current.nextNode.nextNode); + size++; + return true; + } + + + private boolean addFirst(Object object){ + Node node = new Node(object,null); + current = head.nextNode; + head.nextNode = node; + node.nextNode = current; + size++; + return true; + } + + + private boolean addLast(Object object){ + add(object); + return true; + } + + + private Object get(int index) throws Exception{ + index(index); + return current.object; + } + + + private Object remove(int index) throws Exception{ + + if (index == size - 1){ + Object object = removeLast(); + return object; + } + index(index - 1); + Object object = current.nextNode.object; + + current.nextNode = current.nextNode.nextNode; + size--; + return object; + } + + private Object removeFirst(){ + Object object = null; + if (size > 0){ + current = head.nextNode; + object = current.object; + head.nextNode = head.nextNode.nextNode; + size--; + } + return object; + } + + private Object removeLast() throws Exception{ + Object object = null; + if (size > 0){ + int j = 0; + current = head.nextNode; + + while (current != null){ + current = current.nextNode; + j++; + } + index(j - 1); + object = current.nextNode.object; + current.nextNode = null; + size--; + } + return object; + } + private void index (int index) throws Exception{ + + if (index < -1 || index > size){ + + throw new Exception(" "); + } + + if (index == -1){ + return; + } + current = head.nextNode; + int j = 0; + while (current != null && j < index){ + current = current.nextNode; + j++; + } + } + + + private void addAfter(Object object){ + + if (head.nextNode == null){ + + Node newNode = new Node(object,null); + }else{ + current = head.nextNode; + while (current.nextNode == null){ + current = current.nextNode; + } + current.setNode(new Node(object,null)); + } + + + } + + + + + private static class Node{ + + Object object; + + Node nextNode; + + + Node (Node nextNode){ + this.nextNode = nextNode; + } + + + Node (Object object, Node nextNode){ + this.nextNode = nextNode; + this.object = object; + } + + private void setNode(Node node){ + this.nextNode = node; + } + + } + + +} diff --git a/group16/1154151360/src/com/list/Stack.java b/group16/1154151360/src/com/list/Stack.java new file mode 100644 index 0000000000..f92a9e731c --- /dev/null +++ b/group16/1154151360/src/com/list/Stack.java @@ -0,0 +1,35 @@ +package com.list; + +import java.util.ArrayList; +import java.util.EmptyStackException; + +public class Stack { + + ArrayList elelmentData = new ArrayList(); + + //压入栈 + public void push(Object object){ + elelmentData.add(object); + } + + //弹出栈 + public Object pop(){ + if (isEmpty()){ throw new EmptyStackException();} + return elelmentData.remove(elelmentData.size() - 1); + } + + //取栈顶元素 + public Object peek(){ + if (isEmpty()){return null;} + return elelmentData.get(elelmentData.size() - 1); + } + + public boolean isEmpty(){ + return elelmentData.isEmpty(); + } + + public int size(){ + if (isEmpty()){throw new EmptyStackException();} + return elelmentData.size(); + } +} From fa9be5c1ff00c702ff26590adadf59ae80142c2f Mon Sep 17 00:00:00 2001 From: ikook <935542673@qq.com> Date: Thu, 23 Feb 2017 17:54:07 +0800 Subject: [PATCH 050/518] Queue(The madman implementation) --- .../basic_data_structure/MyQueueTest.java | 54 +++++++++++++++++++ .../ikook/basic_data_structure/MyQueue.java | 42 +++++++++++++++ 2 files changed, 96 insertions(+) create mode 100644 group18/935542673/Coding/junit/com/ikook/basic_data_structure/MyQueueTest.java create mode 100644 group18/935542673/Coding/src/com/ikook/basic_data_structure/MyQueue.java diff --git a/group18/935542673/Coding/junit/com/ikook/basic_data_structure/MyQueueTest.java b/group18/935542673/Coding/junit/com/ikook/basic_data_structure/MyQueueTest.java new file mode 100644 index 0000000000..8fb8ba825f --- /dev/null +++ b/group18/935542673/Coding/junit/com/ikook/basic_data_structure/MyQueueTest.java @@ -0,0 +1,54 @@ +package com.ikook.basic_data_structure; + +import static org.junit.Assert.*; + +import java.util.Date; + +import org.junit.Before; +import org.junit.Test; + +/** + * 此单元测试只测试了正常情况,一些异常情况没有测试。 + * @author ikook + */ +public class MyQueueTest { + + private MyQueue queue; + + @Before + public void setUp() { + queue = new MyQueue(); + + queue.enQueue(111); + queue.enQueue("222"); + queue.enQueue(new Date()); + } + + @Test + public void testEnQueue() { + queue.enQueue(444); + assertEquals(4, queue.size()); + } + + @Test + public void testDeQueue() { + assertEquals(111, queue.deQueue()); + } + + @Test + public void testSize() { + assertEquals(3, queue.size()); + + MyQueue queue = new MyQueue(); + assertEquals(0, queue.size()); + } + + @Test + public void testIsEmpty() { + assertEquals(false, queue.isEmpty()); + + MyQueue queue = new MyQueue(); + assertEquals(true, queue.isEmpty()); + } + +} diff --git a/group18/935542673/Coding/src/com/ikook/basic_data_structure/MyQueue.java b/group18/935542673/Coding/src/com/ikook/basic_data_structure/MyQueue.java new file mode 100644 index 0000000000..824d7579c6 --- /dev/null +++ b/group18/935542673/Coding/src/com/ikook/basic_data_structure/MyQueue.java @@ -0,0 +1,42 @@ +package com.ikook.basic_data_structure; + +/** + * @author ikook; QQ号码: 935542673 + */ +public class MyQueue { + + private MyLinkedList queue = new MyLinkedList(); + + /** + * 入队操作 + * @param obj + */ + public void enQueue(Object obj) { + queue.addLast(obj); + } + + /** + * 出队操作 + * @return + */ + public Object deQueue() { + return queue.removeFirst(); + } + + /** + * 队列的长度 + * @return + */ + public int size() { + return queue.size(); + } + + /** + * 队列是否为空 + * @return + */ + public boolean isEmpty() { + return queue.isEmpty(); + } + +} From d94ec28ebc1ebe629d51ac74edc0ce1ba36394b1 Mon Sep 17 00:00:00 2001 From: ikook <935542673@qq.com> Date: Thu, 23 Feb 2017 17:56:05 +0800 Subject: [PATCH 051/518] Stack(The madman implementation) --- .../basic_data_structure/MyStackTest.java | 55 ++++++++++++++ .../ikook/basic_data_structure/MyStack.java | 73 +++++++++++++++++++ 2 files changed, 128 insertions(+) create mode 100644 group18/935542673/Coding/junit/com/ikook/basic_data_structure/MyStackTest.java create mode 100644 group18/935542673/Coding/src/com/ikook/basic_data_structure/MyStack.java diff --git a/group18/935542673/Coding/junit/com/ikook/basic_data_structure/MyStackTest.java b/group18/935542673/Coding/junit/com/ikook/basic_data_structure/MyStackTest.java new file mode 100644 index 0000000000..fe1084e343 --- /dev/null +++ b/group18/935542673/Coding/junit/com/ikook/basic_data_structure/MyStackTest.java @@ -0,0 +1,55 @@ +package com.ikook.basic_data_structure; + +import static org.junit.Assert.*; + +import java.util.Date; + +import org.junit.Before; +import org.junit.Test; + +/** + * 此单元测试只测试了正常情况,一些异常情况没有测试。 + * @author ikook + */ +public class MyStackTest { + + private MyStack stack; + + @Before + public void setUp() { + stack = new MyStack(); + stack.push(111); + stack.push("222"); + stack.push(333); + stack.push(new Date()); + stack.push("555"); + } + + @Test + public void testPush() { + stack.push(93554); + assertEquals(6, stack.size()); + } + + @Test + public void testPop() { + assertEquals("555", stack.pop()); + assertEquals(4, stack.size()); + + assertEquals(new Date(), stack.pop()); + } + + @Test + public void testGetTop() { + assertEquals("555", stack.getTop()); + } + + @Test + public void testIsEmpty() { + assertEquals(false, stack.isEmpty()); + + MyStack stack = new MyStack(); + assertEquals(true, stack.isEmpty()); + } + +} diff --git a/group18/935542673/Coding/src/com/ikook/basic_data_structure/MyStack.java b/group18/935542673/Coding/src/com/ikook/basic_data_structure/MyStack.java new file mode 100644 index 0000000000..0ad6c05910 --- /dev/null +++ b/group18/935542673/Coding/src/com/ikook/basic_data_structure/MyStack.java @@ -0,0 +1,73 @@ +package com.ikook.basic_data_structure; + +/** + * @author ikook; QQ号码: 935542673 + */ +public class MyStack { + + private MyArrayList elementDate = new MyArrayList(); + + /** + * 入栈操作 + * @param obj + */ + public void push(Object obj) { + elementDate.add(obj); + } + + /** + * 出栈操作 + * @return + */ + public Object pop() { + emptyExce(); + return elementDate.remove(topIndex()); + } + + /** + * 获取栈顶元素 + * @return + */ + public Object getTop() { + emptyExce(); + return elementDate.get(topIndex()); + } + + /** + * 判断栈是否为空 + * @return + */ + public boolean isEmpty() { + return size() == 0; + } + + /** + * 获取栈的深度 + * @return + */ + public int size() { + return elementDate.size(); + } + + /** + * 栈顶元素所在索引封装类 + * @return + */ + private int topIndex() { + return size() - 1; + } + + /** + * 队列为空异常处理封装类 + */ + private void emptyExce() { + if (isEmpty()) { + try { + throw new Exception("队列为空"); + } catch (Exception e) { + e.printStackTrace(); + } + } + } + +} From 4618840afb8a253bf29068391dd5d52ab13926ff Mon Sep 17 00:00:00 2001 From: ikook <935542673@qq.com> Date: Thu, 23 Feb 2017 17:57:49 +0800 Subject: [PATCH 052/518] List(The madman implementation) --- .../ikook/basic_data_structure/MyList.java | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 group18/935542673/Coding/src/com/ikook/basic_data_structure/MyList.java diff --git a/group18/935542673/Coding/src/com/ikook/basic_data_structure/MyList.java b/group18/935542673/Coding/src/com/ikook/basic_data_structure/MyList.java new file mode 100644 index 0000000000..f1fa613d0e --- /dev/null +++ b/group18/935542673/Coding/src/com/ikook/basic_data_structure/MyList.java @@ -0,0 +1,22 @@ +package com.ikook.basic_data_structure; + +/** + * @author ikook QQ号码: 935542673 + */ +public interface MyList { + + public void add(Object o); + public void add(int index, Object o); + + public int size(); + + public boolean isEmpty(); + + public Object get(int index); + + public Object remove(int index); + public boolean remove(Object obj); + + public Object set(int index, Object obj); + +} From 957bb914e3a8a59a9a04bad16ce86f7018b5bc29 Mon Sep 17 00:00:00 2001 From: HuiZhou-Xmu <1814014897@qq.com> Date: Thu, 23 Feb 2017 17:59:12 +0800 Subject: [PATCH 053/518] Basic Data Structure Test---Version 1.0 --- group01/1814014897/zhouhui/.classpath | 7 ++ group01/1814014897/zhouhui/.gitignore | 1 + group01/1814014897/zhouhui/.project | 17 +++ .../.settings/org.eclipse.jdt.core.prefs | 11 ++ .../src/BasicDataStructure/ArrayList.java | 74 ++++++++++++ .../BasicDataStructure/BinaryTreeNode.java | 56 +++++++++ .../src/BasicDataStructure/Iterator.java | 7 ++ .../src/BasicDataStructure/LinkedList.java | 113 ++++++++++++++++++ .../zhouhui/src/BasicDataStructure/List.java | 9 ++ .../zhouhui/src/BasicDataStructure/Queue.java | 25 ++++ .../zhouhui/src/BasicDataStructure/Stack.java | 25 ++++ .../src/BasicDataStructureTest/AllTest.java | 18 +++ .../BasicDataStructureTest/ArrayListTest.java | 72 +++++++++++ .../BinaryTreeNodeTest.java | 77 ++++++++++++ .../LinkedListTest.java | 103 ++++++++++++++++ .../src/BasicDataStructureTest/QueueTest.java | 53 ++++++++ .../src/BasicDataStructureTest/StackTest.java | 67 +++++++++++ 17 files changed, 735 insertions(+) create mode 100644 group01/1814014897/zhouhui/.classpath create mode 100644 group01/1814014897/zhouhui/.gitignore create mode 100644 group01/1814014897/zhouhui/.project create mode 100644 group01/1814014897/zhouhui/.settings/org.eclipse.jdt.core.prefs create mode 100644 group01/1814014897/zhouhui/src/BasicDataStructure/ArrayList.java create mode 100644 group01/1814014897/zhouhui/src/BasicDataStructure/BinaryTreeNode.java create mode 100644 group01/1814014897/zhouhui/src/BasicDataStructure/Iterator.java create mode 100644 group01/1814014897/zhouhui/src/BasicDataStructure/LinkedList.java create mode 100644 group01/1814014897/zhouhui/src/BasicDataStructure/List.java create mode 100644 group01/1814014897/zhouhui/src/BasicDataStructure/Queue.java create mode 100644 group01/1814014897/zhouhui/src/BasicDataStructure/Stack.java create mode 100644 group01/1814014897/zhouhui/src/BasicDataStructureTest/AllTest.java create mode 100644 group01/1814014897/zhouhui/src/BasicDataStructureTest/ArrayListTest.java create mode 100644 group01/1814014897/zhouhui/src/BasicDataStructureTest/BinaryTreeNodeTest.java create mode 100644 group01/1814014897/zhouhui/src/BasicDataStructureTest/LinkedListTest.java create mode 100644 group01/1814014897/zhouhui/src/BasicDataStructureTest/QueueTest.java create mode 100644 group01/1814014897/zhouhui/src/BasicDataStructureTest/StackTest.java diff --git a/group01/1814014897/zhouhui/.classpath b/group01/1814014897/zhouhui/.classpath new file mode 100644 index 0000000000..373dce4005 --- /dev/null +++ b/group01/1814014897/zhouhui/.classpath @@ -0,0 +1,7 @@ + + + + + + + diff --git a/group01/1814014897/zhouhui/.gitignore b/group01/1814014897/zhouhui/.gitignore new file mode 100644 index 0000000000..ae3c172604 --- /dev/null +++ b/group01/1814014897/zhouhui/.gitignore @@ -0,0 +1 @@ +/bin/ diff --git a/group01/1814014897/zhouhui/.project b/group01/1814014897/zhouhui/.project new file mode 100644 index 0000000000..fab8d7f04c --- /dev/null +++ b/group01/1814014897/zhouhui/.project @@ -0,0 +1,17 @@ + + + 2017Learning + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/group01/1814014897/zhouhui/.settings/org.eclipse.jdt.core.prefs b/group01/1814014897/zhouhui/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000000..3a21537071 --- /dev/null +++ b/group01/1814014897/zhouhui/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/group01/1814014897/zhouhui/src/BasicDataStructure/ArrayList.java b/group01/1814014897/zhouhui/src/BasicDataStructure/ArrayList.java new file mode 100644 index 0000000000..3fdea3d732 --- /dev/null +++ b/group01/1814014897/zhouhui/src/BasicDataStructure/ArrayList.java @@ -0,0 +1,74 @@ +package BasicDataStructure; + +import java.util.Arrays; + +public class ArrayList implements List { + + private int size = 0; + + private Object[] elementData = new Object[100]; + + public void add(Object o){ + ensureCapacity(size + 1); //size increase,in order to have enough capacity. + elementData[size++] = o; //similar to: elementData[size]=o; size++; + } + + private void ensureCapacity(int minCapacity){ + if(minCapacity > elementData.length){ + grow(minCapacity); + } + } + + private void grow(int minCapacity){ + int oldCapacity = elementData.length; + int newCapacity = oldCapacity + ( oldCapacity >> 1 ); + if(newCapacity < minCapacity){ + newCapacity = minCapacity; + } + elementData = Arrays.copyOf(elementData, newCapacity); + + } + + public void add(int index, Object o){ + if(index < 0 || index > size) throw new IndexOutOfBoundsException("Index:"+index+",Size:"+size); + ensureCapacity(size+1); + System.arraycopy(elementData, index, elementData, index + 1, size - index); + elementData[index] = o; + size++; + } + + public Object get(int index){ + if(index < 0 || index >= size) throw new IndexOutOfBoundsException("Index:"+index+",Size:"+size); + return elementData[index]; + } + + public Object remove(int index){ + if(index < 0 || index >= size) throw new IndexOutOfBoundsException("Index:"+index+",Size:"+size); + System.arraycopy(elementData, index + 1, elementData, index, size - index - 1); + elementData[size - 1] = null; + size--; + return elementData; + } + + public int size(){ + return size; + } + + public Iterator iterator(){ + return new ArrayListIterator(); + } + + private class ArrayListIterator implements Iterator{ + + private int pos = 0; + + public boolean hasNext() { + return pos < size; + } + + public Object next() { + return elementData[pos++]; + } + } + +} diff --git a/group01/1814014897/zhouhui/src/BasicDataStructure/BinaryTreeNode.java b/group01/1814014897/zhouhui/src/BasicDataStructure/BinaryTreeNode.java new file mode 100644 index 0000000000..b11ca68417 --- /dev/null +++ b/group01/1814014897/zhouhui/src/BasicDataStructure/BinaryTreeNode.java @@ -0,0 +1,56 @@ +package BasicDataStructure; + +public class BinaryTreeNode{ + + private Object data; + private BinaryTreeNode left; + private BinaryTreeNode right; + + public BinaryTreeNode(Object data){ + this.data = data; + left = null; + right = null; + } + + 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){ + if((Integer)o < (Integer)this.data) + { + if(this.left == null){ + BinaryTreeNode node = new BinaryTreeNode(o); + this.setLeft(node); + return node; + }else{ + return this.left.insert(o); + } + }else{ + if(this.right == null){ + BinaryTreeNode node = new BinaryTreeNode(o); + this.setRight(node); + return node; + }else{ + return this.right.insert(o); + } + } + } + } + + diff --git a/group01/1814014897/zhouhui/src/BasicDataStructure/Iterator.java b/group01/1814014897/zhouhui/src/BasicDataStructure/Iterator.java new file mode 100644 index 0000000000..c70ebb77dd --- /dev/null +++ b/group01/1814014897/zhouhui/src/BasicDataStructure/Iterator.java @@ -0,0 +1,7 @@ +package BasicDataStructure; + +public interface Iterator { + public boolean hasNext(); + public Object next(); + +} diff --git a/group01/1814014897/zhouhui/src/BasicDataStructure/LinkedList.java b/group01/1814014897/zhouhui/src/BasicDataStructure/LinkedList.java new file mode 100644 index 0000000000..b99e6f15f9 --- /dev/null +++ b/group01/1814014897/zhouhui/src/BasicDataStructure/LinkedList.java @@ -0,0 +1,113 @@ +package BasicDataStructure; + +public class LinkedList implements List { + + private Node head; + private int size = 0; + + public void add(Object o){ + if(head == null){ + head = new Node(o); + }else{ + Node pos = head; + while(pos.next != null){ + pos = pos.next; + } + pos.next = new Node(o); + } + size++; + } + + public void add(int index , Object o){ + if(index < 0 || index >size ) throw new IndexOutOfBoundsException("Index:"+index+",Size"+size); + if(index == 0) { + Node node = new Node(o); + node.next = head; + head = node; + } + else{ + Node pos = head; + for(int i = 0;i < index-1;i++){ + pos = pos.next; + } + Node node = new Node(o); + node.next = pos.next; + pos.next = node; + } + size++; + } + + public Object get(int index){ + if(index < 0 || index >=size ) throw new IndexOutOfBoundsException("Index:"+index+",Size"+size); + Node pos = head; + for(int i = 0;i < index;i++){ + pos = pos.next; + } + return pos.data; + } + + public Object remove(int index){ + if(index < 0 || index >=size ) throw new IndexOutOfBoundsException("Index:"+index+",Size:"+size); + Node element = head; + if(index == 0){ + head = head.next; + }else{ + Node pos = head; + for(int i = 0;i < index - 1;i++){ + pos = pos.next; + } + element = pos.next; + pos.next = pos.next.next; + } + size--; + return element.data; + } + + public int size(){ + return size; + } + + public void addFirst(Object o){ + add(0,o); + } + public void addLast(Object o){ + add(size,o); + } + public Object removeFirst(){ + return remove(0); + } + public Object removeLast(){ + return remove(size-1); + } + public Iterator iterator(){ + return new LinkedListIterator(); + } + + class LinkedListIterator implements Iterator{ + + private Node node = head; + private int pos = 0; + @Override + public boolean hasNext() { + return pos < size; + } + + @Override + public Object next() { + pos++; + if(pos != 1){ + node = node.next; + } + return node.data; + } + } + + private static class Node{ + Object data; + Node next; + public Node(Object data){ + this.data = data; + next = null; + } + } +} diff --git a/group01/1814014897/zhouhui/src/BasicDataStructure/List.java b/group01/1814014897/zhouhui/src/BasicDataStructure/List.java new file mode 100644 index 0000000000..746612c77e --- /dev/null +++ b/group01/1814014897/zhouhui/src/BasicDataStructure/List.java @@ -0,0 +1,9 @@ +package BasicDataStructure; + +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/group01/1814014897/zhouhui/src/BasicDataStructure/Queue.java b/group01/1814014897/zhouhui/src/BasicDataStructure/Queue.java new file mode 100644 index 0000000000..c4fe4c578e --- /dev/null +++ b/group01/1814014897/zhouhui/src/BasicDataStructure/Queue.java @@ -0,0 +1,25 @@ +package BasicDataStructure; + +public class Queue { + + private LinkedList linkedList = new LinkedList(); + private int size = 0; + + public void enQueue(Object o){ + linkedList.add(o); + size++; + } + + public Object deQueue(){ + size--; + return linkedList.removeFirst(); + } + + public boolean isEmpty(){ + return linkedList.size() == 0; + } + + public int size(){ + return size; + } +} diff --git a/group01/1814014897/zhouhui/src/BasicDataStructure/Stack.java b/group01/1814014897/zhouhui/src/BasicDataStructure/Stack.java new file mode 100644 index 0000000000..c524ee618d --- /dev/null +++ b/group01/1814014897/zhouhui/src/BasicDataStructure/Stack.java @@ -0,0 +1,25 @@ +package BasicDataStructure; + +public class Stack { + private ArrayList elementData = new ArrayList(); + private int size = 0; + + public void push(Object o){ + elementData.add(o); + size++; + } + + public Object pop(){ + return elementData.remove(--size); + } + + public Object peek(){ + return elementData.get(size - 1); + } + public boolean isEmpty(){ + return elementData.size() == 0; + } + public int size(){ + return elementData.size(); + } +} diff --git a/group01/1814014897/zhouhui/src/BasicDataStructureTest/AllTest.java b/group01/1814014897/zhouhui/src/BasicDataStructureTest/AllTest.java new file mode 100644 index 0000000000..ff09c3e4bd --- /dev/null +++ b/group01/1814014897/zhouhui/src/BasicDataStructureTest/AllTest.java @@ -0,0 +1,18 @@ +package BasicDataStructureTest; + +import org.junit.runner.RunWith; +import org.junit.runners.Suite; +import org.junit.runners.Suite.SuiteClasses; + +@RunWith(Suite.class) +@SuiteClasses({ + ArrayListTest.class, + BinaryTreeNodeTest.class, + LinkedListTest.class, + QueueTest.class, + StackTest.class +}) + +public class AllTest { + +} diff --git a/group01/1814014897/zhouhui/src/BasicDataStructureTest/ArrayListTest.java b/group01/1814014897/zhouhui/src/BasicDataStructureTest/ArrayListTest.java new file mode 100644 index 0000000000..61cf94a49c --- /dev/null +++ b/group01/1814014897/zhouhui/src/BasicDataStructureTest/ArrayListTest.java @@ -0,0 +1,72 @@ +package BasicDataStructureTest; + +import org.junit.*; +import BasicDataStructure.ArrayList; +import BasicDataStructure.Iterator; + +public class ArrayListTest { + + private ArrayList arrayList = new ArrayList(); + + @Before + public void setUp() throws Exception { + for(int i = 0;i < 100 ; i++){ + arrayList.add(i); + } + } + + @Test + public void testAddObject() { + for(int i = 0;i < 100;i++){ + Assert.assertEquals(arrayList.get(i), i); + } + } + + @Test + public void testAddIntObject() { + arrayList.add(0,10); + arrayList.add(22, 44); + arrayList.add(40, 5); + arrayList.add(100,88); + Assert.assertEquals(arrayList.get(0), 10); + Assert.assertEquals(arrayList.get(22),44); + Assert.assertEquals(arrayList.get(40), 5); + Assert.assertEquals(arrayList.get(100), 88); + } + + @Test + public void testGet() { + Assert.assertEquals(arrayList.get(0), 0); + Assert.assertEquals(arrayList.get(33), 33); + Assert.assertEquals(arrayList.get(77), 77); + Assert.assertEquals(arrayList.get(99), 99); + } + + @Test + public void testRemove() { + arrayList.remove(0); + Assert.assertEquals(arrayList.get(0), 1); + arrayList.remove(50); + Assert.assertEquals(arrayList.get(50), 52); + arrayList.remove(97); + Assert.assertEquals(arrayList.size(), 97); + Assert.assertEquals(arrayList.get(96), 98); + } + + @Test + public void testSize() { + Assert.assertEquals(arrayList.size(), 100); + arrayList.add(5,5); + Assert.assertEquals(arrayList.size(),101); + arrayList.remove(5); + Assert.assertEquals(arrayList.size(), 100); + } + + @Test + public void testIterator() { + Iterator iterator = arrayList.iterator(); + for(int i=0;iterator.hasNext();i++){ + Assert.assertEquals(iterator.next(),i); + } + } +} diff --git a/group01/1814014897/zhouhui/src/BasicDataStructureTest/BinaryTreeNodeTest.java b/group01/1814014897/zhouhui/src/BasicDataStructureTest/BinaryTreeNodeTest.java new file mode 100644 index 0000000000..cf7e899816 --- /dev/null +++ b/group01/1814014897/zhouhui/src/BasicDataStructureTest/BinaryTreeNodeTest.java @@ -0,0 +1,77 @@ +package BasicDataStructureTest; + +import org.junit.*; +import BasicDataStructure.BinaryTreeNode; + + +public class BinaryTreeNodeTest { + + private BinaryTreeNode root = new BinaryTreeNode(5); + + @Before + public void setUp() throws Exception { + root.insert(2); + root.insert(7); + root.insert(1); + root.insert(6); + } + + @Test + public void testGetData() { + Assert.assertEquals(root.getData(), 5); + Assert.assertEquals(root.getLeft().getData(), 2); + Assert.assertEquals(root.getRight().getData(), 7); + Assert.assertEquals(root.getLeft().getLeft().getData(), 1); + Assert.assertEquals(root.getRight().getLeft().getData(), 6); + } + + @Test + public void testSetData() { + root.setData(8); + Assert.assertEquals(root.getData(),8); + root.getLeft().setData(88); + Assert.assertEquals(root.getLeft().getData(),88); + root.getRight().setData(888); + Assert.assertEquals(root.getRight().getData(),888); + } + + @Test + public void testGetLeft() { + BinaryTreeNode node_left = root.getLeft(); + Assert.assertEquals(node_left.getData(), 2); + BinaryTreeNode node_left_left = root.getLeft().getLeft(); + Assert.assertEquals(node_left_left.getData(), 1); + } + + @Test + public void testSetLeft() { + BinaryTreeNode node = new BinaryTreeNode(100); + root.setLeft(node); + Assert.assertEquals(root.getLeft().getData(), 100); + } + + @Test + public void testGetRight() { + BinaryTreeNode node_right = root.getRight(); + Assert.assertEquals(node_right.getData(), 7); + root.insert(8); + BinaryTreeNode node_right_right = root.getRight().getRight(); + Assert.assertEquals(node_right_right.getData(), 8); + } + + @Test + public void testSetRight() { + BinaryTreeNode node = new BinaryTreeNode(100); + root.setRight(node); + Assert.assertEquals(root.getRight().getData(), 100); + } + + @Test + public void testInsert() { + root.insert(4); + root.insert(8); + Assert.assertEquals(root.getLeft().getRight().getData(), 4); + Assert.assertEquals(root.getRight().getRight().getData(), 8); + } + +} diff --git a/group01/1814014897/zhouhui/src/BasicDataStructureTest/LinkedListTest.java b/group01/1814014897/zhouhui/src/BasicDataStructureTest/LinkedListTest.java new file mode 100644 index 0000000000..cb0b2e3191 --- /dev/null +++ b/group01/1814014897/zhouhui/src/BasicDataStructureTest/LinkedListTest.java @@ -0,0 +1,103 @@ +package BasicDataStructureTest; + +import org.junit.*; +import BasicDataStructure.Iterator; +import BasicDataStructure.LinkedList; + +public class LinkedListTest { + + private LinkedList linkedList = new LinkedList(); + + @Before + public void setUp() throws Exception { + for(int i=0;i<100;i++){ + linkedList.add(i); + } + } + + @Test + public void testAddObject() { + for(int i=0;i<200;i++){ + linkedList.add(i); + } + for(int i=0;i<100;i++){ + Assert.assertEquals(linkedList.get(i), i); + } + for(int i=100;i<300;i++){ + Assert.assertEquals(linkedList.get(i), i-100); + } + } + + @Test + public void testAddIntObject() { + linkedList.add(0, 10); + Assert.assertEquals(linkedList.get(0), 10); + linkedList.add(5,60); + Assert.assertEquals(linkedList.get(5), 60); + Assert.assertEquals(linkedList.get(101), 99); + } + + @Test + public void testGet() { + for(int i =0;i<100;i++){ + Assert.assertEquals(linkedList.get(i), i); + } + } + + @Test + public void testRemove() { + Assert.assertEquals(linkedList.remove(0), 0); + Assert.assertEquals(linkedList.remove(0), 1); + Assert.assertEquals(linkedList.size(), 98); + linkedList.remove(97); + Assert.assertEquals(linkedList.get(96), 98); + } + + @Test + public void testSize() { + linkedList.add(0); + Assert.assertEquals(linkedList.size(), 101); + linkedList.add(0, 10); + Assert.assertEquals(linkedList.size(), 102); + linkedList.remove(0); + Assert.assertEquals(linkedList.size(), 101); + } + + @Test + public void testAddFirst() { + linkedList.addFirst(22); + Assert.assertEquals(linkedList.get(0), 22); + linkedList.addFirst(44); + Assert.assertEquals(linkedList.get(0), 44); + Assert.assertEquals(linkedList.size(), 102); + } + + @Test + public void testAddLast() { + linkedList.addLast(22); + Assert.assertEquals(linkedList.get(100), 22); + linkedList.addLast(44); + Assert.assertEquals(linkedList.get(101), 44); + } + + @Test + public void testRemoveFirst() { + Assert.assertEquals(linkedList.removeFirst(), 0); + Assert.assertEquals(linkedList.removeFirst(), 1); + } + + @Test + public void testRemoveLast() { + Assert.assertEquals(linkedList.removeLast(),99 ); + Assert.assertEquals(linkedList.removeLast(), 98); + } + + @Test + public void testIterator() { + Iterator iterator = linkedList.iterator(); + for(int i = 0;iterator.hasNext();i++){ + Assert.assertEquals(iterator.next(), i); + } + } + +} diff --git a/group01/1814014897/zhouhui/src/BasicDataStructureTest/QueueTest.java b/group01/1814014897/zhouhui/src/BasicDataStructureTest/QueueTest.java new file mode 100644 index 0000000000..9af9ca2288 --- /dev/null +++ b/group01/1814014897/zhouhui/src/BasicDataStructureTest/QueueTest.java @@ -0,0 +1,53 @@ +package BasicDataStructureTest; + +import org.junit.*; +import BasicDataStructure.Queue; + + +public class QueueTest { + + Queue queue = new Queue(); + + @Before + public void setUp() throws Exception { + for(int i=0;i<100;i++){ + queue.enQueue(i); + } + } + + @Test + public void testEnQueue() { + Assert.assertEquals(queue.size(), 100); + for(int i =0;i<100;i++){ + queue.enQueue(i); + } + Assert.assertEquals(queue.size(), 200); + } + + @Test + public void testDeQueue() { + for(int i =0;i<100;i++){ + Assert.assertEquals(queue.deQueue(), i); + } + + } + + @Test + public void testIsEmpty() { + Assert.assertEquals(queue.isEmpty(), false); + for(int i=0;i<100;i++){ + queue.deQueue(); + } + Assert.assertEquals(queue.isEmpty(), true); + } + + @Test + public void testSize() { + Assert.assertEquals(queue.size(), 100); + queue.enQueue(100); + Assert.assertEquals(queue.size(), 101); + queue.deQueue(); + Assert.assertEquals(queue.size(), 100); + } + +} diff --git a/group01/1814014897/zhouhui/src/BasicDataStructureTest/StackTest.java b/group01/1814014897/zhouhui/src/BasicDataStructureTest/StackTest.java new file mode 100644 index 0000000000..9f9c930600 --- /dev/null +++ b/group01/1814014897/zhouhui/src/BasicDataStructureTest/StackTest.java @@ -0,0 +1,67 @@ +package BasicDataStructureTest; + +import org.junit.*; +import BasicDataStructure.Stack; + + +public class StackTest { + + Stack stack = new Stack(); + + @Before + public void setUp() throws Exception { + for(int i =0 ;i <100;i++){ + stack.push(i); + } + } + + @Test + public void testPush() { + Assert.assertEquals(stack.peek(), 99); + for(int i =0;i <200;i++){ + stack.push(i); + } + Assert.assertEquals(stack.peek(), 199); + Assert.assertEquals(stack.size(), 300); + } + + @Test + public void testPop() { + stack.pop(); + Assert.assertEquals(stack.peek(), 98); + for(int i=0;i<99;i++){ + stack.pop(); + } + Assert.assertEquals(stack.size(), 0); + } + + @Test + public void testPeek() { + for(int i=0;i<100;i++){ + Assert.assertEquals(stack.peek(), 99); + Assert.assertEquals(stack.size(), 100); + } + stack.pop(); + Assert.assertEquals(stack.peek(), 98); + } + + @Test + public void testIsEmpty() { + Assert.assertEquals(stack.isEmpty(), false); + for(int i =0 ;i <100;i++){ + stack.pop(); + } + Assert.assertEquals(stack.isEmpty(), true); + } + + @Test + public void testSize() { + stack.push(100); + Assert.assertEquals(stack.size(), 101); + stack.pop(); + Assert.assertEquals(stack.size(), 100); + stack.peek(); + Assert.assertEquals(stack.size(), 100); + } + +} From 2660fd24231850782c3cb97669b40e3ccdddbc3e Mon Sep 17 00:00:00 2001 From: ikook <935542673@qq.com> Date: Thu, 23 Feb 2017 18:00:44 +0800 Subject: [PATCH 054/518] Datum --- ...50\347\232\204\351\227\256\351\242\230.docx" | Bin 0 -> 82125 bytes 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 "group18/935542673/Datum/\345\205\263\344\272\216.metadata\347\233\256\345\275\225\345\222\214.gitignore\344\275\277\347\224\250\347\232\204\351\227\256\351\242\230.docx" diff --git "a/group18/935542673/Datum/\345\205\263\344\272\216.metadata\347\233\256\345\275\225\345\222\214.gitignore\344\275\277\347\224\250\347\232\204\351\227\256\351\242\230.docx" "b/group18/935542673/Datum/\345\205\263\344\272\216.metadata\347\233\256\345\275\225\345\222\214.gitignore\344\275\277\347\224\250\347\232\204\351\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p*5yf*XIDXC*y-%l}~gzmxWN z2FB_C!vC2&`=5&cnP&U9=06q3?EDS*@1)!R6tP_vQ)pTP08rHNXOzpoMcn^g_a7n{ ze#gB0Q^Y?5W&SNf8RxG7{EyV%e}v8aQv}*M2~7JZgG`?bqoj^2uib0PtD=kMbuER{t~W>>XS!js64t|A&3&&n583;5(QaSsDF5 vEA>`sWES}I2RFxG0Yd-oclO_bf588;5um?+p#xxkKCnNp(m6gC8o>VtPFd&z literal 0 HcmV?d00001 From 335ea91d7276b0634c4a780555eb6f12ecc1a2f0 Mon Sep 17 00:00:00 2001 From: wa122as Date: Thu, 23 Feb 2017 18:04:47 +0800 Subject: [PATCH 055/518] =?UTF-8?q?=E5=9F=BA=E6=9C=AC=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E7=BB=93=E6=9E=84=E4=BD=9C=E4=B8=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- group15/1521_653895972/basic/ArrayList.java | 81 +++++++++ group15/1521_653895972/basic/BasicTest.java | 150 ++++++++++++++++ .../1521_653895972/basic/BinaryTreeNode.java | 85 +++++++++ group15/1521_653895972/basic/Iterator.java | 7 + group15/1521_653895972/basic/LinkedList.java | 170 ++++++++++++++++++ group15/1521_653895972/basic/List.java | 9 + group15/1521_653895972/basic/Queue.java | 28 +++ group15/1521_653895972/basic/Stack.java | 33 ++++ 8 files changed, 563 insertions(+) create mode 100644 group15/1521_653895972/basic/ArrayList.java create mode 100644 group15/1521_653895972/basic/BasicTest.java create mode 100644 group15/1521_653895972/basic/BinaryTreeNode.java create mode 100644 group15/1521_653895972/basic/Iterator.java create mode 100644 group15/1521_653895972/basic/LinkedList.java create mode 100644 group15/1521_653895972/basic/List.java create mode 100644 group15/1521_653895972/basic/Queue.java create mode 100644 group15/1521_653895972/basic/Stack.java diff --git a/group15/1521_653895972/basic/ArrayList.java b/group15/1521_653895972/basic/ArrayList.java new file mode 100644 index 0000000000..7b2d1cef5e --- /dev/null +++ b/group15/1521_653895972/basic/ArrayList.java @@ -0,0 +1,81 @@ +package com.oneces.tool.basic; + +import java.util.Arrays; +import java.util.NoSuchElementException; + +public class ArrayList implements List { + //实例化空数组 不用每次都new + private static final Object[] Empty_elementData = {}; + private int size = 0; + + private Object[] elementData = new Object[100]; + + public ArrayList() { + this.elementData = Empty_elementData; + } + //检查是否越界 + private void checkLenght(int index){ + if (index - size > 0) + throw new IndexOutOfBoundsException(); + } + //增加数组容量 + private void kuorong(){ + elementData = Arrays.copyOf(elementData, size + 1); + } + public void add(Object o) { + kuorong(); + elementData[size++] = o; + } + + public void add(int index, Object o) { + kuorong(); + System.arraycopy(elementData, index, elementData, index + 1, size - index); + elementData[index] = o; + size++; + } + + public Object get(int index) { + checkLenght(index); + return elementData[index]; + } + + public Object remove(int index) { + checkLenght(index); + Object element =elementData[index]; + int movesize=size-index-1; + System.arraycopy(elementData,index+1,elementData,index,movesize); + elementData[--size]=null; + return element; + } + + public int size() { + return size; + } + + public Iterator iterator() { + return new ArrayItr(); + } + private class ArrayItr implements Iterator{ + int cursor;//游标 + @Override + public boolean hasNext() { + return cursor!=size; + } + + @Override + public Object next() { + int i=cursor; + if (i>size)throw new NoSuchElementException(); + Object [] newElementData = ArrayList.this.elementData; + if (i>newElementData.length)throw new IndexOutOfBoundsException(); + cursor=i+1; + return newElementData[i]; + } + } + + @Override + public String toString() { + Object[] s = Arrays.copyOf(elementData,size); + return Arrays.toString(s); + } +} diff --git a/group15/1521_653895972/basic/BasicTest.java b/group15/1521_653895972/basic/BasicTest.java new file mode 100644 index 0000000000..3f3567169a --- /dev/null +++ b/group15/1521_653895972/basic/BasicTest.java @@ -0,0 +1,150 @@ +package com.oneces.tool.basic; + +import org.junit.Assert; +import org.junit.Test; + +/** + * Created by wanc on 2017/2/21. + */ +public class BasicTest { + + @Test + public void test() { + //测试 +// testArrayList(); +// testLinkedList(); +// testBinaryTreeNode(); +// testStack(); + testQueue(); + } + + + public void testQueue(){ + Queue queue = new Queue(); + queue.enQueue("S"); + queue.enQueue("Y"); + queue.enQueue(5); + System.out.println(queue); + System.out.println("queue.size()="+queue.size()); + System.out.println("queue.deQueue()="+queue.deQueue()); + System.out.println(queue); + System.out.println("queue.isEmpty()="+queue.isEmpty()); + System.out.println(queue); + } + public void testStack(){ + Stack stack = new Stack(); + stack.push("S"); + stack.push("Y"); + stack.push(5); + System.out.println("stack.size()="+stack.size()); + System.out.println("stack.peek()="+stack.peek()); + System.out.println(stack); + System.out.println("stack.isEmpty()="+stack.isEmpty()); + stack.pop(); + System.out.println(stack); + } + public void testBinaryTreeNode(){ + System.out.println("-------------------BinaryTreeNode 测试开始-------------------"); + System.out.println("new 一个实例"); + BinaryTreeNode root = new BinaryTreeNode(); + root.insert(5); + root.insert(6); + root.insert(9); + root.insert(3); + root.insert(3); + root.insert(2); + root.insert(10); + System.out.println(root); + System.out.println("-------------------LinkedList 测试结束-------------------"); + } + public void testLinkedList() { + System.out.println("-------------------LinkedList 测试开始-------------------"); + System.out.println("new 一个实例"); + LinkedList list = new LinkedList(); + System.out.println("1.add(\"A\") 添加元素----A"); + list.add("A"); + System.out.println("结果:"+list); + System.out.println(); + System.out.println("2.add(\"B\") 添加元素----B"); + list.add("B"); + System.out.println("结果:"+list); + System.out.println(); + System.out.println("3.add(3) 添加元素----3"); + list.add(3); + System.out.println("结果:"+list); + System.out.println(); + System.out.println("4.add(1, 3) 在下标1插入元素----3"); + list.add(1, 3); + System.out.println("结果:"+list); + System.out.println(); + System.out.println("5.add(3, 6) 在下标3插入元素----6"); + list.add(3, 6); + System.out.println("结果:"+list); + System.out.println(); + System.out.println("6.remove(0) 删除下标0元素"); + list.remove(0); + System.out.println("结果:"+list); + System.out.println(); + System.out.println("7.size() 获取size"); + System.out.println("结果:"+list.size()); + System.out.println(); + System.out.println("8.addFirst(\"F\") 在首位前插入F"); + list.addFirst("F"); + System.out.println("结果:"+list); + System.out.println("9.addLast(\"K\") 在末位前插入K"); + list.addLast("K"); + System.out.println("结果:"+list); + System.out.println("10.removeFirst() 删除首位"); + list.removeFirst(); + System.out.println("结果:"+list); + System.out.println("11.removeLast() 删除末尾"); + list.removeLast(); + System.out.println("结果:"+list); + System.out.println(); + System.out.println("12.迭代器"); + Iterator i = list.iterator(); + while (i.hasNext()){ + System.out.println(i.next()); + } + System.out.println("-------------------LinkedList 测试结束-------------------"); + } + public void testArrayList() { + System.out.println("-------------------ArrayList 测试开始-------------------"); + System.out.println("new 一个实例"); + ArrayList list = new ArrayList(); + System.out.println("1.添加元素----A"); + list.add("A"); + Assert.assertEquals(list.get(0),"A"); + System.out.println("结果:"+list); + System.out.println(); + System.out.println("2.添加元素----B"); + list.add("B"); + System.out.println("结果:"+list); + System.out.println(); + System.out.println("3.添加元素----3"); + list.add(3); + System.out.println("结果:"+list); + System.out.println(); + System.out.println("4.在下标1插入元素----3"); + list.add(1, 3); + System.out.println("结果:"+list); + System.out.println(); + System.out.println("5.在下标3插入元素----6"); + list.add(3, 6); + System.out.println("结果:"+list); + System.out.println(); + System.out.println("6.删除下标0元素"); + list.remove(0); + System.out.println("结果:"+list); + System.out.println(); + System.out.println("7.获取size"); + System.out.println("结果:"+list.size()); + System.out.println(); + System.out.println("8.迭代器"); + Iterator i = list.iterator(); + while (i.hasNext()){ + System.out.println(i.next()); + } + System.out.println("-------------------ArrayList 测试结束-------------------"); + } +} diff --git a/group15/1521_653895972/basic/BinaryTreeNode.java b/group15/1521_653895972/basic/BinaryTreeNode.java new file mode 100644 index 0000000000..2e4fcae8dc --- /dev/null +++ b/group15/1521_653895972/basic/BinaryTreeNode.java @@ -0,0 +1,85 @@ +package com.oneces.tool.basic; + +/** + * 实现二叉树 + * left总比父节点小 + * right总比父节点大 + */ +public class BinaryTreeNode { + private Node root; + private int size = 0; + + public void insert(int data) { + final Node newNode = new Node(data); + if (root == null) { + root = newNode; + } else { + Node current = root; + while (true) { + Node parent = current; + if (data < current.data) {//left + current = current.left; + if (current == null) { + parent.left = newNode; + return; + } + } else {//right + current = current.right; + if (current == null) { + parent.right = newNode; + return; + } + } + } + } + size++; + } + + + //先序遍历 + private String preTraverse(Node node) { + if (node == null) + return ""; + else + return node.data + preJointComma(preTraverse(node.left)) + preJointComma(preTraverse(node.right)); + } + //中序遍历 + private String midTraverse(Node node) { + if (node == null) + return ""; + else + return midTraverse(node.left)+" "+node.data+" " +midTraverse(node.right); + } + //后序遍历 + private String posTraverse(Node node) { + if (node == null) + return ""; + else + return posTraverse(node.left)+" " +posTraverse(node.right)+" "+node.data; + } + + private String preJointComma(String str) { + return str == "" ? "" : "," + str; + } + + public int size() { + return size; + } + + @Override + public String toString() { + return "["+midTraverse(root)+"]"; + } + + private static class Node { + int data; + Node left; + Node right; + + Node(int data) { + this.data = data; + this.left = null; + this.right = null; + } + } +} diff --git a/group15/1521_653895972/basic/Iterator.java b/group15/1521_653895972/basic/Iterator.java new file mode 100644 index 0000000000..5096f85909 --- /dev/null +++ b/group15/1521_653895972/basic/Iterator.java @@ -0,0 +1,7 @@ +package com.oneces.tool.basic; + +public interface Iterator { + public boolean hasNext(); + public Object next(); + +} diff --git a/group15/1521_653895972/basic/LinkedList.java b/group15/1521_653895972/basic/LinkedList.java new file mode 100644 index 0000000000..877b267943 --- /dev/null +++ b/group15/1521_653895972/basic/LinkedList.java @@ -0,0 +1,170 @@ +package com.oneces.tool.basic; + +import java.util.NoSuchElementException; + +/** + * 实现单向链表集合 + */ +public class LinkedList implements List { + + private Node head; + private int size = 0; + + //检查是否越界 利用jdk源码的检测方法 + private boolean isElementIndex(int index) { + return index >= 0 && index < size; + } + + private boolean isPositionIndex(int index) { + return index >= 0 && index <= size; + } + + private String outOfBoundsMsg(int index) { + return "Index: " + index + ", Size: " + size; + } + + private void checkElementIndex(int index) { + if (!isElementIndex(index)) + throw new IndexOutOfBoundsException(outOfBoundsMsg(index)); + } + + private void checkPositionIndex(int index) { + if (!isPositionIndex(index)) + throw new IndexOutOfBoundsException(outOfBoundsMsg(index)); + } + + //获取对应下标的节点 + Node node(int index) { + Node x = head; + for (int i = 0; i < index; i++) + x = x.next; + return x; + } + + public void add(Object o) { + + if (head==null) + head = new Node(o, null); + else { + final Node lastNode = node(size - 1); + final Node newNode = new Node(o, null); + lastNode.next = newNode; + } + size++; + } + + public void add(int index, Object o) { + checkPositionIndex(index); + if (size == index) + add(o); + else { + final Node prevNode = node(index - 1); + final Node nextNode = prevNode.next; + final Node newNode = new Node(o, nextNode); + prevNode.next = newNode; + size++; + } + } + + public Object get(int index) { + return node(index); + } + + public Object remove(int index) { + checkElementIndex(index); + final Node prevNode = node(index - 1); + final Node x = prevNode.next; + if (index-1<0){ + prevNode.next=null; + head=x; + }else { + final Node nextNode = x.next; + prevNode.next = nextNode; + x.next = null; + } + size--; + return x.data; + } + + public int size() { + return size; + } + + public void addFirst(Object o) { + final Node h = head; + final Node newNode = new Node(o, h); + head = newNode; + size++; + } + + public void addLast(Object o) { + add(o); + } + + public Object removeFirst() { + final Node h = head; + if (h == null) + throw new NoSuchElementException(); + final Node newFirst = h.next; + h.next = null; + head = newFirst; + size--; + return h.data; + } + + public Object removeLast() { + final Node prev = node(size - 1-1); + final Node l = prev.next; + prev.next = null; + l.next = null; + size--; + return l.data; + } + + public Iterator iterator() { + return new LinkedItr(); + } + private class LinkedItr implements Iterator{ + int cursor;//游标 + @Override + public boolean hasNext() { + return cursor!=size; + } + + @Override + public Object next() { + int i=cursor; + if (i>size-1)throw new NoSuchElementException(); + Node current = node(i); + if (current==null)throw new IndexOutOfBoundsException(); + cursor=i+1; + return current.data; + } + } + + + private static class Node { + Object data; + Node next; + + Node(Object data, Node next) { + this.data = data; + this.next = next; + } + } + + @Override + public String toString() { + String result = "["; + for (int i = 0; i < size; i++) { + Node n = node(i); + if (i == 0) + result += n.data; + else + result += "," + n.data; + + } + + return result + "]"; + } +} diff --git a/group15/1521_653895972/basic/List.java b/group15/1521_653895972/basic/List.java new file mode 100644 index 0000000000..0d13889fa2 --- /dev/null +++ b/group15/1521_653895972/basic/List.java @@ -0,0 +1,9 @@ +package com.oneces.tool.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/group15/1521_653895972/basic/Queue.java b/group15/1521_653895972/basic/Queue.java new file mode 100644 index 0000000000..657ddb30f4 --- /dev/null +++ b/group15/1521_653895972/basic/Queue.java @@ -0,0 +1,28 @@ +package com.oneces.tool.basic; + +public class Queue { + private LinkedList elementData = new LinkedList(); + + public void enQueue(Object o) { + elementData.add(o); + } + + public Object deQueue() { + return elementData.removeFirst(); + } + + public boolean isEmpty() { + return elementData.size()==0?true:false; + } + + public int size() { + return elementData.size(); + } + + @Override + public String toString() { + return "Queue{" + + "elementData=" + elementData + + '}'; + } +} diff --git a/group15/1521_653895972/basic/Stack.java b/group15/1521_653895972/basic/Stack.java new file mode 100644 index 0000000000..6e41577235 --- /dev/null +++ b/group15/1521_653895972/basic/Stack.java @@ -0,0 +1,33 @@ +package com.oneces.tool.basic; + +public class Stack { + private ArrayList elementData = new ArrayList(); + + public void push(Object o) { + elementData.add(o); + } + + public Object pop() { + elementData.remove(elementData.size()-1); + return null; + } + + public Object peek() { + return elementData.get(elementData.size()-1); + } + + public boolean isEmpty() { + return elementData.size()==0?true:false; + } + + public int size() { + return elementData.size(); + } + + @Override + public String toString() { + return "Stack{" + + "elementData=" + elementData + + '}'; + } +} From dfe7e9719d4db86e963223880c69ddecbed5f08a Mon Sep 17 00:00:00 2001 From: HuiZhou-Xmu <1814014897@qq.com> Date: Thu, 23 Feb 2017 18:10:45 +0800 Subject: [PATCH 056/518] Basic Data Structure Test---Version 1.0 --- .../{ => week01}/BasicDataStructure/ArrayList.java | 2 +- .../BasicDataStructure/BinaryTreeNode.java | 2 +- .../src/{ => week01}/BasicDataStructure/Iterator.java | 2 +- .../{ => week01}/BasicDataStructure/LinkedList.java | 2 +- .../src/{ => week01}/BasicDataStructure/List.java | 2 +- .../src/{ => week01}/BasicDataStructure/Queue.java | 2 +- .../src/{ => week01}/BasicDataStructure/Stack.java | 2 +- .../{ => week01}/BasicDataStructureTest/AllTest.java | 2 +- .../BasicDataStructureTest/ArrayListTest.java | 11 +++++++---- .../BasicDataStructureTest/BinaryTreeNodeTest.java | 9 ++++++--- .../BasicDataStructureTest/LinkedListTest.java | 11 +++++++---- .../BasicDataStructureTest/QueueTest.java | 9 ++++++--- .../BasicDataStructureTest/StackTest.java | 9 ++++++--- 13 files changed, 40 insertions(+), 25 deletions(-) rename group01/1814014897/zhouhui/src/{ => week01}/BasicDataStructure/ArrayList.java (98%) rename group01/1814014897/zhouhui/src/{ => week01}/BasicDataStructure/BinaryTreeNode.java (96%) rename group01/1814014897/zhouhui/src/{ => week01}/BasicDataStructure/Iterator.java (70%) rename group01/1814014897/zhouhui/src/{ => week01}/BasicDataStructure/LinkedList.java (98%) rename group01/1814014897/zhouhui/src/{ => week01}/BasicDataStructure/List.java (83%) rename group01/1814014897/zhouhui/src/{ => week01}/BasicDataStructure/Queue.java (90%) rename group01/1814014897/zhouhui/src/{ => week01}/BasicDataStructure/Stack.java (92%) rename group01/1814014897/zhouhui/src/{ => week01}/BasicDataStructureTest/AllTest.java (88%) rename group01/1814014897/zhouhui/src/{ => week01}/BasicDataStructureTest/ArrayListTest.java (88%) rename group01/1814014897/zhouhui/src/{ => week01}/BasicDataStructureTest/BinaryTreeNodeTest.java (91%) rename group01/1814014897/zhouhui/src/{ => week01}/BasicDataStructureTest/LinkedListTest.java (91%) rename group01/1814014897/zhouhui/src/{ => week01}/BasicDataStructureTest/QueueTest.java (84%) rename group01/1814014897/zhouhui/src/{ => week01}/BasicDataStructureTest/StackTest.java (88%) diff --git a/group01/1814014897/zhouhui/src/BasicDataStructure/ArrayList.java b/group01/1814014897/zhouhui/src/week01/BasicDataStructure/ArrayList.java similarity index 98% rename from group01/1814014897/zhouhui/src/BasicDataStructure/ArrayList.java rename to group01/1814014897/zhouhui/src/week01/BasicDataStructure/ArrayList.java index 3fdea3d732..e33d14ae20 100644 --- a/group01/1814014897/zhouhui/src/BasicDataStructure/ArrayList.java +++ b/group01/1814014897/zhouhui/src/week01/BasicDataStructure/ArrayList.java @@ -1,4 +1,4 @@ -package BasicDataStructure; +package week01.BasicDataStructure; import java.util.Arrays; diff --git a/group01/1814014897/zhouhui/src/BasicDataStructure/BinaryTreeNode.java b/group01/1814014897/zhouhui/src/week01/BasicDataStructure/BinaryTreeNode.java similarity index 96% rename from group01/1814014897/zhouhui/src/BasicDataStructure/BinaryTreeNode.java rename to group01/1814014897/zhouhui/src/week01/BasicDataStructure/BinaryTreeNode.java index b11ca68417..a4fb2cf8b9 100644 --- a/group01/1814014897/zhouhui/src/BasicDataStructure/BinaryTreeNode.java +++ b/group01/1814014897/zhouhui/src/week01/BasicDataStructure/BinaryTreeNode.java @@ -1,4 +1,4 @@ -package BasicDataStructure; +package week01.BasicDataStructure; public class BinaryTreeNode{ diff --git a/group01/1814014897/zhouhui/src/BasicDataStructure/Iterator.java b/group01/1814014897/zhouhui/src/week01/BasicDataStructure/Iterator.java similarity index 70% rename from group01/1814014897/zhouhui/src/BasicDataStructure/Iterator.java rename to group01/1814014897/zhouhui/src/week01/BasicDataStructure/Iterator.java index c70ebb77dd..0ad3fff8f3 100644 --- a/group01/1814014897/zhouhui/src/BasicDataStructure/Iterator.java +++ b/group01/1814014897/zhouhui/src/week01/BasicDataStructure/Iterator.java @@ -1,4 +1,4 @@ -package BasicDataStructure; +package week01.BasicDataStructure; public interface Iterator { public boolean hasNext(); diff --git a/group01/1814014897/zhouhui/src/BasicDataStructure/LinkedList.java b/group01/1814014897/zhouhui/src/week01/BasicDataStructure/LinkedList.java similarity index 98% rename from group01/1814014897/zhouhui/src/BasicDataStructure/LinkedList.java rename to group01/1814014897/zhouhui/src/week01/BasicDataStructure/LinkedList.java index b99e6f15f9..35b1158cd1 100644 --- a/group01/1814014897/zhouhui/src/BasicDataStructure/LinkedList.java +++ b/group01/1814014897/zhouhui/src/week01/BasicDataStructure/LinkedList.java @@ -1,4 +1,4 @@ -package BasicDataStructure; +package week01.BasicDataStructure; public class LinkedList implements List { diff --git a/group01/1814014897/zhouhui/src/BasicDataStructure/List.java b/group01/1814014897/zhouhui/src/week01/BasicDataStructure/List.java similarity index 83% rename from group01/1814014897/zhouhui/src/BasicDataStructure/List.java rename to group01/1814014897/zhouhui/src/week01/BasicDataStructure/List.java index 746612c77e..7806b75ed3 100644 --- a/group01/1814014897/zhouhui/src/BasicDataStructure/List.java +++ b/group01/1814014897/zhouhui/src/week01/BasicDataStructure/List.java @@ -1,4 +1,4 @@ -package BasicDataStructure; +package week01.BasicDataStructure; public interface List { public void add(Object o); diff --git a/group01/1814014897/zhouhui/src/BasicDataStructure/Queue.java b/group01/1814014897/zhouhui/src/week01/BasicDataStructure/Queue.java similarity index 90% rename from group01/1814014897/zhouhui/src/BasicDataStructure/Queue.java rename to group01/1814014897/zhouhui/src/week01/BasicDataStructure/Queue.java index c4fe4c578e..e0ab6bbb9c 100644 --- a/group01/1814014897/zhouhui/src/BasicDataStructure/Queue.java +++ b/group01/1814014897/zhouhui/src/week01/BasicDataStructure/Queue.java @@ -1,4 +1,4 @@ -package BasicDataStructure; +package week01.BasicDataStructure; public class Queue { diff --git a/group01/1814014897/zhouhui/src/BasicDataStructure/Stack.java b/group01/1814014897/zhouhui/src/week01/BasicDataStructure/Stack.java similarity index 92% rename from group01/1814014897/zhouhui/src/BasicDataStructure/Stack.java rename to group01/1814014897/zhouhui/src/week01/BasicDataStructure/Stack.java index c524ee618d..53f99b37c7 100644 --- a/group01/1814014897/zhouhui/src/BasicDataStructure/Stack.java +++ b/group01/1814014897/zhouhui/src/week01/BasicDataStructure/Stack.java @@ -1,4 +1,4 @@ -package BasicDataStructure; +package week01.BasicDataStructure; public class Stack { private ArrayList elementData = new ArrayList(); diff --git a/group01/1814014897/zhouhui/src/BasicDataStructureTest/AllTest.java b/group01/1814014897/zhouhui/src/week01/BasicDataStructureTest/AllTest.java similarity index 88% rename from group01/1814014897/zhouhui/src/BasicDataStructureTest/AllTest.java rename to group01/1814014897/zhouhui/src/week01/BasicDataStructureTest/AllTest.java index ff09c3e4bd..5d5f07d815 100644 --- a/group01/1814014897/zhouhui/src/BasicDataStructureTest/AllTest.java +++ b/group01/1814014897/zhouhui/src/week01/BasicDataStructureTest/AllTest.java @@ -1,4 +1,4 @@ -package BasicDataStructureTest; +package week01.BasicDataStructureTest; import org.junit.runner.RunWith; import org.junit.runners.Suite; diff --git a/group01/1814014897/zhouhui/src/BasicDataStructureTest/ArrayListTest.java b/group01/1814014897/zhouhui/src/week01/BasicDataStructureTest/ArrayListTest.java similarity index 88% rename from group01/1814014897/zhouhui/src/BasicDataStructureTest/ArrayListTest.java rename to group01/1814014897/zhouhui/src/week01/BasicDataStructureTest/ArrayListTest.java index 61cf94a49c..072d53f833 100644 --- a/group01/1814014897/zhouhui/src/BasicDataStructureTest/ArrayListTest.java +++ b/group01/1814014897/zhouhui/src/week01/BasicDataStructureTest/ArrayListTest.java @@ -1,8 +1,11 @@ -package BasicDataStructureTest; +package week01.BasicDataStructureTest; -import org.junit.*; -import BasicDataStructure.ArrayList; -import BasicDataStructure.Iterator; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; + +import week01.BasicDataStructure.ArrayList; +import week01.BasicDataStructure.Iterator; public class ArrayListTest { diff --git a/group01/1814014897/zhouhui/src/BasicDataStructureTest/BinaryTreeNodeTest.java b/group01/1814014897/zhouhui/src/week01/BasicDataStructureTest/BinaryTreeNodeTest.java similarity index 91% rename from group01/1814014897/zhouhui/src/BasicDataStructureTest/BinaryTreeNodeTest.java rename to group01/1814014897/zhouhui/src/week01/BasicDataStructureTest/BinaryTreeNodeTest.java index cf7e899816..724e6c0e03 100644 --- a/group01/1814014897/zhouhui/src/BasicDataStructureTest/BinaryTreeNodeTest.java +++ b/group01/1814014897/zhouhui/src/week01/BasicDataStructureTest/BinaryTreeNodeTest.java @@ -1,7 +1,10 @@ -package BasicDataStructureTest; +package week01.BasicDataStructureTest; -import org.junit.*; -import BasicDataStructure.BinaryTreeNode; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; + +import week01.BasicDataStructure.BinaryTreeNode; public class BinaryTreeNodeTest { diff --git a/group01/1814014897/zhouhui/src/BasicDataStructureTest/LinkedListTest.java b/group01/1814014897/zhouhui/src/week01/BasicDataStructureTest/LinkedListTest.java similarity index 91% rename from group01/1814014897/zhouhui/src/BasicDataStructureTest/LinkedListTest.java rename to group01/1814014897/zhouhui/src/week01/BasicDataStructureTest/LinkedListTest.java index cb0b2e3191..2fb20d12f4 100644 --- a/group01/1814014897/zhouhui/src/BasicDataStructureTest/LinkedListTest.java +++ b/group01/1814014897/zhouhui/src/week01/BasicDataStructureTest/LinkedListTest.java @@ -1,8 +1,11 @@ -package BasicDataStructureTest; +package week01.BasicDataStructureTest; -import org.junit.*; -import BasicDataStructure.Iterator; -import BasicDataStructure.LinkedList; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; + +import week01.BasicDataStructure.Iterator; +import week01.BasicDataStructure.LinkedList; public class LinkedListTest { diff --git a/group01/1814014897/zhouhui/src/BasicDataStructureTest/QueueTest.java b/group01/1814014897/zhouhui/src/week01/BasicDataStructureTest/QueueTest.java similarity index 84% rename from group01/1814014897/zhouhui/src/BasicDataStructureTest/QueueTest.java rename to group01/1814014897/zhouhui/src/week01/BasicDataStructureTest/QueueTest.java index 9af9ca2288..7302b5ec38 100644 --- a/group01/1814014897/zhouhui/src/BasicDataStructureTest/QueueTest.java +++ b/group01/1814014897/zhouhui/src/week01/BasicDataStructureTest/QueueTest.java @@ -1,7 +1,10 @@ -package BasicDataStructureTest; +package week01.BasicDataStructureTest; -import org.junit.*; -import BasicDataStructure.Queue; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; + +import week01.BasicDataStructure.Queue; public class QueueTest { diff --git a/group01/1814014897/zhouhui/src/BasicDataStructureTest/StackTest.java b/group01/1814014897/zhouhui/src/week01/BasicDataStructureTest/StackTest.java similarity index 88% rename from group01/1814014897/zhouhui/src/BasicDataStructureTest/StackTest.java rename to group01/1814014897/zhouhui/src/week01/BasicDataStructureTest/StackTest.java index 9f9c930600..b8fb964955 100644 --- a/group01/1814014897/zhouhui/src/BasicDataStructureTest/StackTest.java +++ b/group01/1814014897/zhouhui/src/week01/BasicDataStructureTest/StackTest.java @@ -1,7 +1,10 @@ -package BasicDataStructureTest; +package week01.BasicDataStructureTest; -import org.junit.*; -import BasicDataStructure.Stack; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; + +import week01.BasicDataStructure.Stack; public class StackTest { From 0847c96068b57e30f2e62c8462c789ca17d6a24b Mon Sep 17 00:00:00 2001 From: wa122as Date: Thu, 23 Feb 2017 18:18:11 +0800 Subject: [PATCH 057/518] =?UTF-8?q?=E5=9F=BA=E6=9C=AC=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E7=BB=93=E6=9E=84=E4=BD=9C=E4=B8=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- group15/1521_653895972/basic/ArrayList.java | 81 --------- group15/1521_653895972/basic/BasicTest.java | 150 ---------------- .../1521_653895972/basic/BinaryTreeNode.java | 85 --------- group15/1521_653895972/basic/Iterator.java | 7 - group15/1521_653895972/basic/LinkedList.java | 170 ------------------ group15/1521_653895972/basic/List.java | 9 - group15/1521_653895972/basic/Queue.java | 28 --- group15/1521_653895972/basic/Stack.java | 33 ---- 8 files changed, 563 deletions(-) delete mode 100644 group15/1521_653895972/basic/ArrayList.java delete mode 100644 group15/1521_653895972/basic/BasicTest.java delete mode 100644 group15/1521_653895972/basic/BinaryTreeNode.java delete mode 100644 group15/1521_653895972/basic/Iterator.java delete mode 100644 group15/1521_653895972/basic/LinkedList.java delete mode 100644 group15/1521_653895972/basic/List.java delete mode 100644 group15/1521_653895972/basic/Queue.java delete mode 100644 group15/1521_653895972/basic/Stack.java diff --git a/group15/1521_653895972/basic/ArrayList.java b/group15/1521_653895972/basic/ArrayList.java deleted file mode 100644 index 7b2d1cef5e..0000000000 --- a/group15/1521_653895972/basic/ArrayList.java +++ /dev/null @@ -1,81 +0,0 @@ -package com.oneces.tool.basic; - -import java.util.Arrays; -import java.util.NoSuchElementException; - -public class ArrayList implements List { - //实例化空数组 不用每次都new - private static final Object[] Empty_elementData = {}; - private int size = 0; - - private Object[] elementData = new Object[100]; - - public ArrayList() { - this.elementData = Empty_elementData; - } - //检查是否越界 - private void checkLenght(int index){ - if (index - size > 0) - throw new IndexOutOfBoundsException(); - } - //增加数组容量 - private void kuorong(){ - elementData = Arrays.copyOf(elementData, size + 1); - } - public void add(Object o) { - kuorong(); - elementData[size++] = o; - } - - public void add(int index, Object o) { - kuorong(); - System.arraycopy(elementData, index, elementData, index + 1, size - index); - elementData[index] = o; - size++; - } - - public Object get(int index) { - checkLenght(index); - return elementData[index]; - } - - public Object remove(int index) { - checkLenght(index); - Object element =elementData[index]; - int movesize=size-index-1; - System.arraycopy(elementData,index+1,elementData,index,movesize); - elementData[--size]=null; - return element; - } - - public int size() { - return size; - } - - public Iterator iterator() { - return new ArrayItr(); - } - private class ArrayItr implements Iterator{ - int cursor;//游标 - @Override - public boolean hasNext() { - return cursor!=size; - } - - @Override - public Object next() { - int i=cursor; - if (i>size)throw new NoSuchElementException(); - Object [] newElementData = ArrayList.this.elementData; - if (i>newElementData.length)throw new IndexOutOfBoundsException(); - cursor=i+1; - return newElementData[i]; - } - } - - @Override - public String toString() { - Object[] s = Arrays.copyOf(elementData,size); - return Arrays.toString(s); - } -} diff --git a/group15/1521_653895972/basic/BasicTest.java b/group15/1521_653895972/basic/BasicTest.java deleted file mode 100644 index 3f3567169a..0000000000 --- a/group15/1521_653895972/basic/BasicTest.java +++ /dev/null @@ -1,150 +0,0 @@ -package com.oneces.tool.basic; - -import org.junit.Assert; -import org.junit.Test; - -/** - * Created by wanc on 2017/2/21. - */ -public class BasicTest { - - @Test - public void test() { - //测试 -// testArrayList(); -// testLinkedList(); -// testBinaryTreeNode(); -// testStack(); - testQueue(); - } - - - public void testQueue(){ - Queue queue = new Queue(); - queue.enQueue("S"); - queue.enQueue("Y"); - queue.enQueue(5); - System.out.println(queue); - System.out.println("queue.size()="+queue.size()); - System.out.println("queue.deQueue()="+queue.deQueue()); - System.out.println(queue); - System.out.println("queue.isEmpty()="+queue.isEmpty()); - System.out.println(queue); - } - public void testStack(){ - Stack stack = new Stack(); - stack.push("S"); - stack.push("Y"); - stack.push(5); - System.out.println("stack.size()="+stack.size()); - System.out.println("stack.peek()="+stack.peek()); - System.out.println(stack); - System.out.println("stack.isEmpty()="+stack.isEmpty()); - stack.pop(); - System.out.println(stack); - } - public void testBinaryTreeNode(){ - System.out.println("-------------------BinaryTreeNode 测试开始-------------------"); - System.out.println("new 一个实例"); - BinaryTreeNode root = new BinaryTreeNode(); - root.insert(5); - root.insert(6); - root.insert(9); - root.insert(3); - root.insert(3); - root.insert(2); - root.insert(10); - System.out.println(root); - System.out.println("-------------------LinkedList 测试结束-------------------"); - } - public void testLinkedList() { - System.out.println("-------------------LinkedList 测试开始-------------------"); - System.out.println("new 一个实例"); - LinkedList list = new LinkedList(); - System.out.println("1.add(\"A\") 添加元素----A"); - list.add("A"); - System.out.println("结果:"+list); - System.out.println(); - System.out.println("2.add(\"B\") 添加元素----B"); - list.add("B"); - System.out.println("结果:"+list); - System.out.println(); - System.out.println("3.add(3) 添加元素----3"); - list.add(3); - System.out.println("结果:"+list); - System.out.println(); - System.out.println("4.add(1, 3) 在下标1插入元素----3"); - list.add(1, 3); - System.out.println("结果:"+list); - System.out.println(); - System.out.println("5.add(3, 6) 在下标3插入元素----6"); - list.add(3, 6); - System.out.println("结果:"+list); - System.out.println(); - System.out.println("6.remove(0) 删除下标0元素"); - list.remove(0); - System.out.println("结果:"+list); - System.out.println(); - System.out.println("7.size() 获取size"); - System.out.println("结果:"+list.size()); - System.out.println(); - System.out.println("8.addFirst(\"F\") 在首位前插入F"); - list.addFirst("F"); - System.out.println("结果:"+list); - System.out.println("9.addLast(\"K\") 在末位前插入K"); - list.addLast("K"); - System.out.println("结果:"+list); - System.out.println("10.removeFirst() 删除首位"); - list.removeFirst(); - System.out.println("结果:"+list); - System.out.println("11.removeLast() 删除末尾"); - list.removeLast(); - System.out.println("结果:"+list); - System.out.println(); - System.out.println("12.迭代器"); - Iterator i = list.iterator(); - while (i.hasNext()){ - System.out.println(i.next()); - } - System.out.println("-------------------LinkedList 测试结束-------------------"); - } - public void testArrayList() { - System.out.println("-------------------ArrayList 测试开始-------------------"); - System.out.println("new 一个实例"); - ArrayList list = new ArrayList(); - System.out.println("1.添加元素----A"); - list.add("A"); - Assert.assertEquals(list.get(0),"A"); - System.out.println("结果:"+list); - System.out.println(); - System.out.println("2.添加元素----B"); - list.add("B"); - System.out.println("结果:"+list); - System.out.println(); - System.out.println("3.添加元素----3"); - list.add(3); - System.out.println("结果:"+list); - System.out.println(); - System.out.println("4.在下标1插入元素----3"); - list.add(1, 3); - System.out.println("结果:"+list); - System.out.println(); - System.out.println("5.在下标3插入元素----6"); - list.add(3, 6); - System.out.println("结果:"+list); - System.out.println(); - System.out.println("6.删除下标0元素"); - list.remove(0); - System.out.println("结果:"+list); - System.out.println(); - System.out.println("7.获取size"); - System.out.println("结果:"+list.size()); - System.out.println(); - System.out.println("8.迭代器"); - Iterator i = list.iterator(); - while (i.hasNext()){ - System.out.println(i.next()); - } - System.out.println("-------------------ArrayList 测试结束-------------------"); - } -} diff --git a/group15/1521_653895972/basic/BinaryTreeNode.java b/group15/1521_653895972/basic/BinaryTreeNode.java deleted file mode 100644 index 2e4fcae8dc..0000000000 --- a/group15/1521_653895972/basic/BinaryTreeNode.java +++ /dev/null @@ -1,85 +0,0 @@ -package com.oneces.tool.basic; - -/** - * 实现二叉树 - * left总比父节点小 - * right总比父节点大 - */ -public class BinaryTreeNode { - private Node root; - private int size = 0; - - public void insert(int data) { - final Node newNode = new Node(data); - if (root == null) { - root = newNode; - } else { - Node current = root; - while (true) { - Node parent = current; - if (data < current.data) {//left - current = current.left; - if (current == null) { - parent.left = newNode; - return; - } - } else {//right - current = current.right; - if (current == null) { - parent.right = newNode; - return; - } - } - } - } - size++; - } - - - //先序遍历 - private String preTraverse(Node node) { - if (node == null) - return ""; - else - return node.data + preJointComma(preTraverse(node.left)) + preJointComma(preTraverse(node.right)); - } - //中序遍历 - private String midTraverse(Node node) { - if (node == null) - return ""; - else - return midTraverse(node.left)+" "+node.data+" " +midTraverse(node.right); - } - //后序遍历 - private String posTraverse(Node node) { - if (node == null) - return ""; - else - return posTraverse(node.left)+" " +posTraverse(node.right)+" "+node.data; - } - - private String preJointComma(String str) { - return str == "" ? "" : "," + str; - } - - public int size() { - return size; - } - - @Override - public String toString() { - return "["+midTraverse(root)+"]"; - } - - private static class Node { - int data; - Node left; - Node right; - - Node(int data) { - this.data = data; - this.left = null; - this.right = null; - } - } -} diff --git a/group15/1521_653895972/basic/Iterator.java b/group15/1521_653895972/basic/Iterator.java deleted file mode 100644 index 5096f85909..0000000000 --- a/group15/1521_653895972/basic/Iterator.java +++ /dev/null @@ -1,7 +0,0 @@ -package com.oneces.tool.basic; - -public interface Iterator { - public boolean hasNext(); - public Object next(); - -} diff --git a/group15/1521_653895972/basic/LinkedList.java b/group15/1521_653895972/basic/LinkedList.java deleted file mode 100644 index 877b267943..0000000000 --- a/group15/1521_653895972/basic/LinkedList.java +++ /dev/null @@ -1,170 +0,0 @@ -package com.oneces.tool.basic; - -import java.util.NoSuchElementException; - -/** - * 实现单向链表集合 - */ -public class LinkedList implements List { - - private Node head; - private int size = 0; - - //检查是否越界 利用jdk源码的检测方法 - private boolean isElementIndex(int index) { - return index >= 0 && index < size; - } - - private boolean isPositionIndex(int index) { - return index >= 0 && index <= size; - } - - private String outOfBoundsMsg(int index) { - return "Index: " + index + ", Size: " + size; - } - - private void checkElementIndex(int index) { - if (!isElementIndex(index)) - throw new IndexOutOfBoundsException(outOfBoundsMsg(index)); - } - - private void checkPositionIndex(int index) { - if (!isPositionIndex(index)) - throw new IndexOutOfBoundsException(outOfBoundsMsg(index)); - } - - //获取对应下标的节点 - Node node(int index) { - Node x = head; - for (int i = 0; i < index; i++) - x = x.next; - return x; - } - - public void add(Object o) { - - if (head==null) - head = new Node(o, null); - else { - final Node lastNode = node(size - 1); - final Node newNode = new Node(o, null); - lastNode.next = newNode; - } - size++; - } - - public void add(int index, Object o) { - checkPositionIndex(index); - if (size == index) - add(o); - else { - final Node prevNode = node(index - 1); - final Node nextNode = prevNode.next; - final Node newNode = new Node(o, nextNode); - prevNode.next = newNode; - size++; - } - } - - public Object get(int index) { - return node(index); - } - - public Object remove(int index) { - checkElementIndex(index); - final Node prevNode = node(index - 1); - final Node x = prevNode.next; - if (index-1<0){ - prevNode.next=null; - head=x; - }else { - final Node nextNode = x.next; - prevNode.next = nextNode; - x.next = null; - } - size--; - return x.data; - } - - public int size() { - return size; - } - - public void addFirst(Object o) { - final Node h = head; - final Node newNode = new Node(o, h); - head = newNode; - size++; - } - - public void addLast(Object o) { - add(o); - } - - public Object removeFirst() { - final Node h = head; - if (h == null) - throw new NoSuchElementException(); - final Node newFirst = h.next; - h.next = null; - head = newFirst; - size--; - return h.data; - } - - public Object removeLast() { - final Node prev = node(size - 1-1); - final Node l = prev.next; - prev.next = null; - l.next = null; - size--; - return l.data; - } - - public Iterator iterator() { - return new LinkedItr(); - } - private class LinkedItr implements Iterator{ - int cursor;//游标 - @Override - public boolean hasNext() { - return cursor!=size; - } - - @Override - public Object next() { - int i=cursor; - if (i>size-1)throw new NoSuchElementException(); - Node current = node(i); - if (current==null)throw new IndexOutOfBoundsException(); - cursor=i+1; - return current.data; - } - } - - - private static class Node { - Object data; - Node next; - - Node(Object data, Node next) { - this.data = data; - this.next = next; - } - } - - @Override - public String toString() { - String result = "["; - for (int i = 0; i < size; i++) { - Node n = node(i); - if (i == 0) - result += n.data; - else - result += "," + n.data; - - } - - return result + "]"; - } -} diff --git a/group15/1521_653895972/basic/List.java b/group15/1521_653895972/basic/List.java deleted file mode 100644 index 0d13889fa2..0000000000 --- a/group15/1521_653895972/basic/List.java +++ /dev/null @@ -1,9 +0,0 @@ -package com.oneces.tool.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/group15/1521_653895972/basic/Queue.java b/group15/1521_653895972/basic/Queue.java deleted file mode 100644 index 657ddb30f4..0000000000 --- a/group15/1521_653895972/basic/Queue.java +++ /dev/null @@ -1,28 +0,0 @@ -package com.oneces.tool.basic; - -public class Queue { - private LinkedList elementData = new LinkedList(); - - public void enQueue(Object o) { - elementData.add(o); - } - - public Object deQueue() { - return elementData.removeFirst(); - } - - public boolean isEmpty() { - return elementData.size()==0?true:false; - } - - public int size() { - return elementData.size(); - } - - @Override - public String toString() { - return "Queue{" + - "elementData=" + elementData + - '}'; - } -} diff --git a/group15/1521_653895972/basic/Stack.java b/group15/1521_653895972/basic/Stack.java deleted file mode 100644 index 6e41577235..0000000000 --- a/group15/1521_653895972/basic/Stack.java +++ /dev/null @@ -1,33 +0,0 @@ -package com.oneces.tool.basic; - -public class Stack { - private ArrayList elementData = new ArrayList(); - - public void push(Object o) { - elementData.add(o); - } - - public Object pop() { - elementData.remove(elementData.size()-1); - return null; - } - - public Object peek() { - return elementData.get(elementData.size()-1); - } - - public boolean isEmpty() { - return elementData.size()==0?true:false; - } - - public int size() { - return elementData.size(); - } - - @Override - public String toString() { - return "Stack{" + - "elementData=" + elementData + - '}'; - } -} From 8835e6e740cf26f0e19fd2c2999e0d45a52d8d38 Mon Sep 17 00:00:00 2001 From: shane Date: Thu, 23 Feb 2017 18:21:50 +0800 Subject: [PATCH 058/518] update .gitignore, add *.iml and *.idea format --- .gitignore | 3 +++ group16/214074094/src/com/reading/blog_test.txt | 1 + 2 files changed, 4 insertions(+) create mode 100644 group16/214074094/src/com/reading/blog_test.txt diff --git a/.gitignore b/.gitignore index ec55baf87d..359bdf7ae5 100644 --- a/.gitignore +++ b/.gitignore @@ -8,6 +8,9 @@ *.war *.ear +*.iml +*.idea + # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml hs_err_pid* diff --git a/group16/214074094/src/com/reading/blog_test.txt b/group16/214074094/src/com/reading/blog_test.txt new file mode 100644 index 0000000000..b7e5cbfe14 --- /dev/null +++ b/group16/214074094/src/com/reading/blog_test.txt @@ -0,0 +1 @@ +just test new fork \ No newline at end of file From f3f4984007781bd25d41e53a1fdf1329434aabfd Mon Sep 17 00:00:00 2001 From: Administrator Date: Thu, 23 Feb 2017 18:22:54 +0800 Subject: [PATCH 059/518] =?UTF-8?q?=E7=AC=AC=E4=B8=80=E5=91=A8=E4=BD=9C?= =?UTF-8?q?=E4=B8=9A=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../FelixCJF/coding2017/basic/ArrayList.java | 97 ++++++++ .../coding2017/basic/BinaryTreeNode.java | 32 +++ .../FelixCJF/coding2017/basic/Iterator.java | 8 + .../FelixCJF/coding2017/basic/LinkedList.java | 214 ++++++++++++++++++ .../FelixCJF/coding2017/basic/List.java | 11 + .../FelixCJF/coding2017/basic/Queue.java | 53 +++++ .../FelixCJF/coding2017/basic/Stack.java | 36 +++ .../coding2017/basic/test/ArrayListTest.java | 14 ++ .../coding2017/basic/test/LinkedListTest.java | 97 ++++++++ .../coding2017/basic/test/ListTest.java | 118 ++++++++++ .../coding2017/basic/test/QueueTest.java | 34 +++ .../coding2017/basic/test/StackTest.java | 41 ++++ 12 files changed, 755 insertions(+) create mode 100644 group02/1554421063/src/com/github/FelixCJF/coding2017/basic/ArrayList.java create mode 100644 group02/1554421063/src/com/github/FelixCJF/coding2017/basic/BinaryTreeNode.java create mode 100644 group02/1554421063/src/com/github/FelixCJF/coding2017/basic/Iterator.java create mode 100644 group02/1554421063/src/com/github/FelixCJF/coding2017/basic/LinkedList.java create mode 100644 group02/1554421063/src/com/github/FelixCJF/coding2017/basic/List.java create mode 100644 group02/1554421063/src/com/github/FelixCJF/coding2017/basic/Queue.java create mode 100644 group02/1554421063/src/com/github/FelixCJF/coding2017/basic/Stack.java create mode 100644 group02/1554421063/src/com/github/FelixCJF/coding2017/basic/test/ArrayListTest.java create mode 100644 group02/1554421063/src/com/github/FelixCJF/coding2017/basic/test/LinkedListTest.java create mode 100644 group02/1554421063/src/com/github/FelixCJF/coding2017/basic/test/ListTest.java create mode 100644 group02/1554421063/src/com/github/FelixCJF/coding2017/basic/test/QueueTest.java create mode 100644 group02/1554421063/src/com/github/FelixCJF/coding2017/basic/test/StackTest.java diff --git a/group02/1554421063/src/com/github/FelixCJF/coding2017/basic/ArrayList.java b/group02/1554421063/src/com/github/FelixCJF/coding2017/basic/ArrayList.java new file mode 100644 index 0000000000..e287d1779a --- /dev/null +++ b/group02/1554421063/src/com/github/FelixCJF/coding2017/basic/ArrayList.java @@ -0,0 +1,97 @@ +package com.github.FelixCJF.coding2017.basic; + +import java.util.Arrays; + +public class ArrayList implements List { + + private int size = 0; + + private Object[] elementData = new Object[100]; + + public void add(Object o){ + //容量增加 + ensureCapacity(size + 1); + //添加 + elementData[size++] = o; + } + + public void add(int index, Object o){ + //容量增加 + ensureCapacity(size + 1); + //临时变量 + Object[] elementData3 = new Object[size + 1]; + //将index前数据复制 + for (int i = 0; i < index + 1 ; i++) { + elementData3[i] = elementData[i]; + } + //插入的数据 + elementData3 [index + 1] = o; + //插入数据之后的后半段复制 + for (int i = index + 2 ; i < elementData3.length; i++) { + elementData3[i] = elementData[i-1]; + } + elementData = elementData3; + size++; + } + + public Object get(int index){ + if (index < 0 || index >= this.size) { + throw new IndexOutOfBoundsException(); + } + return elementData[index]; + } + + public Object remove(int index){ + if (index < 0 || index >= this.size) { + throw new IndexOutOfBoundsException(); + } + Object oldValue = elementData[index]; + Object[] elementData4 = new Object[size - 1]; + for (int i = 0; i < index; i++) { + elementData4[i] = elementData[i]; + } + for (int i = index; i < elementData4.length; i++) { + elementData4[i] = elementData[i + 1]; + } + elementData = elementData4; + size--; + return oldValue; + } + + public int size(){ + return size; + } + + public Iterator iterator(){ + return new ArrayListIterator(); + } + + //内部类,实现Iterator + private class ArrayListIterator implements Iterator{ + + private int currentIndex = 0; //当前索引 + + public boolean hasNext() { + if (currentIndex >= size) { + return false; + } + return true; + } + + public Object next() { + Object object = elementData[currentIndex]; + currentIndex ++ ; + return object; + } + } + public void ensureCapacity(int minCapacity) { + int oldCapacity = elementData.length; + if (minCapacity > oldCapacity) { + int newCapacity = (oldCapacity * 3) / 2 + 1; + if (newCapacity < minCapacity) + newCapacity = minCapacity; + elementData = Arrays.copyOf(elementData, newCapacity); + } + } + +} diff --git a/group02/1554421063/src/com/github/FelixCJF/coding2017/basic/BinaryTreeNode.java b/group02/1554421063/src/com/github/FelixCJF/coding2017/basic/BinaryTreeNode.java new file mode 100644 index 0000000000..6dccc25dcb --- /dev/null +++ b/group02/1554421063/src/com/github/FelixCJF/coding2017/basic/BinaryTreeNode.java @@ -0,0 +1,32 @@ +package com.github.FelixCJF.coding2017.basic; + +public class BinaryTreeNode { + + private Object data; + private BinaryTreeNode left; + private BinaryTreeNode right; + + public Object getData() { + return data; + } + public void setData(Object data) { + this.data = data; + } + public BinaryTreeNode getLeft() { + return left; + } + public void setLeft(BinaryTreeNode left) { + this.left = left; + } + public BinaryTreeNode getRight() { + return right; + } + public void setRight(BinaryTreeNode right) { + this.right = right; + } + + public BinaryTreeNode insert(Object o){ + return null; + } + +} \ No newline at end of file diff --git a/group02/1554421063/src/com/github/FelixCJF/coding2017/basic/Iterator.java b/group02/1554421063/src/com/github/FelixCJF/coding2017/basic/Iterator.java new file mode 100644 index 0000000000..3a1b9abf8c --- /dev/null +++ b/group02/1554421063/src/com/github/FelixCJF/coding2017/basic/Iterator.java @@ -0,0 +1,8 @@ +package com.github.FelixCJF.coding2017.basic; + +public interface Iterator { + + public boolean hasNext(); + public Object next(); + +} diff --git a/group02/1554421063/src/com/github/FelixCJF/coding2017/basic/LinkedList.java b/group02/1554421063/src/com/github/FelixCJF/coding2017/basic/LinkedList.java new file mode 100644 index 0000000000..d86e970b8a --- /dev/null +++ b/group02/1554421063/src/com/github/FelixCJF/coding2017/basic/LinkedList.java @@ -0,0 +1,214 @@ +package com.github.FelixCJF.coding2017.basic; + +import java.util.NoSuchElementException; + +public class LinkedList implements List { + + private Node head;//头指针 + private Node last;//尾指针 + private int size = 0; + + public void add(Object o){ + addLast(o); + } + + public void add(int index , Object o){ + //检查是否越界 + checkIndex(index); + + Node indexNode = node(index); + + if (index == size) { + addLast(o); + } else { + final Node pred = indexNode.prv; + + final Node newNode = new Node(); + newNode.data = o; + newNode.next = indexNode; + newNode.prv = pred; + + indexNode.prv = newNode; + + if (pred == null) { + head = newNode; + } else { + pred.next = newNode; + } + } + size ++; + } + public Object get(int index){ + //检查是否越界 + checkIndex(index); + + Node indexNode = node(index); + + return indexNode.data; + } + public Object remove(int index){ + //检查是否越界 + checkIndex(index); + + Node indexNode = node(index); + Object element = indexNode.data; + Node pre = indexNode.prv; + Node next = indexNode.next; + + if (pre == null) { + head = next; + } else { + pre.next = next; + indexNode.prv = null; + } + + if (next == null) { + last = pre; + } else { + next.prv = pre; + indexNode.next = null; + } + + indexNode.data = null; + + size --; + + return element; + } + + public int size(){ + return size; + } + + public void addFirst(Object o){ + //节点变量存放原来的头指针 + final Node oldHead = head; + //创建新的节点对象 + final Node newNode = new Node(); + newNode.data = o; + newNode.next = head; + newNode.prv = null; + //判断oldhead是否为null + if (oldHead == null) { + last = newNode; + }else { + //头指针指向新创建的节点对象 + oldHead.prv = newNode; + } + //将newNode变为头指针 + head = newNode; + size ++; + } + public void addLast(Object o){ + //节点新变量放原先的尾指针 + final Node oldLast = last; + //创建新节点,加入要添加的对象 + final Node newNode = new Node(); + newNode.data = o; + newNode.next = null; + newNode.prv = oldLast; + if (oldLast == null) { + head = newNode; + } else { + //尾指针指向新创建的节点 + oldLast.next = newNode; + } + //newNode变为尾指针 + last = newNode; + size++; + } + public Object removeFirst(){ + //通过头指针创建头节点 + final Node hNode = head; + if (hNode == null) { + throw new NoSuchElementException(); + } + final Node next = hNode.next; + final Object element = hNode.data; + + //移除 + hNode.data = null; + hNode.next = null; + head = next; + //判断是否为尾节点 + if (next == null) { + last = null; + }else { + next.prv = null; + } + size --; + return element; + } + public Object removeLast(){ + //通过尾指针创建节点 + final Node lastNode = last; + if (lastNode == null) { + throw new NoSuchElementException(); + } + final Object element = lastNode.data; + final Node prve = lastNode.prv; + + //移除 + lastNode.data = null; + lastNode.prv = null; + last = prve; + + if (prve == null) { + head = null; + } else { + prve.next = null; + } + size --; + return element; + } + public Iterator iterator(){ + return new LinkedListIterator(); + } + + private class LinkedListIterator implements Iterator{ + + private Node currentNode = head;//当前节点 + + public boolean hasNext() { + if (currentNode == null) { + return false; + } + return true; + } + + public Object next() { + Object element = currentNode.data; + currentNode = currentNode.next; + return element; + } + + } + + //查找index节点,并返回该节点 + Node node(int index) { + // assert isElementIndex(index); + + if (index < (size >> 1)) { + Node x = head; + for (int i = 0; i < index; i++) + x = x.next; + return x; + } else { + Node x = last; + for (int i = size - 1; i > index; i--) + x = x.prv; + return x; + } + } + //检查索引 + private void checkIndex(int index){ + if (index < 0 || index > size) { + throw new IndexOutOfBoundsException(); + } + } + private static class Node{ + Object data; + Node next; + Node prv; + } +} \ No newline at end of file diff --git a/group02/1554421063/src/com/github/FelixCJF/coding2017/basic/List.java b/group02/1554421063/src/com/github/FelixCJF/coding2017/basic/List.java new file mode 100644 index 0000000000..ecbb657597 --- /dev/null +++ b/group02/1554421063/src/com/github/FelixCJF/coding2017/basic/List.java @@ -0,0 +1,11 @@ +package com.github.FelixCJF.coding2017.basic; + + +public interface List { + public void add(Object o); + public void add(int index, Object o); + public Object get(int index); + public Object remove(int index); + public int size(); + public Iterator iterator(); +} \ No newline at end of file diff --git a/group02/1554421063/src/com/github/FelixCJF/coding2017/basic/Queue.java b/group02/1554421063/src/com/github/FelixCJF/coding2017/basic/Queue.java new file mode 100644 index 0000000000..c2661ce35f --- /dev/null +++ b/group02/1554421063/src/com/github/FelixCJF/coding2017/basic/Queue.java @@ -0,0 +1,53 @@ +package com.github.FelixCJF.coding2017.basic; + + +public class Queue { + + private Node head;//头节点 + private Node last;//尾节点 + private int size;//记录节点 + + public void enQueue(Object o){ + //设置一个节点变量存放原先的尾节点 + final Node oldLast = last; + //创建一个新的节点 + Node newNode = new Node(); + newNode.data = o; + newNode.next = null; + //添加到队列 + if (isEmpty()) { + head = newNode; + } else { + oldLast.next = newNode; + } + //新节点变为尾节点 + last = newNode; + size ++; + } + + public Object deQueue(){ + + Object object = head.data; + + head = head.next; + + if (isEmpty()) { + last = null; + } + size --; + return object; + } + + public boolean isEmpty(){ + return head == null; + } + + public int size(){ + return size; + } + + private static class Node{ + Object data; + Node next; + } +} \ No newline at end of file diff --git a/group02/1554421063/src/com/github/FelixCJF/coding2017/basic/Stack.java b/group02/1554421063/src/com/github/FelixCJF/coding2017/basic/Stack.java new file mode 100644 index 0000000000..cbb7e0683c --- /dev/null +++ b/group02/1554421063/src/com/github/FelixCJF/coding2017/basic/Stack.java @@ -0,0 +1,36 @@ +package com.github.FelixCJF.coding2017.basic; + +import java.util.EmptyStackException; + +public class Stack { + + //存放栈内元素的容器 + private ArrayList elementData = new ArrayList(); + //记录栈内元素个数 + private int size = 0; + + public void push(Object o){ + elementData.add(o); + size ++; + } + + public Object pop(){ + if (isEmpty()) { + throw new EmptyStackException(); + } + return elementData.remove(size - 1); + } + + public Object peek(){ + if (isEmpty()) { + throw new EmptyStackException(); + } + return elementData.get(size - 1); + } + public boolean isEmpty(){ + return elementData.size() == 0; + } + public int size(){ + return size; + } +} diff --git a/group02/1554421063/src/com/github/FelixCJF/coding2017/basic/test/ArrayListTest.java b/group02/1554421063/src/com/github/FelixCJF/coding2017/basic/test/ArrayListTest.java new file mode 100644 index 0000000000..51f2c1115c --- /dev/null +++ b/group02/1554421063/src/com/github/FelixCJF/coding2017/basic/test/ArrayListTest.java @@ -0,0 +1,14 @@ +package com.github.FelixCJF.coding2017.basic.test; + +import org.junit.Before; + +import com.github.FelixCJF.coding2017.basic.ArrayList; + +public class ArrayListTest extends ListTest { + + @Before + public void setUpArrayList() { + aList = new ArrayList(); + } + +} diff --git a/group02/1554421063/src/com/github/FelixCJF/coding2017/basic/test/LinkedListTest.java b/group02/1554421063/src/com/github/FelixCJF/coding2017/basic/test/LinkedListTest.java new file mode 100644 index 0000000000..b990f0327e --- /dev/null +++ b/group02/1554421063/src/com/github/FelixCJF/coding2017/basic/test/LinkedListTest.java @@ -0,0 +1,97 @@ +package com.github.FelixCJF.coding2017.basic.test; + + + +import static org.junit.Assert.*; + +import org.junit.Before; +import org.junit.Test; + +import com.github.FelixCJF.coding2017.basic.LinkedList; + +public class LinkedListTest extends ListTest{ + + private LinkedList aLinkedList; + + @Before + public void setUpLinkedList() { + aList = new LinkedList(); + aLinkedList = new LinkedList(); + } + + @Test + public void testAddFirst() { + aLinkedList.addFirst(5); + assertEquals(5, aLinkedList.get(0)); + + aLinkedList.addFirst(6); + assertEquals(6, aLinkedList.get(0)); + assertEquals(5, aLinkedList.get(1)); + assertEquals(2, aLinkedList.size()); + } + + @Test + public void testAddLast() { + aLinkedList.addLast("hello"); + assertEquals("hello", aLinkedList.get(0)); + + aLinkedList.addLast("world"); + assertEquals("hello", aLinkedList.get(0)); + assertEquals("world", aLinkedList.get(1)); + assertEquals(2, aLinkedList.size()); + } + + @Test + public void testRemoveFirst() { + aLinkedList.addLast("hello"); + aLinkedList.addLast("world"); + + aLinkedList.removeFirst(); + assertEquals("world", aLinkedList.get(0)); + assertEquals(1, aLinkedList.size()); + + aLinkedList.removeFirst(); + assertEquals(0, aLinkedList.size()); + } + + @Test + public void testRemoveLast() { + aLinkedList.addFirst("world"); + aLinkedList.addFirst("hello"); + + aLinkedList.removeLast(); + assertEquals("hello", aLinkedList.get(0)); + assertEquals(1, aLinkedList.size()); + + aLinkedList.removeLast(); + assertEquals(0, aLinkedList.size()); + } + + @Test + public void testLinkedListFunctional() { + for (int i=1; i<4; i++) { + aLinkedList.add(i); // [1,2,3] + } + aLinkedList.remove(1); // [1,3] + + aLinkedList.add(1, 0); // [1,0,3] + for (int i=4; i<6; i++) { + aLinkedList.addFirst(i); // [5, 4, 1, 0, 3] + } + assertEquals(5, aLinkedList.size()); + assertEquals(5, aLinkedList.get(0)); + assertEquals(1, aLinkedList.get(2)); + assertEquals(0, aLinkedList.get(3)); + + aLinkedList.remove(3); // [5, 4, 1, 3] + assertEquals(3, aLinkedList.get(aLinkedList.size()-1)); + aLinkedList.removeLast(); // [5, 4, 1] + assertEquals(1, aLinkedList.get(aLinkedList.size()-1)); + aLinkedList.removeFirst(); // [4,1] + + assertEquals(4, aLinkedList.get(0)); + assertEquals(1, aLinkedList.get(1)); + assertEquals(2, aLinkedList.size()); + } + +} diff --git a/group02/1554421063/src/com/github/FelixCJF/coding2017/basic/test/ListTest.java b/group02/1554421063/src/com/github/FelixCJF/coding2017/basic/test/ListTest.java new file mode 100644 index 0000000000..d9c52595d1 --- /dev/null +++ b/group02/1554421063/src/com/github/FelixCJF/coding2017/basic/test/ListTest.java @@ -0,0 +1,118 @@ +package com.github.FelixCJF.coding2017.basic.test; + +import static org.junit.Assert.*; + +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.ExpectedException; + +import com.github.FelixCJF.coding2017.basic.Iterator; +import com.github.FelixCJF.coding2017.basic.List; + +public class ListTest { + + + protected static List aList; + + + @Test + public void testFunctional() { + aList.add(1); + aList.add(2); + assertEquals(1, aList.get(0)); + assertEquals(2, aList.get(1)); + + aList.add(3); + aList.add(0, 5); + aList.add(2, 11); + assertEquals(5, aList.get(0)); + assertEquals(11, aList.get(2)); + + aList.add("hi"); + assertEquals("hi", aList.get(5)); + assertEquals(6, aList.size()); + + aList.remove(1); + assertEquals(11, aList.get(1)); + assertEquals(2, aList.get(2)); + + assertEquals(5, aList.size()); + } + + @Test + public void testAdd() { + for (int i=0; i<100; i++) + aList.add(i); + assertEquals(0, aList.get(0)); + assertEquals(99, aList.get(99)); + assertEquals(44, aList.get(44)); + } + + @Test + public void testRemove() { + aList.add(1); + aList.add(2); + aList.add(3); + int u = (Integer)aList.remove(2); + assertEquals(3, u); + assertEquals(2, aList.size()); + + aList.add(1, 5); + u = (Integer)aList.remove(0); + assertEquals(1, u); + assertEquals(5, aList.get(0)); + assertEquals(2, aList.get(1)); + assertEquals(2, aList.size()); + + aList.remove(0); + aList.remove(0); + assertEquals(0, aList.size()); + + + } + + @Test + public void testSize() { + for (int i=0; i<10; i++) + aList.add(i*2); + assertEquals(10, aList.size()); + } + + @Rule + public ExpectedException expectedEx = ExpectedException.none(); + + @Test + public void testException() { + expectedEx.expect(Exception.class); + + aList.remove(1); + aList.add(3); + aList.add(2, 5); + expectedEx.expect(Exception.class); + } + + @Test + public void testIterator() { + Iterator it = aList.iterator(); + assertEquals(false, it.hasNext()); + + aList.add(1); + aList.add(2); + aList.add(3); + + it = aList.iterator(); + assertEquals(true, it.hasNext()); + assertEquals(1, it.next()); + assertEquals(2, it.next()); + assertEquals(3, it.next()); + assertEquals(false, it.hasNext()); + + aList.remove(1); + it = aList.iterator(); + assertEquals(true, it.hasNext()); + assertEquals(1, it.next()); + assertEquals(3, it.next()); + assertEquals(false, it.hasNext()); + } + +} diff --git a/group02/1554421063/src/com/github/FelixCJF/coding2017/basic/test/QueueTest.java b/group02/1554421063/src/com/github/FelixCJF/coding2017/basic/test/QueueTest.java new file mode 100644 index 0000000000..49506c2b35 --- /dev/null +++ b/group02/1554421063/src/com/github/FelixCJF/coding2017/basic/test/QueueTest.java @@ -0,0 +1,34 @@ +package com.github.FelixCJF.coding2017.basic.test; + +import static org.junit.Assert.*; +import org.junit.Before; +import org.junit.Test; + +import com.github.FelixCJF.coding2017.basic.Queue; + +public class QueueTest { + private Queue queue; + + @Before + public void setUpQueue() { + queue = new Queue(); + } + + @Test + public void testQueueFunctional() { + assertEquals(true, queue.isEmpty()); + queue.enQueue(4); + queue.enQueue(2); + assertEquals(2, queue.size()); + assertEquals(false, queue.isEmpty()); + + int i = (Integer)queue.deQueue(); + assertEquals(4, i); + i = (Integer)queue.deQueue(); + assertEquals(2, i); + + assertEquals(0, queue.size()); + assertEquals(true, queue.isEmpty()); + } + +} diff --git a/group02/1554421063/src/com/github/FelixCJF/coding2017/basic/test/StackTest.java b/group02/1554421063/src/com/github/FelixCJF/coding2017/basic/test/StackTest.java new file mode 100644 index 0000000000..6bb53571a5 --- /dev/null +++ b/group02/1554421063/src/com/github/FelixCJF/coding2017/basic/test/StackTest.java @@ -0,0 +1,41 @@ +package com.github.FelixCJF.coding2017.basic.test; + +import static org.junit.Assert.*; + +import org.junit.Before; +import org.junit.Test; + +import com.github.FelixCJF.coding2017.basic.Stack; + + +public class StackTest { + + private Stack stack; + + @Before + public void setUpStack() { + stack = new Stack(); + } + + @Test + public void testStackFunctional() { + assertEquals(true, stack.isEmpty()); + stack.push(4); + stack.push(2); + assertEquals(2, stack.size()); + assertEquals(false, stack.isEmpty()); + + int i = (Integer)stack.pop(); + assertEquals(2, i); + + i = (Integer)stack.peek(); + assertEquals(4, i); + + i = (Integer)stack.pop(); + assertEquals(4, i); + + assertEquals(0, stack.size()); + assertEquals(true, stack.isEmpty()); + } + +} From 6edb4f1a32d42ec54847ba28c2f40cc7312c05c7 Mon Sep 17 00:00:00 2001 From: wa122as Date: Thu, 23 Feb 2017 18:27:20 +0800 Subject: [PATCH 060/518] =?UTF-8?q?=E5=9F=BA=E6=9C=AC=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E7=BB=93=E6=9E=84=E4=BD=9C=E4=B8=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/com/coding/basic/ArrayList.java | 81 +++++++++ .../src/com/coding/basic/BasicTest.java | 150 ++++++++++++++++ .../src/com/coding/basic/BinaryTreeNode.java | 85 +++++++++ .../src/com/coding/basic/Iterator.java | 7 + .../src/com/coding/basic/LinkedList.java | 170 ++++++++++++++++++ .../src/com/coding/basic/List.java | 9 + .../src/com/coding/basic/Queue.java | 28 +++ .../src/com/coding/basic/Stack.java | 33 ++++ 8 files changed, 563 insertions(+) create mode 100644 group15/1521_653895972/src/com/coding/basic/ArrayList.java create mode 100644 group15/1521_653895972/src/com/coding/basic/BasicTest.java create mode 100644 group15/1521_653895972/src/com/coding/basic/BinaryTreeNode.java create mode 100644 group15/1521_653895972/src/com/coding/basic/Iterator.java create mode 100644 group15/1521_653895972/src/com/coding/basic/LinkedList.java create mode 100644 group15/1521_653895972/src/com/coding/basic/List.java create mode 100644 group15/1521_653895972/src/com/coding/basic/Queue.java create mode 100644 group15/1521_653895972/src/com/coding/basic/Stack.java diff --git a/group15/1521_653895972/src/com/coding/basic/ArrayList.java b/group15/1521_653895972/src/com/coding/basic/ArrayList.java new file mode 100644 index 0000000000..61813344dc --- /dev/null +++ b/group15/1521_653895972/src/com/coding/basic/ArrayList.java @@ -0,0 +1,81 @@ +package com.coding.basic; + +import java.util.Arrays; +import java.util.NoSuchElementException; + +public class ArrayList implements List { + //实例化空数组 不用每次都new + private static final Object[] Empty_elementData = {}; + private int size = 0; + + private Object[] elementData = new Object[100]; + + public ArrayList() { + this.elementData = Empty_elementData; + } + //检查是否越界 + private void checkLenght(int index){ + if (index - size > 0) + throw new IndexOutOfBoundsException(); + } + //增加数组容量 + private void kuorong(){ + elementData = Arrays.copyOf(elementData, size + 1); + } + public void add(Object o) { + kuorong(); + elementData[size++] = o; + } + + public void add(int index, Object o) { + kuorong(); + System.arraycopy(elementData, index, elementData, index + 1, size - index); + elementData[index] = o; + size++; + } + + public Object get(int index) { + checkLenght(index); + return elementData[index]; + } + + public Object remove(int index) { + checkLenght(index); + Object element =elementData[index]; + int movesize=size-index-1; + System.arraycopy(elementData,index+1,elementData,index,movesize); + elementData[--size]=null; + return element; + } + + public int size() { + return size; + } + + public Iterator iterator() { + return new ArrayItr(); + } + private class ArrayItr implements Iterator{ + int cursor;//游标 + @Override + public boolean hasNext() { + return cursor!=size; + } + + @Override + public Object next() { + int i=cursor; + if (i>size)throw new NoSuchElementException(); + Object [] newElementData = ArrayList.this.elementData; + if (i>newElementData.length)throw new IndexOutOfBoundsException(); + cursor=i+1; + return newElementData[i]; + } + } + + @Override + public String toString() { + Object[] s = Arrays.copyOf(elementData,size); + return Arrays.toString(s); + } +} diff --git a/group15/1521_653895972/src/com/coding/basic/BasicTest.java b/group15/1521_653895972/src/com/coding/basic/BasicTest.java new file mode 100644 index 0000000000..3add39d66c --- /dev/null +++ b/group15/1521_653895972/src/com/coding/basic/BasicTest.java @@ -0,0 +1,150 @@ +package com.coding.basic; + +import org.junit.Assert; +import org.junit.Test; + +/** + * Created by wanc on 2017/2/21. + */ +public class BasicTest { + + @Test + public void test() { + //测试 +// testArrayList(); +// testLinkedList(); +// testBinaryTreeNode(); +// testStack(); + testQueue(); + } + + + public void testQueue(){ + Queue queue = new Queue(); + queue.enQueue("S"); + queue.enQueue("Y"); + queue.enQueue(5); + System.out.println(queue); + System.out.println("queue.size()="+queue.size()); + System.out.println("queue.deQueue()="+queue.deQueue()); + System.out.println(queue); + System.out.println("queue.isEmpty()="+queue.isEmpty()); + System.out.println(queue); + } + public void testStack(){ + Stack stack = new Stack(); + stack.push("S"); + stack.push("Y"); + stack.push(5); + System.out.println("stack.size()="+stack.size()); + System.out.println("stack.peek()="+stack.peek()); + System.out.println(stack); + System.out.println("stack.isEmpty()="+stack.isEmpty()); + stack.pop(); + System.out.println(stack); + } + public void testBinaryTreeNode(){ + System.out.println("-------------------BinaryTreeNode 测试开始-------------------"); + System.out.println("new 一个实例"); + BinaryTreeNode root = new BinaryTreeNode(); + root.insert(5); + root.insert(6); + root.insert(9); + root.insert(3); + root.insert(3); + root.insert(2); + root.insert(10); + System.out.println(root); + System.out.println("-------------------LinkedList 测试结束-------------------"); + } + public void testLinkedList() { + System.out.println("-------------------LinkedList 测试开始-------------------"); + System.out.println("new 一个实例"); + LinkedList list = new LinkedList(); + System.out.println("1.add(\"A\") 添加元素----A"); + list.add("A"); + System.out.println("结果:"+list); + System.out.println(); + System.out.println("2.add(\"B\") 添加元素----B"); + list.add("B"); + System.out.println("结果:"+list); + System.out.println(); + System.out.println("3.add(3) 添加元素----3"); + list.add(3); + System.out.println("结果:"+list); + System.out.println(); + System.out.println("4.add(1, 3) 在下标1插入元素----3"); + list.add(1, 3); + System.out.println("结果:"+list); + System.out.println(); + System.out.println("5.add(3, 6) 在下标3插入元素----6"); + list.add(3, 6); + System.out.println("结果:"+list); + System.out.println(); + System.out.println("6.remove(0) 删除下标0元素"); + list.remove(0); + System.out.println("结果:"+list); + System.out.println(); + System.out.println("7.size() 获取size"); + System.out.println("结果:"+list.size()); + System.out.println(); + System.out.println("8.addFirst(\"F\") 在首位前插入F"); + list.addFirst("F"); + System.out.println("结果:"+list); + System.out.println("9.addLast(\"K\") 在末位前插入K"); + list.addLast("K"); + System.out.println("结果:"+list); + System.out.println("10.removeFirst() 删除首位"); + list.removeFirst(); + System.out.println("结果:"+list); + System.out.println("11.removeLast() 删除末尾"); + list.removeLast(); + System.out.println("结果:"+list); + System.out.println(); + System.out.println("12.迭代器"); + Iterator i = list.iterator(); + while (i.hasNext()){ + System.out.println(i.next()); + } + System.out.println("-------------------LinkedList 测试结束-------------------"); + } + public void testArrayList() { + System.out.println("-------------------ArrayList 测试开始-------------------"); + System.out.println("new 一个实例"); + ArrayList list = new ArrayList(); + System.out.println("1.添加元素----A"); + list.add("A"); + Assert.assertEquals(list.get(0),"A"); + System.out.println("结果:"+list); + System.out.println(); + System.out.println("2.添加元素----B"); + list.add("B"); + System.out.println("结果:"+list); + System.out.println(); + System.out.println("3.添加元素----3"); + list.add(3); + System.out.println("结果:"+list); + System.out.println(); + System.out.println("4.在下标1插入元素----3"); + list.add(1, 3); + System.out.println("结果:"+list); + System.out.println(); + System.out.println("5.在下标3插入元素----6"); + list.add(3, 6); + System.out.println("结果:"+list); + System.out.println(); + System.out.println("6.删除下标0元素"); + list.remove(0); + System.out.println("结果:"+list); + System.out.println(); + System.out.println("7.获取size"); + System.out.println("结果:"+list.size()); + System.out.println(); + System.out.println("8.迭代器"); + Iterator i = list.iterator(); + while (i.hasNext()){ + System.out.println(i.next()); + } + System.out.println("-------------------ArrayList 测试结束-------------------"); + } +} diff --git a/group15/1521_653895972/src/com/coding/basic/BinaryTreeNode.java b/group15/1521_653895972/src/com/coding/basic/BinaryTreeNode.java new file mode 100644 index 0000000000..82ff8302e7 --- /dev/null +++ b/group15/1521_653895972/src/com/coding/basic/BinaryTreeNode.java @@ -0,0 +1,85 @@ +package com.coding.basic; + +/** + * 实现二叉树 + * left总比父节点小 + * right总比父节点大 + */ +public class BinaryTreeNode { + private Node root; + private int size = 0; + + public void insert(int data) { + final Node newNode = new Node(data); + if (root == null) { + root = newNode; + } else { + Node current = root; + while (true) { + Node parent = current; + if (data < current.data) {//left + current = current.left; + if (current == null) { + parent.left = newNode; + return; + } + } else {//right + current = current.right; + if (current == null) { + parent.right = newNode; + return; + } + } + } + } + size++; + } + + + //先序遍历 + private String preTraverse(Node node) { + if (node == null) + return ""; + else + return node.data + preJointComma(preTraverse(node.left)) + preJointComma(preTraverse(node.right)); + } + //中序遍历 + private String midTraverse(Node node) { + if (node == null) + return ""; + else + return midTraverse(node.left)+" "+node.data+" " +midTraverse(node.right); + } + //后序遍历 + private String posTraverse(Node node) { + if (node == null) + return ""; + else + return posTraverse(node.left)+" " +posTraverse(node.right)+" "+node.data; + } + + private String preJointComma(String str) { + return str == "" ? "" : "," + str; + } + + public int size() { + return size; + } + + @Override + public String toString() { + return "["+midTraverse(root)+"]"; + } + + private static class Node { + int data; + Node left; + Node right; + + Node(int data) { + this.data = data; + this.left = null; + this.right = null; + } + } +} diff --git a/group15/1521_653895972/src/com/coding/basic/Iterator.java b/group15/1521_653895972/src/com/coding/basic/Iterator.java new file mode 100644 index 0000000000..06ef6311b2 --- /dev/null +++ b/group15/1521_653895972/src/com/coding/basic/Iterator.java @@ -0,0 +1,7 @@ +package com.coding.basic; + +public interface Iterator { + public boolean hasNext(); + public Object next(); + +} diff --git a/group15/1521_653895972/src/com/coding/basic/LinkedList.java b/group15/1521_653895972/src/com/coding/basic/LinkedList.java new file mode 100644 index 0000000000..0c2222d969 --- /dev/null +++ b/group15/1521_653895972/src/com/coding/basic/LinkedList.java @@ -0,0 +1,170 @@ +package com.coding.basic; + +import java.util.NoSuchElementException; + +/** + * 实现单向链表集合 + */ +public class LinkedList implements List { + + private Node head; + private int size = 0; + + //检查是否越界 利用jdk源码的检测方法 + private boolean isElementIndex(int index) { + return index >= 0 && index < size; + } + + private boolean isPositionIndex(int index) { + return index >= 0 && index <= size; + } + + private String outOfBoundsMsg(int index) { + return "Index: " + index + ", Size: " + size; + } + + private void checkElementIndex(int index) { + if (!isElementIndex(index)) + throw new IndexOutOfBoundsException(outOfBoundsMsg(index)); + } + + private void checkPositionIndex(int index) { + if (!isPositionIndex(index)) + throw new IndexOutOfBoundsException(outOfBoundsMsg(index)); + } + + //获取对应下标的节点 + Node node(int index) { + Node x = head; + for (int i = 0; i < index; i++) + x = x.next; + return x; + } + + public void add(Object o) { + + if (head==null) + head = new Node(o, null); + else { + final Node lastNode = node(size - 1); + final Node newNode = new Node(o, null); + lastNode.next = newNode; + } + size++; + } + + public void add(int index, Object o) { + checkPositionIndex(index); + if (size == index) + add(o); + else { + final Node prevNode = node(index - 1); + final Node nextNode = prevNode.next; + final Node newNode = new Node(o, nextNode); + prevNode.next = newNode; + size++; + } + } + + public Object get(int index) { + return node(index); + } + + public Object remove(int index) { + checkElementIndex(index); + final Node prevNode = node(index - 1); + final Node x = prevNode.next; + if (index-1<0){ + prevNode.next=null; + head=x; + }else { + final Node nextNode = x.next; + prevNode.next = nextNode; + x.next = null; + } + size--; + return x.data; + } + + public int size() { + return size; + } + + public void addFirst(Object o) { + final Node h = head; + final Node newNode = new Node(o, h); + head = newNode; + size++; + } + + public void addLast(Object o) { + add(o); + } + + public Object removeFirst() { + final Node h = head; + if (h == null) + throw new NoSuchElementException(); + final Node newFirst = h.next; + h.next = null; + head = newFirst; + size--; + return h.data; + } + + public Object removeLast() { + final Node prev = node(size - 1-1); + final Node l = prev.next; + prev.next = null; + l.next = null; + size--; + return l.data; + } + + public Iterator iterator() { + return new LinkedItr(); + } + private class LinkedItr implements Iterator{ + int cursor;//游标 + @Override + public boolean hasNext() { + return cursor!=size; + } + + @Override + public Object next() { + int i=cursor; + if (i>size-1)throw new NoSuchElementException(); + Node current = node(i); + if (current==null)throw new IndexOutOfBoundsException(); + cursor=i+1; + return current.data; + } + } + + + private static class Node { + Object data; + Node next; + + Node(Object data, Node next) { + this.data = data; + this.next = next; + } + } + + @Override + public String toString() { + String result = "["; + for (int i = 0; i < size; i++) { + Node n = node(i); + if (i == 0) + result += n.data; + else + result += "," + n.data; + + } + + return result + "]"; + } +} diff --git a/group15/1521_653895972/src/com/coding/basic/List.java b/group15/1521_653895972/src/com/coding/basic/List.java new file mode 100644 index 0000000000..10d13b5832 --- /dev/null +++ b/group15/1521_653895972/src/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/group15/1521_653895972/src/com/coding/basic/Queue.java b/group15/1521_653895972/src/com/coding/basic/Queue.java new file mode 100644 index 0000000000..8084624da1 --- /dev/null +++ b/group15/1521_653895972/src/com/coding/basic/Queue.java @@ -0,0 +1,28 @@ +package com.coding.basic; + +public class Queue { + private LinkedList elementData = new LinkedList(); + + public void enQueue(Object o) { + elementData.add(o); + } + + public Object deQueue() { + return elementData.removeFirst(); + } + + public boolean isEmpty() { + return elementData.size()==0?true:false; + } + + public int size() { + return elementData.size(); + } + + @Override + public String toString() { + return "Queue{" + + "elementData=" + elementData + + '}'; + } +} diff --git a/group15/1521_653895972/src/com/coding/basic/Stack.java b/group15/1521_653895972/src/com/coding/basic/Stack.java new file mode 100644 index 0000000000..5125abd268 --- /dev/null +++ b/group15/1521_653895972/src/com/coding/basic/Stack.java @@ -0,0 +1,33 @@ +package com.coding.basic; + +public class Stack { + private ArrayList elementData = new ArrayList(); + + public void push(Object o) { + elementData.add(o); + } + + public Object pop() { + elementData.remove(elementData.size()-1); + return null; + } + + public Object peek() { + return elementData.get(elementData.size()-1); + } + + public boolean isEmpty() { + return elementData.size()==0?true:false; + } + + public int size() { + return elementData.size(); + } + + @Override + public String toString() { + return "Stack{" + + "elementData=" + elementData + + '}'; + } +} From 8f629228030607f08b35a6dbef3f45650507e877 Mon Sep 17 00:00:00 2001 From: Alex5Moon <1924332561@qq.com> Date: Thu, 23 Feb 2017 19:28:59 +0800 Subject: [PATCH 061/518] init --- group16/1924332561/.classpath | 6 ++++++ group16/1924332561/.project | 17 +++++++++++++++++ .../src/com/coding/basic/ArrayList.java | 2 ++ .../1924332561/src/com/coding/basic/List.java | 2 +- 4 files changed, 26 insertions(+), 1 deletion(-) create mode 100644 group16/1924332561/.classpath create mode 100644 group16/1924332561/.project diff --git a/group16/1924332561/.classpath b/group16/1924332561/.classpath new file mode 100644 index 0000000000..fb5011632c --- /dev/null +++ b/group16/1924332561/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/group16/1924332561/.project b/group16/1924332561/.project new file mode 100644 index 0000000000..5f960262bc --- /dev/null +++ b/group16/1924332561/.project @@ -0,0 +1,17 @@ + + + 1924332561Learning + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/group16/1924332561/src/com/coding/basic/ArrayList.java b/group16/1924332561/src/com/coding/basic/ArrayList.java index 9e20bf25c4..3fc0960e08 100644 --- a/group16/1924332561/src/com/coding/basic/ArrayList.java +++ b/group16/1924332561/src/com/coding/basic/ArrayList.java @@ -9,6 +9,8 @@ public class ArrayList implements List{ @Override public void add(Object o) { + this.elementDate[this.size]=o; + this.size++; } @Override diff --git a/group16/1924332561/src/com/coding/basic/List.java b/group16/1924332561/src/com/coding/basic/List.java index 9be54168b6..d48b1f4827 100644 --- a/group16/1924332561/src/com/coding/basic/List.java +++ b/group16/1924332561/src/com/coding/basic/List.java @@ -3,7 +3,7 @@ public interface List { public void add(Object o); public void add(int index,Object o); - public Object get(int dex); + public Object get(int index); public Object remove(int index); public int size(); } From e84543236b90a5e60ea9f833f6ae5aec9a737053 Mon Sep 17 00:00:00 2001 From: dongqihust Date: Thu, 23 Feb 2017 19:31:27 +0800 Subject: [PATCH 062/518] =?UTF-8?q?=E8=91=A3=E7=90=AA=E7=81=AB=E9=80=9F?= =?UTF-8?q?=E6=8A=A5=E9=81=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- group16/1325756593/dongqihust.readme | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 group16/1325756593/dongqihust.readme diff --git a/group16/1325756593/dongqihust.readme b/group16/1325756593/dongqihust.readme new file mode 100644 index 0000000000..e69de29bb2 From 99f12ba969aec7a9b4e2a365a850e7cb88cdff8a Mon Sep 17 00:00:00 2001 From: nelson Date: Thu, 23 Feb 2017 20:11:49 +0800 Subject: [PATCH 063/518] first commit of MyDataStructure --- group07/476770768/MyDataStructure/.classpath | 6 + group07/476770768/MyDataStructure/.gitignore | 17 ++ group07/476770768/MyDataStructure/.project | 17 ++ .../.settings/org.eclipse.jdt.core.prefs | 11 + .../src/com/coding/basic/BinaryTreeNode.java | 44 ++++ .../src/com/coding/basic/MyArrayList.java | 149 ++++++++++++ .../src/com/coding/basic/MyIterator.java | 6 + .../src/com/coding/basic/MyLinkedList.java | 223 ++++++++++++++++++ .../src/com/coding/basic/MyList.java | 9 + .../src/com/coding/basic/MyQueue.java | 30 +++ .../src/com/coding/basic/MyStack.java | 44 ++++ .../src/com/coding/basic/testFile.java | 23 ++ 12 files changed, 579 insertions(+) create mode 100644 group07/476770768/MyDataStructure/.classpath create mode 100644 group07/476770768/MyDataStructure/.gitignore create mode 100644 group07/476770768/MyDataStructure/.project create mode 100644 group07/476770768/MyDataStructure/.settings/org.eclipse.jdt.core.prefs create mode 100644 group07/476770768/MyDataStructure/src/com/coding/basic/BinaryTreeNode.java create mode 100644 group07/476770768/MyDataStructure/src/com/coding/basic/MyArrayList.java create mode 100644 group07/476770768/MyDataStructure/src/com/coding/basic/MyIterator.java create mode 100644 group07/476770768/MyDataStructure/src/com/coding/basic/MyLinkedList.java create mode 100644 group07/476770768/MyDataStructure/src/com/coding/basic/MyList.java create mode 100644 group07/476770768/MyDataStructure/src/com/coding/basic/MyQueue.java create mode 100644 group07/476770768/MyDataStructure/src/com/coding/basic/MyStack.java create mode 100644 group07/476770768/MyDataStructure/src/com/coding/basic/testFile.java diff --git a/group07/476770768/MyDataStructure/.classpath b/group07/476770768/MyDataStructure/.classpath new file mode 100644 index 0000000000..63b7e892d1 --- /dev/null +++ b/group07/476770768/MyDataStructure/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/group07/476770768/MyDataStructure/.gitignore b/group07/476770768/MyDataStructure/.gitignore new file mode 100644 index 0000000000..c910559f7f --- /dev/null +++ b/group07/476770768/MyDataStructure/.gitignore @@ -0,0 +1,17 @@ +*.class + +# Mobile Tools for Java (J2ME) +.mtj.tmp/ + +# Package Files # +*.jar +*.war +*.ear + +# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml +hs_err_pid* + +#ide config +.metadata +.recommenders +/bin/ diff --git a/group07/476770768/MyDataStructure/.project b/group07/476770768/MyDataStructure/.project new file mode 100644 index 0000000000..b2d0b8054f --- /dev/null +++ b/group07/476770768/MyDataStructure/.project @@ -0,0 +1,17 @@ + + + MyDataStructure + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/group07/476770768/MyDataStructure/.settings/org.eclipse.jdt.core.prefs b/group07/476770768/MyDataStructure/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000000..bb35fa0a87 --- /dev/null +++ b/group07/476770768/MyDataStructure/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/group07/476770768/MyDataStructure/src/com/coding/basic/BinaryTreeNode.java b/group07/476770768/MyDataStructure/src/com/coding/basic/BinaryTreeNode.java new file mode 100644 index 0000000000..6cc4ecb4df --- /dev/null +++ b/group07/476770768/MyDataStructure/src/com/coding/basic/BinaryTreeNode.java @@ -0,0 +1,44 @@ +package com.coding.basic; + +public class BinaryTreeNode { + private Object data; + private BinaryTreeNode left; + private BinaryTreeNode right; + + public void insert(BinaryTreeNode node) { + if (this.data == null) { + // empty binary tree + this.data = node.data; + this.left = node.left; + this.right = node.right; + } else if (((Integer) this.data).intValue() >= ((Integer) node.data).intValue()) { + this.left.insert(node); + }else{ + this.right.insert(node); + } + } + + 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; + } +} diff --git a/group07/476770768/MyDataStructure/src/com/coding/basic/MyArrayList.java b/group07/476770768/MyDataStructure/src/com/coding/basic/MyArrayList.java new file mode 100644 index 0000000000..f0c1b3608c --- /dev/null +++ b/group07/476770768/MyDataStructure/src/com/coding/basic/MyArrayList.java @@ -0,0 +1,149 @@ +package com.coding.basic; + +import java.util.Arrays; + +public class MyArrayList implements MyList{ + + private int size = 0; + + private Object[] elementData = new Object[5]; + + @Override + /** + * add an element to the end + */ + public void add(Object o) { + int index = size; + if(isFull()){ + extendLength(); + } + elementData[index] = o; + size++; + } + + @Override + /** + * add an element to certain index + */ + public void add(int index, Object o) { + checkBounds(index); + if(isFull()){ + extendLength(); + } + for(int i=size; i>=index; i--){ + elementData[i+1] = elementData[i]; + } + elementData[index] = o; + size++; + } + + @Override + /** + * get an element + */ + public Object get(int index) { + checkBoundsForGet(index); + if(index >= size){ + return null; + } + return elementData[index]; + } + + @Override + /** + * remove an element + */ + public Object remove(int index) { + checkBounds(index); + Object res = elementData[index]; + for(int i=index+1; i<=size; i++){ + elementData[i-1] = elementData[i]; + } + size--; + return res; + } + + @Override + public int size() { + return size; + } + + /** + * extends the length + */ + public void extendLength(){ + elementData = Arrays.copyOf(elementData, elementData.length * 2); + //System.out.println("add extend "+elementData.length); + } + + public boolean isEmpty(){ + return size == 0; + } + + public boolean isFull(){ + int len = elementData.length; + if(size >= len-1){ + return true; + } + return false; + } + + public void checkBounds(int index){ + if(index >= size || index < 0){ + //System.out.println("From MyArrayList: Index out of bounds"); + throw new IndexOutOfBoundsException(OutOfBoundsMsg(index)); + } + } + + /** + * for get() + * @param index + */ + public void checkBoundsForGet(int index){ + if(index >= elementData.length || index < 0){ + //System.out.println("From MyArrayList: Index out of bounds"); + throw new IndexOutOfBoundsException(OutOfBoundsMsg(index)); + } + } + + public String OutOfBoundsMsg(int index){ + return "Index: "+index+", Size: "+size; + } + + @Override + public String toString() { + String s = ""; + for(int i=0; i size - 1) { + // System.out.println("From MyLinkedList: Index out of bounds"); + throw new IndexOutOfBoundsException(OutOfBoundsMsg(index)); + } + } + + /** + * the index should be within 0~size + * + * @param index + */ + public void checkBoundsForAdd(int index) { + if (index < 0 || index > size) { + // System.out.println("From MyLinkedList: Index out of bounds"); + throw new IndexOutOfBoundsException(OutOfBoundsMsg(index)); + } + } + + public String OutOfBoundsMsg(int index) { + return "Index: " + index + ", Size: " + size; + } + + /** + * find the position of index + * + * @param index + * @return + */ + public Node findIndexPosition(int index) { + Node pos = head; + for (int i = 0; i < index; i++) { + pos = pos.next; + } + return pos; + } + + @Override + public String toString() { + String s = ""; + Node tmp = head; + while (tmp != null) { + s += tmp.data + " "; + tmp = tmp.next; + } + return s; + } + + private static class Node { + public Object data; + public Node prov; + public Node next; + + public Node() { + } + + public Node(Object o) { + this.data = o; + this.prov = null; + this.next = null; + } + } + + public MyIterator iterator() { + return new LinkedListIterator(this); + } + + private class LinkedListIterator implements MyIterator{ + + private MyLinkedList eleIterator; + private Node pos; + + private LinkedListIterator(MyLinkedList mll){ + this.eleIterator = mll; + this.pos = eleIterator.get(0); + } + + @Override + public boolean hasNext() { + return pos != null; + } + + @Override + public Object next() { + Node res = pos; + pos = pos.next; + return res; + } + + } + +} diff --git a/group07/476770768/MyDataStructure/src/com/coding/basic/MyList.java b/group07/476770768/MyDataStructure/src/com/coding/basic/MyList.java new file mode 100644 index 0000000000..9089e106db --- /dev/null +++ b/group07/476770768/MyDataStructure/src/com/coding/basic/MyList.java @@ -0,0 +1,9 @@ +package com.coding.basic; + +public interface MyList { + 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/group07/476770768/MyDataStructure/src/com/coding/basic/MyQueue.java b/group07/476770768/MyDataStructure/src/com/coding/basic/MyQueue.java new file mode 100644 index 0000000000..717c67bd4b --- /dev/null +++ b/group07/476770768/MyDataStructure/src/com/coding/basic/MyQueue.java @@ -0,0 +1,30 @@ +package com.coding.basic; + +public class MyQueue { + + private MyLinkedList elementData = new MyLinkedList(); + + public void enQueue(Object o){ + elementData.add(o); + } + + public Object deQueue(){ + //if queue is empty, element.size()-1 = -1 + //MyLinkedList will throw exception + Object tmp = elementData.remove(elementData.size()-1); + return tmp; + } + + public boolean isEmpty(){ + return elementData.isEmpty(); + } + + public int size(){ + return elementData.size(); + } + + public MyIterator iterator() { + return elementData.iterator(); + } + +} diff --git a/group07/476770768/MyDataStructure/src/com/coding/basic/MyStack.java b/group07/476770768/MyDataStructure/src/com/coding/basic/MyStack.java new file mode 100644 index 0000000000..3d9e1ef9a0 --- /dev/null +++ b/group07/476770768/MyDataStructure/src/com/coding/basic/MyStack.java @@ -0,0 +1,44 @@ +package com.coding.basic; + +import java.util.EmptyStackException; + +public class MyStack { + private MyArrayList elementData = new MyArrayList(); + int top = -1;//always points to top element + + public void push(Object o){ + elementData.add(o); + top++; + } + + public Object pop(){ + if(isEmpty()){ + throw new EmptyStackException(); + }else{ + Object tmp = elementData.remove(top); + top--; + return tmp; + } + } + + public Object peek(){ + if(isEmpty()){ + throw new EmptyStackException(); + }else{ + Object tmp = elementData.get(top); + return tmp; + } + } + + public boolean isEmpty(){ + return top >= 0; + } + + public int size(){ + return top + 1; + } + + public MyIterator iterator() { + return elementData.iterator(); + } +} diff --git a/group07/476770768/MyDataStructure/src/com/coding/basic/testFile.java b/group07/476770768/MyDataStructure/src/com/coding/basic/testFile.java new file mode 100644 index 0000000000..1ccabfc977 --- /dev/null +++ b/group07/476770768/MyDataStructure/src/com/coding/basic/testFile.java @@ -0,0 +1,23 @@ +package com.coding.basic; + +public class testFile { + + public static void main(String[] args) { + MyLinkedList mll = new MyLinkedList(); + mll.add(new Integer(5)); + mll.add(new Integer(2)); + mll.add(new Integer(3)); + mll.add(new Integer(4)); + System.out.println(mll); + MyIterator mIt = mll.iterator(); + while(mIt.hasNext()){ + System.out.println(mIt.next()); + } + mll.remove(3); + System.out.println(mll); + + + + } + +} From 2ebcff4546888d40f0495f5cc1c176e724fe4d11 Mon Sep 17 00:00:00 2001 From: JayXu Date: Thu, 23 Feb 2017 21:36:27 +0800 Subject: [PATCH 064/518] xuweijay --- group15/1511_714512544/.idea/misc.xml | 9 - group15/1511_714512544/.idea/uiDesigner.xml | 124 ++++++ group15/1511_714512544/.idea/workspace.xml | 415 ++++++++++++++++-- .../com/coding/basic/BinarySearchTree.java | 106 ++++- .../coding/basic/BinarySearchTreeNode.java | 8 +- .../coding/basic/BinarySearchTreeTest.java | 83 ---- .../coding/basic/BinarySearchTreeTest.java | 202 +++++---- .../src/test/com/coding/basic/StackTest.java | 59 +++ 8 files changed, 777 insertions(+), 229 deletions(-) create mode 100644 group15/1511_714512544/.idea/uiDesigner.xml delete mode 100644 group15/1511_714512544/src/com/coding/basic/BinarySearchTreeTest.java create mode 100644 group15/1511_714512544/src/test/com/coding/basic/StackTest.java diff --git a/group15/1511_714512544/.idea/misc.xml b/group15/1511_714512544/.idea/misc.xml index f45ffd5f26..05483570e0 100644 --- a/group15/1511_714512544/.idea/misc.xml +++ b/group15/1511_714512544/.idea/misc.xml @@ -1,14 +1,5 @@ - - - diff --git a/group15/1511_714512544/.idea/uiDesigner.xml b/group15/1511_714512544/.idea/uiDesigner.xml new file mode 100644 index 0000000000..e96534fb27 --- /dev/null +++ b/group15/1511_714512544/.idea/uiDesigner.xml @@ -0,0 +1,124 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/group15/1511_714512544/.idea/workspace.xml b/group15/1511_714512544/.idea/workspace.xml index 8df02d2252..23a7acce91 100644 --- a/group15/1511_714512544/.idea/workspace.xml +++ b/group15/1511_714512544/.idea/workspace.xml @@ -1,7 +1,15 @@ - + + + + + + + + +