forked from onlyliuxin/coding2017
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #8 from lihhj/master
20170226-176653813
- Loading branch information
Showing
11 changed files
with
345 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<classpath> | ||
<classpathentry kind="src" path="src"/> | ||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/> | ||
<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/4"/> | ||
<classpathentry kind="output" path="bin"/> | ||
</classpath> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/bin/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<projectDescription> | ||
<name>1766538130226Lesson</name> | ||
<comment></comment> | ||
<projects> | ||
</projects> | ||
<buildSpec> | ||
<buildCommand> | ||
<name>org.eclipse.jdt.core.javabuilder</name> | ||
<arguments> | ||
</arguments> | ||
</buildCommand> | ||
</buildSpec> | ||
<natures> | ||
<nature>org.eclipse.jdt.core.javanature</nature> | ||
</natures> | ||
</projectDescription> |
11 changes: 11 additions & 0 deletions
11
group17/176653813/1766538130226Lesson/.settings/org.eclipse.jdt.core.prefs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
80 changes: 80 additions & 0 deletions
80
group17/176653813/1766538130226Lesson/src/com/coding/basic/ArrayList.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
package com.coding.basic; | ||
|
||
public class ArrayList implements List { | ||
|
||
private int size = 0; | ||
private Object[] obj = new Object[5]; | ||
|
||
@Override | ||
public void add(Object o) { | ||
if(this.size < 0 ) | ||
System.out.print("Error"); | ||
this.extend(100); | ||
obj[this.size] = o; | ||
this.size ++; | ||
} | ||
|
||
@Override | ||
public void add(int index, Object o) { | ||
|
||
if(index < 0) | ||
System.out.println("Error"); | ||
if(index < this.size){ | ||
extend(100); | ||
for(int i = this.size;i < index; i--){ | ||
obj[i+1] = obj[i]; | ||
} | ||
obj[index] = o; | ||
}else if(index >= size){ | ||
extend(100); | ||
obj[size] = o; | ||
} | ||
this.size++; | ||
} | ||
|
||
@Override | ||
public Object get(int index) { | ||
if(index < 0 || index > size){ | ||
System.out.println("Error"); | ||
return null; | ||
} | ||
return obj[index]; | ||
} | ||
|
||
@Override | ||
public Object remove(int index) { | ||
if(index < 0 || index > size){ | ||
System.out.println("Error"); | ||
return null; | ||
} | ||
for(int i = index;i <= size;i++){ | ||
obj[i] = obj[i+1]; | ||
} | ||
size--; | ||
return obj[index]; | ||
} | ||
|
||
@Override | ||
public int size() { | ||
return size; | ||
} | ||
public int length(){ | ||
return obj.length; | ||
} | ||
public void extend(int newLength){ | ||
if (this.size >= obj.length){ | ||
//À©Õ¹Êý×é | ||
Object[] old = obj; | ||
obj = new Object[size+newLength]; | ||
for(int i = 0;i < size; i++){ | ||
obj[i] = old[i]; | ||
} | ||
} | ||
return; | ||
} | ||
public void Iteror(){ | ||
for(int i = 0 ;i < size ; i++){ | ||
System.out.println(obj[i]); | ||
} | ||
} | ||
} |
96 changes: 96 additions & 0 deletions
96
group17/176653813/1766538130226Lesson/src/com/coding/basic/LinkList.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
package com.coding.basic; | ||
|
||
public class LinkList implements List{ | ||
|
||
private Node head; //头结点不计算个数 | ||
private static class Node{ | ||
Object data; | ||
Node next; | ||
} | ||
|
||
@Override | ||
public void add(Object o) { | ||
//第一步没有想到 | ||
if(null == head){ | ||
head = new Node(); | ||
head.next = null; | ||
head.data = o; | ||
}else{ | ||
//尾插入法 | ||
//Node t = new Node(); | ||
Node t; | ||
Node ins = new Node(); | ||
t = head; | ||
while(t.next != null){ | ||
t = t.next; | ||
} | ||
t.next = ins; | ||
ins.next = null; | ||
ins.data = o; | ||
} | ||
} | ||
|
||
@Override | ||
public void add(int index, Object o) { | ||
if(index < 0 ){ | ||
System.out.println("Error"); | ||
}else if(index == 0 || index == 1){ | ||
Node t = new Node(); | ||
t.next = head.next; | ||
head.next = t; | ||
t.data = o; | ||
}else{ | ||
Node t = new Node();//当前节点 | ||
Node p = new Node();//前一个节点 | ||
t = head.next; | ||
for(int i = 1;i < index;i++){ | ||
p = t; | ||
t = t.next; | ||
} | ||
Node ins = new Node(); | ||
p.next = ins; | ||
ins.next = t; | ||
ins.data = o; | ||
} | ||
|
||
} | ||
|
||
@Override | ||
public Object get(int index) { | ||
if(index < 0 || head == null){ | ||
System.out.println("Error"); | ||
return null; | ||
}else{ | ||
Node t ; | ||
t = head; | ||
for(int i = 1;i < index;i++){ | ||
t = t.next; | ||
} | ||
return t.data; | ||
} | ||
} | ||
|
||
@Override | ||
public Object remove(int index) { | ||
|
||
return null; | ||
} | ||
|
||
public void display(){ | ||
if(head == null){ | ||
System.out.println("No Data"); | ||
}else{ | ||
Node t ; | ||
t = head; | ||
while(t != null){ | ||
System.out.println("******"+t.data); | ||
t = t.next; | ||
} | ||
} | ||
|
||
} | ||
@Override | ||
public int size() { | ||
return 0; | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
group17/176653813/1766538130226Lesson/src/com/coding/basic/List.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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(); | ||
} |
35 changes: 35 additions & 0 deletions
35
group17/176653813/1766538130226Lesson/src/com/coding/basic/Queue.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package com.coding.basic; | ||
|
||
public class Queue { | ||
|
||
private LinkList elementData = new LinkList(); | ||
private int front = 0; | ||
private int rear = 0; | ||
|
||
|
||
public void enQueue(Object o){ | ||
elementData.add(o); | ||
rear++; | ||
} | ||
public Object deQueue(){ | ||
if(!isEmpty()){ | ||
Object obj = elementData.remove(front); | ||
front++; | ||
return obj; | ||
}else{ | ||
System.out.println("Queue is empty"); | ||
return null; | ||
} | ||
} | ||
public boolean isEmpty(){ | ||
if(front > rear){ | ||
return true; | ||
} | ||
return false; | ||
} | ||
|
||
public int size(){ | ||
return rear-front+1; | ||
} | ||
} | ||
|
41 changes: 41 additions & 0 deletions
41
group17/176653813/1766538130226Lesson/src/com/coding/basic/Stack.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package com.coding.basic; | ||
|
||
public class Stack { | ||
|
||
// | ||
private ArrayList elementData = new ArrayList(); | ||
private int top = 0; | ||
|
||
public void push(Object o){ | ||
elementData.add(o); | ||
top++; | ||
} | ||
|
||
public Object pop(){ | ||
if(!isEmpty()){ | ||
System.out.println("stack is empoty"); | ||
return null; | ||
} | ||
Object obj = elementData.remove(top); | ||
top--; | ||
return obj; | ||
} | ||
|
||
public Object peek(){ | ||
return elementData.get(top); | ||
} | ||
|
||
public boolean isEmpty(){ | ||
if(top != 0){ | ||
return true; | ||
} | ||
return false; | ||
} | ||
|
||
public int size(){ | ||
return top++; | ||
} | ||
|
||
|
||
|
||
} |
36 changes: 36 additions & 0 deletions
36
group17/176653813/1766538130226Lesson/src/com/coding/basic/Test.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package com.coding.basic; | ||
|
||
import static org.junit.Assert.*; | ||
|
||
public class Test { | ||
|
||
@org.junit.Test | ||
public void test() { | ||
|
||
/* ArrayList al = new ArrayList(); | ||
al.add(1); | ||
al.add(2); | ||
al.add(3); | ||
al.add(4); | ||
al.add(5); | ||
al.add(200); | ||
al.add(10,100); | ||
al.Iteror(); | ||
//System.out.println(al.length()); | ||
//System.out.println(al.size()); | ||
System.out.println("=================="); | ||
al.remove(0); | ||
al.Iteror();*/ | ||
|
||
LinkList ls = new LinkList(); | ||
ls.add(100); | ||
ls.add(300); | ||
ls.add(500); | ||
ls.add(1000); | ||
ls.add(3,2000); | ||
ls.display(); | ||
System.out.println(ls.get(4)); | ||
} | ||
|
||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<projectDescription> | ||
<name>RemoteSystemsTempFiles</name> | ||
<comment></comment> | ||
<projects> | ||
</projects> | ||
<buildSpec> | ||
</buildSpec> | ||
<natures> | ||
<nature>org.eclipse.rse.ui.remoteSystemsTempNature</nature> | ||
</natures> | ||
</projectDescription> |