Skip to content

Commit 99f53a7

Browse files
authored
Merge pull request onlyliuxin#34 from zhanglifeng/master
第五组第一次作业
2 parents fa0a05f + f562ec9 commit 99f53a7

File tree

136 files changed

+7368
-0
lines changed

Some content is hidden

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

136 files changed

+7368
-0
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ hs_err_pid*
1414
#ide config
1515
.metadata
1616
.recommenders
17+
.idea/
18+
1719

1820

1921
#macOS

group05/1026626960/.classpath

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
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"/>
5+
<classpathentry kind="output" path="bin"/>
6+
</classpath>

group05/1026626960/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/bin/

group05/1026626960/.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>1026626960Coding</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: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
package cn.study1;
2+
3+
public class myIterator {
4+
//
5+
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
package cn.study1;
2+
3+
public class myQueue<T> {
4+
private class Node{
5+
T t;
6+
Node next;
7+
}
8+
private Node first;
9+
private Node last;
10+
private int N;
11+
public boolean isEmpty(){
12+
return N==0;
13+
}
14+
public int size(){
15+
return N;
16+
}
17+
public void enqueue(T t){
18+
Node oldlast = last;
19+
last = new Node();
20+
last.t = t;
21+
last.next = null;
22+
if(isEmpty()){
23+
first = last;
24+
}else{
25+
oldlast.next = last;
26+
}
27+
N++;
28+
}
29+
public T dequeue(){
30+
T t = first.t;
31+
first = first.next;
32+
if(isEmpty()){
33+
last = null;
34+
}
35+
N--;
36+
return t;
37+
}
38+
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
package cn.study1;
2+
3+
public class myStack<T> {
4+
private class Node{
5+
T t;
6+
Node next;
7+
}
8+
private Node first;
9+
private int N;
10+
public boolean isEmpty(){
11+
return N==0;
12+
}
13+
public int size(){
14+
return N;
15+
}
16+
public void push(T t){
17+
Node oldfirst = first;
18+
first = new Node();
19+
first.t = t;
20+
first.next = oldfirst;
21+
N++;
22+
}
23+
public T pop(){
24+
T t = first.t;
25+
first = first.next;
26+
N--;
27+
return t;
28+
}
29+
}

group05/1094051862/test01/.classpath

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.junit.JUNIT_CONTAINER/4"/>
5+
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
6+
<classpathentry kind="output" path="bin"/>
7+
</classpath>

group05/1094051862/test01/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/bin/

group05/1094051862/test01/.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>test01</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: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
eclipse.preferences.version=1
2+
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
3+
org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate
4+
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7
5+
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
6+
org.eclipse.jdt.core.compiler.compliance=1.7
7+
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
8+
org.eclipse.jdt.core.compiler.debug.localVariable=generate
9+
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
10+
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
11+
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
12+
org.eclipse.jdt.core.compiler.source=1.7

group05/1094051862/test01/src/com/coding/basic/.gitignore

Whitespace-only changes.
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
package com.coding.basic;
2+
3+
import java.util.Arrays;
4+
5+
public class ArrayList implements List {
6+
7+
private int size = 0;
8+
9+
private Object[] elementData = new Object[10];
10+
11+
private int increaseSize = 3;
12+
private void increaseArray() {
13+
Object[] newData = Arrays.copyOf(elementData, elementData.length + increaseSize);
14+
elementData = newData;
15+
}
16+
public void add(Object o){
17+
if (size == elementData.length) {
18+
increaseArray();
19+
elementData[size++] = o;
20+
} else {
21+
elementData[size++] = o;
22+
}
23+
}
24+
public void add(int index, Object o){
25+
if (index < 0 || index > size) {
26+
System.out.println("错误提示:index > size || index < 0");
27+
return;
28+
}
29+
Object temp;
30+
for (int i = index; i < size; i++) {
31+
temp = elementData[i];
32+
elementData[i] = o;
33+
o = temp;
34+
}
35+
elementData[size ++] = o;
36+
}
37+
38+
public Object get(int index){
39+
if (index < 0 || index > size ){
40+
return null;
41+
}
42+
return elementData[index];
43+
}
44+
45+
public Object remove(int index){
46+
if (index < 0 || index > size ){
47+
return null;
48+
}
49+
Object result = elementData[index];
50+
for (int i = index; i < size-1; i++) {
51+
elementData[i] = elementData[i + 1];
52+
}
53+
elementData[size-1] = null;
54+
size --;
55+
return result;
56+
}
57+
58+
public int size(){
59+
return size;
60+
}
61+
62+
public Iterator iterator(){
63+
return new Iterator() {
64+
private int cusor = 0;
65+
@Override
66+
public Object next() {
67+
if (!hasNext()) {
68+
System.out.println("next: !hasNext");
69+
return null;
70+
}
71+
return elementData[cusor ++];
72+
}
73+
@Override
74+
public boolean hasNext() {
75+
return cusor < size;
76+
}
77+
};
78+
}
79+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
package com.coding.basic;
2+
3+
import org.junit.Assert;
4+
import org.junit.Test;
5+
6+
public class ArrayListTest {
7+
8+
@Test
9+
public void test() {
10+
List list = new ArrayList();
11+
for(int i = 0; i < 10; i++) {
12+
list.add(i);
13+
}
14+
Assert.assertEquals(10, list.size());
15+
list.add(11);
16+
list.add(3,99);
17+
Assert.assertEquals(99, list.get(3));
18+
Assert.assertEquals(12, list.size());
19+
Assert.assertEquals(99, list.remove(3));
20+
Assert.assertEquals(11, list.size());
21+
Iterator iterator = list.iterator();
22+
for (int i = 0; i< list.size(); i++) {
23+
System.out.println(list.get(i));
24+
}
25+
System.out.println("======");
26+
while (iterator.hasNext()) {
27+
System.out.println(iterator.next());
28+
}
29+
}
30+
31+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
package com.coding.basic;
2+
3+
public class BinaryTreeNode {
4+
5+
private Object data;
6+
private BinaryTreeNode left;
7+
private BinaryTreeNode right;
8+
9+
public Object getData() {
10+
return data;
11+
}
12+
public void setData(Object data) {
13+
this.data = data;
14+
}
15+
public BinaryTreeNode getLeft() {
16+
return left;
17+
}
18+
public void setLeft(BinaryTreeNode left) {
19+
this.left = left;
20+
}
21+
public BinaryTreeNode getRight() {
22+
return right;
23+
}
24+
public void setRight(BinaryTreeNode right) {
25+
this.right = right;
26+
}
27+
28+
public BinaryTreeNode insert(Object o){
29+
return null;
30+
}
31+
32+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
package com.coding.basic;
2+
3+
public interface Iterator {
4+
public boolean hasNext();
5+
public Object next();
6+
7+
}

0 commit comments

Comments
 (0)