forked from onlyliuxin/coding2017
-
Notifications
You must be signed in to change notification settings - Fork 11
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 #1 from dsfan/master
17457741
- Loading branch information
Showing
36 changed files
with
2,213 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,17 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<projectDescription> | ||
<name>Mywork_LX</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
group22/1014331282/Mywork_LX/.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 |
114 changes: 114 additions & 0 deletions
114
group22/1014331282/Mywork_LX/src/week1_0306/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,114 @@ | ||
package week1_0306; | ||
|
||
|
||
|
||
public class ArrayList implements List | ||
{ | ||
|
||
private int size; | ||
|
||
private Object[] elementData ; | ||
|
||
public ArrayList() | ||
{ | ||
elementData = new Object[3]; | ||
size=-1; | ||
} | ||
|
||
public void add(Object o) | ||
{ | ||
if(size >= elementData.length-1) | ||
{ | ||
Object[] replaceData=new Object[elementData.length+5]; | ||
System.arraycopy(elementData, 0, replaceData, 0, elementData.length); | ||
elementData = replaceData; | ||
} | ||
elementData[++size] = o; | ||
} | ||
|
||
public void add(int index, Object o) | ||
{ | ||
Object[] replaceData=new Object[11]; | ||
for(int i=0;i<index;i++) | ||
{ | ||
replaceData[i]=elementData[i]; | ||
} | ||
replaceData[index]=o; | ||
for(int i=index+1;i<elementData.length+1;i++) | ||
{ | ||
replaceData[i]=elementData[i-1]; | ||
} | ||
elementData=replaceData; | ||
size++; | ||
} | ||
|
||
public Object get(int index) | ||
{ | ||
if (index<=size && index>=0 && size>=0) | ||
return elementData[index]; | ||
else return null; | ||
} | ||
|
||
|
||
public Object remove(int index) | ||
{ | ||
size--; | ||
Object o=elementData[index]; | ||
if (index<elementData.length && index>0) | ||
{ | ||
for(int i=index;i<elementData.length-1;i++) | ||
{ | ||
elementData[i]=elementData[i+1]; | ||
} | ||
elementData[elementData.length-1]=null; | ||
return o; | ||
} | ||
else return null; | ||
} | ||
|
||
public int size() | ||
{ | ||
if(size>=0) | ||
return size+1; | ||
else | ||
return 0; | ||
} | ||
|
||
public Iterator iterator() | ||
{ | ||
return new ArrayListIterator(this); | ||
} | ||
|
||
private class ArrayListIterator implements Iterator | ||
{ | ||
ArrayList l=null; | ||
int pos = 0; | ||
private ArrayListIterator(ArrayList l) | ||
{ | ||
this.l=l; | ||
} | ||
|
||
@Override | ||
public boolean hasNext() { | ||
// TODO Auto-generated method stub | ||
pos++; | ||
if(pos > size) | ||
return false; | ||
else return true; | ||
} | ||
|
||
@Override | ||
public Object next() { | ||
// TODO Auto-generated method stub | ||
return elementData[pos]; | ||
|
||
} | ||
|
||
public Object remove() | ||
{ | ||
return this.l.remove(pos); | ||
} | ||
|
||
} | ||
|
||
} |
135 changes: 135 additions & 0 deletions
135
group22/1014331282/Mywork_LX/src/week1_0306/BinaryTree.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,135 @@ | ||
package week1_0306; | ||
|
||
import java.util.Comparator; | ||
|
||
import week1_0306.BinaryTree.BinaryTreeNode; | ||
|
||
public class BinaryTree | ||
{ | ||
private BinaryTreeNode root; | ||
|
||
private BinaryTreeNode pointer; | ||
|
||
public BinaryTreeNode getRoot() { | ||
return root; | ||
} | ||
|
||
public void setRoot(BinaryTreeNode root) { | ||
this.root = root; | ||
} | ||
|
||
public BinaryTreeNode getPointer() { | ||
return pointer; | ||
} | ||
|
||
public void setPointer(BinaryTreeNode pointer) { | ||
this.pointer = pointer; | ||
} | ||
|
||
public BinaryTree() | ||
{ | ||
root=new BinaryTreeNode(); | ||
pointer=root; | ||
} | ||
|
||
public BinaryTreeNode insert(Object o,Comparator c) | ||
{ | ||
|
||
pointer= root.insert(o, c); | ||
return pointer; | ||
} | ||
|
||
public void printTree() | ||
{ | ||
root.printNode(); | ||
} | ||
|
||
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() { | ||
pointer=left; | ||
return left; | ||
} | ||
|
||
public void setLeft(BinaryTreeNode left) { | ||
this.left = left; | ||
} | ||
|
||
public BinaryTreeNode getRight() { | ||
pointer=right; | ||
return right; | ||
} | ||
|
||
public void setRight(BinaryTreeNode right) { | ||
this.right = right; | ||
} | ||
|
||
|
||
|
||
public BinaryTreeNode insert(Object o, Comparator c) //½¨ÓйæÂɵÄÊ÷+²åÈë | ||
{ | ||
if(this.data == null) | ||
{ | ||
this.data = o; | ||
return this; | ||
} | ||
|
||
int i = c.compare(this.data,o); | ||
|
||
if( i > 0 ) | ||
{ | ||
if(this.left == null) | ||
{ | ||
this.left=new BinaryTreeNode(); | ||
this.left.data=o; | ||
return this.left; | ||
} | ||
else | ||
return this.left.insert(o, c); | ||
} | ||
else if(i < 0) | ||
{ | ||
if(this.right == null) | ||
{ | ||
this.right=new BinaryTreeNode(); | ||
this.right.data = o; | ||
return this.right; | ||
} | ||
|
||
else | ||
return this.right.insert(o, c); | ||
} | ||
else | ||
{ | ||
return this; | ||
} | ||
|
||
} | ||
|
||
public void printNode() | ||
{ | ||
ScoreRecord s=(ScoreRecord)(this.getData()); | ||
System.out.println(s.getName()+" "+s.getId()); | ||
if(this.getLeft()!=null) | ||
this.getLeft().printNode(); | ||
if(this.getRight()!=null) | ||
this.getRight().printNode(); | ||
else return; | ||
} | ||
|
||
} | ||
|
||
} |
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 week1_0306; | ||
|
||
public interface Iterator { | ||
|
||
public boolean hasNext(); | ||
public Object next(); | ||
public Object remove(); | ||
|
||
} |
Oops, something went wrong.