Skip to content

Commit

Permalink
Merge pull request onlyliuxin#16 from nishuibaichuan/master
Browse files Browse the repository at this point in the history
26组提交第一次作业,统计情况放在26组目录下
  • Loading branch information
BlindingDark authored Mar 13, 2017
2 parents 07f5362 + d0b066b commit 1a3df23
Show file tree
Hide file tree
Showing 17 changed files with 862 additions and 460 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,3 @@ target
liuxin/.DS_Store
liuxin/src/.DS_Store


184 changes: 92 additions & 92 deletions group26/2070509107/src/basic/collections/ArrayList.java
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 group26/2070509107/src/basic/collections/BinaryTreeNode.java
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;
}

}
16 changes: 8 additions & 8 deletions group26/2070509107/src/basic/collections/Iterator.java
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();

}
Loading

0 comments on commit 1a3df23

Please sign in to comment.