From a459047b8944ac86dc9ceea93c644a598e6f6615 Mon Sep 17 00:00:00 2001 From: chishiwu <1107225491@qq.com> Date: Tue, 7 Mar 2017 15:51:56 +0800 Subject: [PATCH 1/4] =?UTF-8?q?=E7=AC=AC=E4=B8=80=E6=AC=A1=E6=B5=8B?= =?UTF-8?q?=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- group24/1107225491/1107225491/.classpath | 6 ++++++ group24/1107225491/1107225491/.project | 17 +++++++++++++++++ .../.settings/org.eclipse.jdt.core.prefs | 11 +++++++++++ group24/1107225491/1107225491/test.txt | 1 + 4 files changed, 35 insertions(+) create mode 100644 group24/1107225491/1107225491/.classpath create mode 100644 group24/1107225491/1107225491/.project create mode 100644 group24/1107225491/1107225491/.settings/org.eclipse.jdt.core.prefs create mode 100644 group24/1107225491/1107225491/test.txt diff --git a/group24/1107225491/1107225491/.classpath b/group24/1107225491/1107225491/.classpath new file mode 100644 index 0000000000..07ca123c63 --- /dev/null +++ b/group24/1107225491/1107225491/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/group24/1107225491/1107225491/.project b/group24/1107225491/1107225491/.project new file mode 100644 index 0000000000..2d1d33be8a --- /dev/null +++ b/group24/1107225491/1107225491/.project @@ -0,0 +1,17 @@ + + + 1107225491 + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/group24/1107225491/1107225491/.settings/org.eclipse.jdt.core.prefs b/group24/1107225491/1107225491/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000000..54e493c07c --- /dev/null +++ b/group24/1107225491/1107225491/.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.6 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.6 +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.6 diff --git a/group24/1107225491/1107225491/test.txt b/group24/1107225491/1107225491/test.txt new file mode 100644 index 0000000000..2086f8809c --- /dev/null +++ b/group24/1107225491/1107225491/test.txt @@ -0,0 +1 @@ +ܶܶ \ No newline at end of file From 834d80e9117f470dbb950953a552a80c876b1cbe Mon Sep 17 00:00:00 2001 From: chishiwu <1107225491@qq.com> Date: Sun, 12 Mar 2017 19:46:32 +0800 Subject: [PATCH 2/4] =?UTF-8?q?=E7=AC=AC=E4=B8=80=E6=AC=A1=E4=BD=9C?= =?UTF-8?q?=E4=B8=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 只实现ArrayList和Stack和博客,其他暂时未完成。 --- group24/1107225491/1107225491/.classpath | 6 - group24/1107225491/1107225491/.project | 17 --- .../.settings/org.eclipse.jdt.core.prefs | 11 -- group24/1107225491/1107225491/test.txt | 1 - .../chishiwu/coding2017/basic/ArrayList.java | 90 +++++++++++++ .../chishiwu/coding2017/basic/Iterator.java | 7 + .../chishiwu/coding2017/basic/LinkedList.java | 124 ++++++++++++++++++ .../chishiwu/coding2017/basic/List.java | 9 ++ .../chishiwu/coding2017/basic/Queue.java | 19 +++ .../chishiwu/coding2017/basic/Stack.java | 49 +++++++ ...2\345\256\242\345\234\260\345\235\200.txt" | 1 + 11 files changed, 299 insertions(+), 35 deletions(-) delete mode 100644 group24/1107225491/1107225491/.classpath delete mode 100644 group24/1107225491/1107225491/.project delete mode 100644 group24/1107225491/1107225491/.settings/org.eclipse.jdt.core.prefs delete mode 100644 group24/1107225491/1107225491/test.txt create mode 100644 group24/1107225491/1107225491Learning/src/com/github/chishiwu/coding2017/basic/ArrayList.java create mode 100644 group24/1107225491/1107225491Learning/src/com/github/chishiwu/coding2017/basic/Iterator.java create mode 100644 group24/1107225491/1107225491Learning/src/com/github/chishiwu/coding2017/basic/LinkedList.java create mode 100644 group24/1107225491/1107225491Learning/src/com/github/chishiwu/coding2017/basic/List.java create mode 100644 group24/1107225491/1107225491Learning/src/com/github/chishiwu/coding2017/basic/Queue.java create mode 100644 group24/1107225491/1107225491Learning/src/com/github/chishiwu/coding2017/basic/Stack.java create mode 100644 "group24/1107225491/\345\215\232\345\256\242\345\234\260\345\235\200.txt" diff --git a/group24/1107225491/1107225491/.classpath b/group24/1107225491/1107225491/.classpath deleted file mode 100644 index 07ca123c63..0000000000 --- a/group24/1107225491/1107225491/.classpath +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - diff --git a/group24/1107225491/1107225491/.project b/group24/1107225491/1107225491/.project deleted file mode 100644 index 2d1d33be8a..0000000000 --- a/group24/1107225491/1107225491/.project +++ /dev/null @@ -1,17 +0,0 @@ - - - 1107225491 - - - - - - org.eclipse.jdt.core.javabuilder - - - - - - org.eclipse.jdt.core.javanature - - diff --git a/group24/1107225491/1107225491/.settings/org.eclipse.jdt.core.prefs b/group24/1107225491/1107225491/.settings/org.eclipse.jdt.core.prefs deleted file mode 100644 index 54e493c07c..0000000000 --- a/group24/1107225491/1107225491/.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.6 -org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve -org.eclipse.jdt.core.compiler.compliance=1.6 -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.6 diff --git a/group24/1107225491/1107225491/test.txt b/group24/1107225491/1107225491/test.txt deleted file mode 100644 index 2086f8809c..0000000000 --- a/group24/1107225491/1107225491/test.txt +++ /dev/null @@ -1 +0,0 @@ -ܶܶ \ No newline at end of file diff --git a/group24/1107225491/1107225491Learning/src/com/github/chishiwu/coding2017/basic/ArrayList.java b/group24/1107225491/1107225491Learning/src/com/github/chishiwu/coding2017/basic/ArrayList.java new file mode 100644 index 0000000000..193fbbb536 --- /dev/null +++ b/group24/1107225491/1107225491Learning/src/com/github/chishiwu/coding2017/basic/ArrayList.java @@ -0,0 +1,90 @@ +package com.github.chishiwu.coding2017.basic; + +import java.util.Arrays; + +public class ArrayList implements List { + + private int size = 0; + Object[] elementData = new Object[100]; + + // 动态添加元素 + public void add(Object o) { + ensureCapacity(size + 1); + elementData[size] = o; + size++; + + } + + public void add(int index, Object o) { + Check(index); + ensureCapacity(size + 1); + System.arraycopy(elementData, index, elementData, index + 1, size + - index); + elementData[index] = o; + size++; + } + + // 动态扩容 + private void ensureCapacity(int minCapacity) { + // TODO Auto-generated method stub + int oldCapacity = elementData.length; + if (minCapacity > oldCapacity) { + int newCapacity = (oldCapacity * 3) / 2 + 1; + if (newCapacity < minCapacity) { + newCapacity = minCapacity; + } + elementData = Arrays.copyOf(elementData, newCapacity); + } + } + + public void Check(int index) { + if (index >= size || index < 0) { + throw new IndexOutOfBoundsException("index" + index + "越界"); + } + } + + public Object get(int index) { + Check(index); + return elementData[index]; + } + + public Object remove(int index) { + Check(index); + // 备份 + Object oldValue = elementData[index]; + int num = size - index - 1; + if (num > 0) + System.arraycopy(elementData, index + 1, elementData, index + 1, + num); + elementData[--size] = null; + return oldValue; + + } + + public int size() { + return size; + } + + public Iterator iterator() { + return new ArrayListIterator(); + } + + private class ArrayListIterator implements Iterator { + + private int currentIndex = 0; + + public boolean hasNext() { + if (currentIndex >= size) + return false; + else + return true; + } + + public Object next() { + Object o = elementData[currentIndex]; + currentIndex++; + return o; + } + } + +} diff --git a/group24/1107225491/1107225491Learning/src/com/github/chishiwu/coding2017/basic/Iterator.java b/group24/1107225491/1107225491Learning/src/com/github/chishiwu/coding2017/basic/Iterator.java new file mode 100644 index 0000000000..9096a3c111 --- /dev/null +++ b/group24/1107225491/1107225491Learning/src/com/github/chishiwu/coding2017/basic/Iterator.java @@ -0,0 +1,7 @@ +package com.github.chishiwu.coding2017.basic; + +public interface Iterator { + public boolean hasNext(); + public Object next(); + +} diff --git a/group24/1107225491/1107225491Learning/src/com/github/chishiwu/coding2017/basic/LinkedList.java b/group24/1107225491/1107225491Learning/src/com/github/chishiwu/coding2017/basic/LinkedList.java new file mode 100644 index 0000000000..9e1a5f8646 --- /dev/null +++ b/group24/1107225491/1107225491Learning/src/com/github/chishiwu/coding2017/basic/LinkedList.java @@ -0,0 +1,124 @@ +package com.github.chishiwu.coding2017.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; + + } + + /** + * 鎶婅閾捐〃閫嗙疆 + * 渚嬪閾捐〃涓�3->7->10 , 閫嗙疆鍚庡彉涓� 10->7->3 + */ + public void reverse(){ + + } + + /** + * 鍒犻櫎涓�釜鍗曢摼琛ㄧ殑鍓嶅崐閮ㄥ垎 + * 渚嬪锛歭ist = 2->5->7->8 , 鍒犻櫎浠ュ悗鐨勫�涓�7->8 + * 濡傛灉list = 2->5->7->8->10 ,鍒犻櫎浠ュ悗鐨勫�涓�,8,10 + + */ + public void removeFirstHalf(){ + + } + + /** + * 浠庣i涓厓绱犲紑濮嬶紝 鍒犻櫎length 涓厓绱�锛�娉ㄦ剰i浠�寮� + * @param i + * @param length + */ + public void remove(int i, int length){ + + } + /** + * 鍋囧畾褰撳墠閾捐〃鍜宭ist鍧囧寘鍚凡鍗囧簭鎺掑垪鐨勬暣鏁� + * 浠庡綋鍓嶉摼琛ㄤ腑鍙栧嚭閭d簺list鎵�寚瀹氱殑鍏冪礌 + * 渚嬪褰撳墠閾捐〃 = 11->101->201->301->401->501->601->701 + * listB = 1->3->4->6 + * 杩斿洖鐨勭粨鏋滃簲璇ユ槸[101,301,401,601] + * @param list + */ + public static int[] getElements(LinkedList list){ + return null; + } + + /** + * 宸茬煡閾捐〃涓殑鍏冪礌浠ュ�閫掑鏈夊簭鎺掑垪锛屽苟浠ュ崟閾捐〃浣滃瓨鍌ㄧ粨鏋勩� + * 浠庡綋鍓嶉摼琛ㄤ腑涓垹闄ゅ湪list涓嚭鐜扮殑鍏冪礌 + + * @param list + */ + + public void subtract(LinkedList list){ + + } + + /** + * 宸茬煡褰撳墠閾捐〃涓殑鍏冪礌浠ュ�閫掑鏈夊簭鎺掑垪锛屽苟浠ュ崟閾捐〃浣滃瓨鍌ㄧ粨鏋勩� + * 鍒犻櫎琛ㄤ腑鎵�湁鍊肩浉鍚岀殑澶氫綑鍏冪礌锛堜娇寰楁搷浣滃悗鐨勭嚎鎬ц〃涓墍鏈夊厓绱犵殑鍊煎潎涓嶇浉鍚岋級 + */ + public void removeDuplicateValues(){ + + } + + /** + * 宸茬煡閾捐〃涓殑鍏冪礌浠ュ�閫掑鏈夊簭鎺掑垪锛屽苟浠ュ崟閾捐〃浣滃瓨鍌ㄧ粨鏋勩� + * 璇曞啓涓�珮鏁堢殑绠楁硶锛屽垹闄よ〃涓墍鏈夊�澶т簬min涓斿皬浜巑ax鐨勫厓绱狅紙鑻ヨ〃涓瓨鍦ㄨ繖鏍风殑鍏冪礌锛� + * @param min + * @param max + */ + public void removeRange(int min, int max){ + + } + + /** + * 鍋囪褰撳墠閾捐〃鍜屽弬鏁發ist鎸囧畾鐨勯摼琛ㄥ潎浠ュ厓绱犱緷鍊奸�澧炴湁搴忔帓鍒楋紙鍚屼竴琛ㄤ腑鐨勫厓绱犲�鍚勪笉鐩稿悓锛� + * 鐜拌姹傜敓鎴愭柊閾捐〃C锛屽叾鍏冪礌涓哄綋鍓嶉摼琛ㄥ拰list涓厓绱犵殑浜ら泦锛屼笖琛–涓殑鍏冪礌鏈変緷鍊奸�澧炴湁搴忔帓鍒� + * @param list + */ + public LinkedList intersection( LinkedList list){ + return null; + } +} diff --git a/group24/1107225491/1107225491Learning/src/com/github/chishiwu/coding2017/basic/List.java b/group24/1107225491/1107225491Learning/src/com/github/chishiwu/coding2017/basic/List.java new file mode 100644 index 0000000000..682d54dbfe --- /dev/null +++ b/group24/1107225491/1107225491Learning/src/com/github/chishiwu/coding2017/basic/List.java @@ -0,0 +1,9 @@ +package com.github.chishiwu.coding2017.basic; + +public interface List { + public void add(Object o); + public void add(int index, Object o); + public Object get(int index); + public Object remove(int index); + public int size(); +} diff --git a/group24/1107225491/1107225491Learning/src/com/github/chishiwu/coding2017/basic/Queue.java b/group24/1107225491/1107225491Learning/src/com/github/chishiwu/coding2017/basic/Queue.java new file mode 100644 index 0000000000..0bef3f55fb --- /dev/null +++ b/group24/1107225491/1107225491Learning/src/com/github/chishiwu/coding2017/basic/Queue.java @@ -0,0 +1,19 @@ +package com.github.chishiwu.coding2017.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/group24/1107225491/1107225491Learning/src/com/github/chishiwu/coding2017/basic/Stack.java b/group24/1107225491/1107225491Learning/src/com/github/chishiwu/coding2017/basic/Stack.java new file mode 100644 index 0000000000..de1856f991 --- /dev/null +++ b/group24/1107225491/1107225491Learning/src/com/github/chishiwu/coding2017/basic/Stack.java @@ -0,0 +1,49 @@ +package com.github.chishiwu.coding2017.basic; + +public class Stack { + private Node mStackNode; + private int size; + + public void push(Object o) { + Node node = new Node(); + node.data = o; + if (null == mStackNode) { + mStackNode = node; + } else { + mStackNode.next = node; + mStackNode = node; + } + size++; + } + + public Object pop() { + if (size == 0) { + throw new RuntimeException("the stack is empty"); + } + Object obj = mStackNode.data; + mStackNode = mStackNode.pre; + size--; + return obj; + } + + public Object peek() { + if (size == 0) { + throw new RuntimeException("the stack is empty"); + } + return mStackNode.data; + } + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + private static class Node { + Object data; + Node next; + Node pre; + } +} diff --git "a/group24/1107225491/\345\215\232\345\256\242\345\234\260\345\235\200.txt" "b/group24/1107225491/\345\215\232\345\256\242\345\234\260\345\235\200.txt" new file mode 100644 index 0000000000..eb815ca931 --- /dev/null +++ "b/group24/1107225491/\345\215\232\345\256\242\345\234\260\345\235\200.txt" @@ -0,0 +1 @@ +http://www.cnblogs.com/chishiwu/p/6514526.html \ No newline at end of file From 6c28d0bd450d2394c8ea927fee2c4ee555c0eb52 Mon Sep 17 00:00:00 2001 From: chishiwu <1107225491@qq.com> Date: Sun, 12 Mar 2017 20:37:30 +0800 Subject: [PATCH 3/4] =?UTF-8?q?=E7=AC=AC=E4=B8=80=E6=AC=A1=E6=B5=8B?= =?UTF-8?q?=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 删除无关的内容 --- group24/1107225491/1107225491Learning/test.txt | 1 + 1 file changed, 1 insertion(+) create mode 100644 group24/1107225491/1107225491Learning/test.txt diff --git a/group24/1107225491/1107225491Learning/test.txt b/group24/1107225491/1107225491Learning/test.txt new file mode 100644 index 0000000000..2086f8809c --- /dev/null +++ b/group24/1107225491/1107225491Learning/test.txt @@ -0,0 +1 @@ +ܶܶ \ No newline at end of file From 3cc4c758b251120daf89975304997fa6816ff7df Mon Sep 17 00:00:00 2001 From: chishiwu <1107225491@qq.com> Date: Sun, 12 Mar 2017 20:52:58 +0800 Subject: [PATCH 4/4] =?UTF-8?q?=E7=AC=AC=E4=B8=80=E6=AC=A1=E4=BD=9C?= =?UTF-8?q?=E4=B8=9A=EF=BC=88=E9=83=A8=E5=88=86=E5=AE=8C=E6=88=90=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 尝试提交 --- group24/1107225491/1107225491Learning/test.txt | 1 - 1 file changed, 1 deletion(-) delete mode 100644 group24/1107225491/1107225491Learning/test.txt diff --git a/group24/1107225491/1107225491Learning/test.txt b/group24/1107225491/1107225491Learning/test.txt deleted file mode 100644 index 2086f8809c..0000000000 --- a/group24/1107225491/1107225491Learning/test.txt +++ /dev/null @@ -1 +0,0 @@ -ܶܶ \ No newline at end of file