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 DonaldY/master
- Loading branch information
Showing
86 changed files
with
5,415 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"/> | ||
<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>1054283210Learning</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> |
27 changes: 27 additions & 0 deletions
27
group24/1054283210/src/com/github/xiaozi123/coding2017/basic/.gitignore
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,27 @@ | ||
*.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 | ||
.idea/ | ||
*.iml | ||
rebel.* | ||
.rebel.* | ||
|
||
# Idea | ||
*.iml | ||
*.ipr | ||
*.iws | ||
.idea | ||
|
||
target |
103 changes: 103 additions & 0 deletions
103
group24/1054283210/src/com/github/xiaozi123/coding2017/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,103 @@ | ||
package com.github.xiaozi123.coding2017.basic; | ||
|
||
import java.util.Arrays; | ||
|
||
import org.omg.CORBA.PUBLIC_MEMBER; | ||
|
||
public class ArrayList implements List { | ||
|
||
private int size = 0; | ||
|
||
private Object[] elementData = new Object[100]; | ||
|
||
public void add(Object o){ | ||
if(size>=elementData.length){//如果没有内存 获取两倍内存 | ||
elementData=Arrays.copyOf(elementData,size+1); | ||
} | ||
elementData[size]=o; | ||
size++; | ||
} | ||
public void add(int index, Object o){ | ||
if(index<0||index>=elementData.length){ | ||
throw new ArrayIndexOutOfBoundsException("OutOfBound"); | ||
} | ||
|
||
if(size>=elementData.length){//如果没有内存 获取两倍内存 | ||
elementData=Arrays.copyOf(elementData, size+1); | ||
} | ||
System.arraycopy(elementData, index, elementData, index+1, elementData.length-index-1); | ||
elementData[index]=o; | ||
size++; | ||
} | ||
|
||
public Object get(int index){ | ||
if(index<0||index>=elementData.length){ | ||
throw new ArrayIndexOutOfBoundsException("OutOfBound"); | ||
} | ||
return elementData[index]; | ||
} | ||
|
||
public Object remove(int index){ | ||
if(index<0||index>=elementData.length){ | ||
throw new ArrayIndexOutOfBoundsException("OutOfBound"); | ||
} | ||
Object temp=elementData[index]; | ||
System.arraycopy(elementData, index+1, elementData, index, elementData.length-index-1); | ||
size--; | ||
return temp; | ||
} | ||
|
||
/* | ||
* (non-Javadoc)获取目前长度 | ||
* @see com.github.xiaozi123.coding2017.basic.List#size() | ||
*/ | ||
public int size(){ | ||
if(size>=elementData.length){//如果没有内存 获取两倍内存 | ||
elementData=Arrays.copyOf(elementData,size+1); | ||
} | ||
return size; | ||
} | ||
|
||
// next() hasnext()方法 | ||
public Iterator iterator(){ | ||
return new Iterator(){ | ||
private int index = 0; | ||
public Object next(){ | ||
return elementData[index++]; | ||
} | ||
public boolean hasNext(){ | ||
return index >= size; | ||
} | ||
}; | ||
} | ||
|
||
public static void main(String[] args) { | ||
ArrayList arrayList=new ArrayList(); | ||
|
||
arrayList.add(0); | ||
arrayList.add(1); | ||
arrayList.add(2); | ||
System.out.println("数据个数为3:"+(arrayList.size==3)); | ||
|
||
System.out.print("数据应该为0,1,2: "); | ||
for (int i = 0; i < arrayList.size(); i++) { | ||
System.out.print(arrayList.get(i)+" "); | ||
} | ||
System.out.println(); | ||
|
||
arrayList.add(1,1); | ||
System.out.print("数据应该为:0,1,1,2: "); | ||
for (int i = 0; i < arrayList.size(); i++) { | ||
System.out.print(arrayList.get(i)+" "); | ||
} | ||
System.out.println(); | ||
|
||
System.out.print("数据应该为0: "); | ||
System.out.println(arrayList.remove(0)); | ||
|
||
|
||
} | ||
|
||
|
||
} | ||
|
72 changes: 72 additions & 0 deletions
72
group24/1054283210/src/com/github/xiaozi123/coding2017/basic/BinaryTreeNode.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,72 @@ | ||
package com.github.xiaozi123.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){ | ||
if (data==null) { | ||
this.setData(0); | ||
} | ||
if ((Integer)o<=(Integer)data) { | ||
if (left==null) { | ||
left=new BinaryTreeNode(); | ||
left.setData(o); | ||
return left; | ||
} | ||
return left.insert(o); | ||
}else{ | ||
if (right==null) { | ||
right=new BinaryTreeNode(); | ||
right.setData(o); | ||
return right; | ||
} | ||
return right.insert(o); | ||
|
||
} | ||
} | ||
@Override | ||
public String toString() { | ||
// TODO Auto-generated method stub | ||
return data+" "+left+" "+right; | ||
} | ||
|
||
public static void main(String[] args) { | ||
BinaryTreeNode binaryTreeNode=new BinaryTreeNode(); | ||
for (int i = 0; i < 5; i++) { | ||
binaryTreeNode.insert(i); | ||
} | ||
System.out.println(binaryTreeNode); | ||
} | ||
|
||
// 0 | ||
// 0 1 | ||
// null null null 2 | ||
// null 3 | ||
// null 4 | ||
// null null | ||
|
||
|
||
|
||
} |
7 changes: 7 additions & 0 deletions
7
group24/1054283210/src/com/github/xiaozi123/coding2017/basic/Iterator.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,7 @@ | ||
package com.github.xiaozi123.coding2017.basic; | ||
|
||
public interface Iterator { | ||
public boolean hasNext(); | ||
public Object next(); | ||
|
||
} |
Oops, something went wrong.