Skip to content

Commit c280dd7

Browse files
authored
Merge pull request onlyliuxin#127 from dsfan/master
week 1 and some week 2
2 parents a2a5fc2 + b06506a commit c280dd7

File tree

173 files changed

+10979
-18
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

173 files changed

+10979
-18
lines changed

.gitignore

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
12
#################
23
## Eclipse
34
#################
@@ -258,24 +259,6 @@ tmp
258259
RemoteSystemsTempFiles
259260
.gitignore
260261

261-
262-
build/
263-
.idea/
264-
.gradle/
265-
*.class
266-
# Mobile Tools for Java (J2ME)
267-
.mtj.tmp/
268-
269-
# Package Files #
270-
*.jar
271-
*.war
272-
*.ear
273-
274-
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
275-
hs_err_pid*
276-
277-
#ide config
278-
.metadata
279262
.recommenders
280263
.idea/
281264
*.iml

group22/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/627559964/
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<classpath>
3+
<classpathentry kind="src" path="src"/>
4+
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
5+
<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/4"/>
6+
<classpathentry kind="output" path="bin"/>
7+
</classpath>

group22/1014331282/Mywork_LX/.project

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<projectDescription>
3+
<name>Mywork_LX</name>
4+
<comment></comment>
5+
<projects>
6+
</projects>
7+
<buildSpec>
8+
<buildCommand>
9+
<name>org.eclipse.jdt.core.javabuilder</name>
10+
<arguments>
11+
</arguments>
12+
</buildCommand>
13+
</buildSpec>
14+
<natures>
15+
<nature>org.eclipse.jdt.core.javanature</nature>
16+
</natures>
17+
</projectDescription>
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
eclipse.preferences.version=1
2+
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
3+
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
4+
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
5+
org.eclipse.jdt.core.compiler.compliance=1.8
6+
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
7+
org.eclipse.jdt.core.compiler.debug.localVariable=generate
8+
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
9+
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
10+
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
11+
org.eclipse.jdt.core.compiler.source=1.8
Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
package week1_0306;
2+
3+
4+
5+
public class ArrayList implements List
6+
{
7+
8+
private int size;
9+
10+
private Object[] elementData ;
11+
12+
public ArrayList()
13+
{
14+
elementData = new Object[3];
15+
size=-1;
16+
}
17+
18+
public void add(Object o)
19+
{
20+
if(size >= elementData.length-1)
21+
{
22+
Object[] replaceData=new Object[elementData.length+5];
23+
System.arraycopy(elementData, 0, replaceData, 0, elementData.length);
24+
elementData = replaceData;
25+
}
26+
elementData[++size] = o;
27+
}
28+
29+
public void add(int index, Object o)
30+
{
31+
Object[] replaceData=new Object[11];
32+
for(int i=0;i<index;i++)
33+
{
34+
replaceData[i]=elementData[i];
35+
}
36+
replaceData[index]=o;
37+
for(int i=index+1;i<elementData.length+1;i++)
38+
{
39+
replaceData[i]=elementData[i-1];
40+
}
41+
elementData=replaceData;
42+
size++;
43+
}
44+
45+
public Object get(int index)
46+
{
47+
if (index<=size && index>=0 && size>=0)
48+
return elementData[index];
49+
else return null;
50+
}
51+
52+
53+
public Object remove(int index)
54+
{
55+
size--;
56+
Object o=elementData[index];
57+
if (index<elementData.length && index>0)
58+
{
59+
for(int i=index;i<elementData.length-1;i++)
60+
{
61+
elementData[i]=elementData[i+1];
62+
}
63+
elementData[elementData.length-1]=null;
64+
return o;
65+
}
66+
else return null;
67+
}
68+
69+
public int size()
70+
{
71+
if(size>=0)
72+
return size+1;
73+
else
74+
return 0;
75+
}
76+
77+
public Iterator iterator()
78+
{
79+
return new ArrayListIterator(this);
80+
}
81+
82+
private class ArrayListIterator implements Iterator
83+
{
84+
ArrayList l=null;
85+
int pos = 0;
86+
private ArrayListIterator(ArrayList l)
87+
{
88+
this.l=l;
89+
}
90+
91+
@Override
92+
public boolean hasNext() {
93+
// TODO Auto-generated method stub
94+
pos++;
95+
if(pos > size)
96+
return false;
97+
else return true;
98+
}
99+
100+
@Override
101+
public Object next() {
102+
// TODO Auto-generated method stub
103+
return elementData[pos];
104+
105+
}
106+
107+
public Object remove()
108+
{
109+
return this.l.remove(pos);
110+
}
111+
112+
}
113+
114+
}
Lines changed: 135 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,135 @@
1+
package week1_0306;
2+
3+
import java.util.Comparator;
4+
5+
import week1_0306.BinaryTree.BinaryTreeNode;
6+
7+
public class BinaryTree
8+
{
9+
private BinaryTreeNode root;
10+
11+
private BinaryTreeNode pointer;
12+
13+
public BinaryTreeNode getRoot() {
14+
return root;
15+
}
16+
17+
public void setRoot(BinaryTreeNode root) {
18+
this.root = root;
19+
}
20+
21+
public BinaryTreeNode getPointer() {
22+
return pointer;
23+
}
24+
25+
public void setPointer(BinaryTreeNode pointer) {
26+
this.pointer = pointer;
27+
}
28+
29+
public BinaryTree()
30+
{
31+
root=new BinaryTreeNode();
32+
pointer=root;
33+
}
34+
35+
public BinaryTreeNode insert(Object o,Comparator c)
36+
{
37+
38+
pointer= root.insert(o, c);
39+
return pointer;
40+
}
41+
42+
public void printTree()
43+
{
44+
root.printNode();
45+
}
46+
47+
public class BinaryTreeNode
48+
{
49+
50+
private Object data;
51+
private BinaryTreeNode left;
52+
private BinaryTreeNode right;
53+
54+
public Object getData() {
55+
return data;
56+
}
57+
58+
public void setData(Object data) {
59+
this.data = data;
60+
}
61+
62+
public BinaryTreeNode getLeft() {
63+
pointer=left;
64+
return left;
65+
}
66+
67+
public void setLeft(BinaryTreeNode left) {
68+
this.left = left;
69+
}
70+
71+
public BinaryTreeNode getRight() {
72+
pointer=right;
73+
return right;
74+
}
75+
76+
public void setRight(BinaryTreeNode right) {
77+
this.right = right;
78+
}
79+
80+
81+
82+
public BinaryTreeNode insert(Object o, Comparator c) //½¨ÓйæÂɵÄÊ÷+²åÈë
83+
{
84+
if(this.data == null)
85+
{
86+
this.data = o;
87+
return this;
88+
}
89+
90+
int i = c.compare(this.data,o);
91+
92+
if( i > 0 )
93+
{
94+
if(this.left == null)
95+
{
96+
this.left=new BinaryTreeNode();
97+
this.left.data=o;
98+
return this.left;
99+
}
100+
else
101+
return this.left.insert(o, c);
102+
}
103+
else if(i < 0)
104+
{
105+
if(this.right == null)
106+
{
107+
this.right=new BinaryTreeNode();
108+
this.right.data = o;
109+
return this.right;
110+
}
111+
112+
else
113+
return this.right.insert(o, c);
114+
}
115+
else
116+
{
117+
return this;
118+
}
119+
120+
}
121+
122+
public void printNode()
123+
{
124+
ScoreRecord s=(ScoreRecord)(this.getData());
125+
System.out.println(s.getName()+" "+s.getId());
126+
if(this.getLeft()!=null)
127+
this.getLeft().printNode();
128+
if(this.getRight()!=null)
129+
this.getRight().printNode();
130+
else return;
131+
}
132+
133+
}
134+
135+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
package week1_0306;
2+
3+
public interface Iterator {
4+
5+
public boolean hasNext();
6+
public Object next();
7+
public Object remove();
8+
9+
}

0 commit comments

Comments
 (0)