Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions group22/910725683/RemoteSystemsTempFiles/.project
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>
8 changes: 8 additions & 0 deletions group22/910725683/week01/.classpath
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="src" path="test"/>
<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>
4 changes: 4 additions & 0 deletions group22/910725683/week01/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/bin/
/.settings/
.classpatch
.prject
17 changes: 17 additions & 0 deletions group22/910725683/week01/.project
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>week01</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>
98 changes: 98 additions & 0 deletions group22/910725683/week01/src/com/coding/basic/ArrayList.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
package com.coding.basic;
import java.util.Arrays;

public class ArrayList implements List {

//�����ʼ����//
private final int DEFAULT_CAPICITY=7;

//����Ԫ�ظ���//
private int size = 0;

private Object[] elementData = new Object[DEFAULT_CAPICITY];

public void add(Object o){
ensureCapcity(size+1);
elementData[size++]=o;
}
public void add(int index, Object o){
//indexҪ����������//
checkIndex(index);
ensureCapcity(size+1);
/* index�������Ԫ������һλ,����index��ʼ�ƶ���ע��index��0��ʼ��
* ����Ҫ+1���򳤶�Ϊsize-((index)+1)+1
*/
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 temp=elementData[index];
/* index�����Ԫ������һλ,����index+1��ʼ�ƶ���ע��index��0��ʼ��
* ����Ҫ+1���򳤶�Ϊsize-((index+1)+1)+1
*/
System.arraycopy(elementData, index+1, elementData, index, size-index-1);
size--;
return temp;
}

public int size(){
return size;
}

public Iterator iterator(){
return new Iterator();
}

private class Iterator{
private int index=0;
public boolean hasNext(){
return index<size;
}
public Object next(){
checkIndex(index);
return elementData[index++];
}
}

//�ж�������±��Ƿ�Խ�粢��ʾ//
private void checkIndex(int index){
if (index<0 || index >=size){
throw new IndexOutOfBoundsException("get " + index+" in "+size);
}
}

//�ж��Ƿ���Ҫ���ݲ��������//
private void ensureCapcity(int size){
int oldLength=elementData.length;
if (size>=oldLength){
//util.ArrayList�еĹ�ʽ��Դ����ʹ�õ�����1������2//
int newLength=oldLength/2+oldLength;
if (newLength<size){
newLength=size;
}
//Arrays.copyOf�����µ�ָ�����ȵ�����//
elementData=Arrays.copyOf(elementData, newLength);
}
}

@Override
public String toString(){
//���������toString//
StringBuilder sb = new StringBuilder("[");
for (int i=0 ;i<size-1;i++){
sb.append(elementData[i]+",");
}
sb.append(elementData[size-1]);
sb.append("]");
return sb.toString();
}

}
110 changes: 110 additions & 0 deletions group22/910725683/week01/src/com/coding/basic/BinaryTreeNode.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
package com.coding.basic;

/**
* ʵ������һ������������BinarySearchTree
*/
public class BinaryTreeNode {

//���ڵ�this//
private Object data;
private BinaryTreeNode left;
private BinaryTreeNode right;

public BinaryTreeNode () {}

public BinaryTreeNode(Object o) {
this.data=o;
this.left=null;
this.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 void preOrder(BinaryTreeNode node) {
if (node.data!=null) {
System.out.print(node.data + " ");
if (node.left!=null) {
preOrder(node.left);
}
if (node.right!=null) {
preOrder(node.right);
}
}
}

//��������������//
public void inOrder(BinaryTreeNode node) {
if (node.data!=null) {
if (node.left!=null) {
inOrder(node.left);
}
System.out.print(node.data + " ");
if (node.right!=null) {
inOrder(node.right);
}
}
}

//������������Ҹ�//
public void postOrder(BinaryTreeNode node) {
if (node.data!=null) {
if (node.left!=null) {
postOrder(node.left);
}
if (node.right!=null) {
postOrder (node.right);
}
System.out.print(node.data + " ");
}
}

public BinaryTreeNode insert(Object o){
//�ȿ������ڵ��Dz��ǿյ�//
if (this.data==null){
this.data=o;
return this;
}else{
//С��ȥ��ߣ����ȥ�ұ�//
if ((int) o < (int) this.data){
/*������ǿյ��Ǿ������ˣ�����һ���µĽڵ�
*����߲��ǿյ�����������ҿյ�
*/
if (this.left==null){
this.left = new BinaryTreeNode(o);
return this.left;
}else{

return this.left.insert(o);
}
}else{
/*���ұ��ǿյ��Ǿ������ˣ�����һ���µĽڵ�
*���ұ߲��ǿյ�����������ҿյ�
*/
if (this.right==null){
this.right = new BinaryTreeNode(o);
return this.right;
}else{
return this.right.insert(o);
}
}
}
}
}
7 changes: 7 additions & 0 deletions group22/910725683/week01/src/com/coding/basic/Iterator.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package com.coding.basic;

public interface Iterator {
public boolean hasNext();
public Object next();

}
Loading