forked from onlyliuxin/coding2017
-
Notifications
You must be signed in to change notification settings - Fork 2
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 onlyliuxin#16 from nishuibaichuan/master
26组提交第一次作业,统计情况放在26组目录下
- Loading branch information
Showing
17 changed files
with
862 additions
and
460 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 |
---|---|---|
|
@@ -27,4 +27,3 @@ target | |
liuxin/.DS_Store | ||
liuxin/src/.DS_Store | ||
|
||
|
184 changes: 92 additions & 92 deletions
184
group26/2070509107/src/basic/collections/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 |
---|---|---|
@@ -1,92 +1,92 @@ | ||
package collections; | ||
|
||
/** | ||
* | ||
* @author Mahone Wu | ||
* @data:2017-03-10 | ||
* @description:ArrayList的自我实现,暂时没有自动扩展 | ||
* @version:1.0.0 | ||
*/ | ||
|
||
public class ArrayList implements List { | ||
|
||
// 数组存储数据大小 | ||
private int size = 0; | ||
|
||
int cap = 5; | ||
|
||
// 数组 | ||
private Object[] elementData = new Object[cap]; | ||
|
||
/** | ||
* 新增元素 | ||
*/ | ||
public void add(Object o) { | ||
elementData[size] = o; | ||
size++; | ||
} | ||
|
||
/** | ||
* 指定位置新增数据 | ||
*/ | ||
public void add(int index, Object o) { | ||
// 保存现在该位置有的元素 | ||
Object temp = elementData[index]; | ||
|
||
// 如果当前存放数据等于初始化数组大小,则数组需要进行扩容操作 | ||
if (elementData.length == size) { | ||
// TODO | ||
} | ||
// 如果没有超过大小,则把从插入开始点的数据都往后移一位 | ||
for (int i = size; i > index; i--) { | ||
elementData[i] = elementData[i - 1]; | ||
} | ||
// 将现在赋值的数据放到该位置 | ||
elementData[index] = o; | ||
size++; | ||
} | ||
|
||
/** | ||
* 获取数据 | ||
*/ | ||
public Object get(int index) { | ||
if (index > elementData.length) { | ||
return null; | ||
} | ||
return elementData[index]; | ||
} | ||
|
||
// 返回要删除的数据 | ||
public Object remove(int index) { | ||
// 要被删除的数据 | ||
Object data = elementData[index]; | ||
for (int i = index; i < size; i++) { | ||
elementData[i] = elementData[i + 1]; | ||
} | ||
size--; | ||
return data; | ||
} | ||
|
||
public int size() { | ||
return size; | ||
} | ||
|
||
// TODO | ||
/** | ||
* 循环输出 | ||
* | ||
* @return | ||
*/ | ||
public Iterator iterator() { | ||
int current = 0; | ||
if (hasNext(current)) { | ||
// return elementData[current+1]; | ||
} | ||
return null; | ||
} | ||
|
||
public boolean hasNext(int current) { | ||
return current < size(); | ||
} | ||
|
||
} | ||
package collections; | ||
|
||
/** | ||
* | ||
* @author Mahone Wu | ||
* @data:2017-03-10 | ||
* @description:ArrayList的自我实现,暂时没有自动扩展 | ||
* @version:1.0.0 | ||
*/ | ||
|
||
public class ArrayList implements List { | ||
|
||
// 数组存储数据大小 | ||
private int size = 0; | ||
|
||
int cap = 5; | ||
|
||
// 数组 | ||
private Object[] elementData = new Object[cap]; | ||
|
||
/** | ||
* 新增元素 | ||
*/ | ||
public void add(Object o) { | ||
elementData[size] = o; | ||
size++; | ||
} | ||
|
||
/** | ||
* 指定位置新增数据 | ||
*/ | ||
public void add(int index, Object o) { | ||
// 保存现在该位置有的元素 | ||
Object temp = elementData[index]; | ||
|
||
// 如果当前存放数据等于初始化数组大小,则数组需要进行扩容操作 | ||
if (elementData.length == size) { | ||
// TODO | ||
} | ||
// 如果没有超过大小,则把从插入开始点的数据都往后移一位 | ||
for (int i = size; i > index; i--) { | ||
elementData[i] = elementData[i - 1]; | ||
} | ||
// 将现在赋值的数据放到该位置 | ||
elementData[index] = o; | ||
size++; | ||
} | ||
|
||
/** | ||
* 获取数据 | ||
*/ | ||
public Object get(int index) { | ||
if (index > elementData.length) { | ||
return null; | ||
} | ||
return elementData[index]; | ||
} | ||
|
||
// 返回要删除的数据 | ||
public Object remove(int index) { | ||
// 要被删除的数据 | ||
Object data = elementData[index]; | ||
for (int i = index; i < size; i++) { | ||
elementData[i] = elementData[i + 1]; | ||
} | ||
size--; | ||
return data; | ||
} | ||
|
||
public int size() { | ||
return size; | ||
} | ||
|
||
// TODO | ||
/** | ||
* 循环输出 | ||
* | ||
* @return | ||
*/ | ||
public Iterator iterator() { | ||
int current = 0; | ||
if (hasNext(current)) { | ||
// return elementData[current+1]; | ||
} | ||
return null; | ||
} | ||
|
||
public boolean hasNext(int current) { | ||
return current < size(); | ||
} | ||
|
||
} |
86 changes: 43 additions & 43 deletions
86
group26/2070509107/src/basic/collections/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 |
---|---|---|
@@ -1,43 +1,43 @@ | ||
package collections; | ||
|
||
/** | ||
* | ||
* @author Mahone Wu | ||
* @data:2017-03-10 | ||
* @description:BinaryTreeNode的自我实现 @version:1.0.0 | ||
*/ | ||
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) { | ||
return null; | ||
} | ||
|
||
} | ||
package collections; | ||
|
||
/** | ||
* | ||
* @author Mahone Wu | ||
* @data:2017-03-10 | ||
* @description:BinaryTreeNode的自我实现 @version:1.0.0 | ||
*/ | ||
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) { | ||
return null; | ||
} | ||
|
||
} |
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 |
---|---|---|
@@ -1,8 +1,8 @@ | ||
package collections; | ||
|
||
public interface Iterator { | ||
public boolean hasNext(); | ||
|
||
public Object next(); | ||
|
||
} | ||
package collections; | ||
|
||
public interface Iterator { | ||
public boolean hasNext(); | ||
|
||
public Object next(); | ||
|
||
} |
Oops, something went wrong.