diff --git a/.gitignore b/.gitignore index 4f78db6dbb..77cdfba900 100644 --- a/.gitignore +++ b/.gitignore @@ -27,4 +27,3 @@ target liuxin/.DS_Store liuxin/src/.DS_Store - diff --git a/group26/2070509107/src/basic/collections/ArrayList.java b/group26/2070509107/src/basic/collections/ArrayList.java index 8ba213409e..cdec1fdd01 100644 --- a/group26/2070509107/src/basic/collections/ArrayList.java +++ b/group26/2070509107/src/basic/collections/ArrayList.java @@ -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(); + } + +} diff --git a/group26/2070509107/src/basic/collections/BinaryTreeNode.java b/group26/2070509107/src/basic/collections/BinaryTreeNode.java index 2ec448e2a4..806ccf1d9e 100644 --- a/group26/2070509107/src/basic/collections/BinaryTreeNode.java +++ b/group26/2070509107/src/basic/collections/BinaryTreeNode.java @@ -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; + } + +} diff --git a/group26/2070509107/src/basic/collections/Iterator.java b/group26/2070509107/src/basic/collections/Iterator.java index 50dbd9800f..94a2a9b129 100644 --- a/group26/2070509107/src/basic/collections/Iterator.java +++ b/group26/2070509107/src/basic/collections/Iterator.java @@ -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(); + +} diff --git a/group26/2070509107/src/basic/collections/LinkedList.java b/group26/2070509107/src/basic/collections/LinkedList.java index e9eb46d34f..7a796daa3a 100644 --- a/group26/2070509107/src/basic/collections/LinkedList.java +++ b/group26/2070509107/src/basic/collections/LinkedList.java @@ -1,196 +1,196 @@ -package collections; - - -/** - * - * @author Mahone Wu - * @date:2017-03-11 - * @description:链表实现 - * @version:1.0.0 - */ -public class LinkedList implements List { - - //定义头节点 - private Node head; - - //最后一个节点 - private Node last; - - //链表大小 - private int size; - - /** - * 添加元素 - */ - public void add(Object o) { - addLast(o); - } - - /** - * 指定位置添加元素 - */ - public void add(int index, Object o) { - if(!(index >= 0 && index <= size)){ - //超出索引范围 - } - Node currentNode =null; - - - } - - - - - /** - * 获取指定元素 - */ - public Object get(int index) { - return null; - } - - public Object remove(int index) { - return null; - } - - public int size() { - return size; - } - - public void addFirst(Object o) { - Node fistNode = head; - Node newNode = new Node(null, o, head); - head = newNode; - if(null == fistNode){ - last = newNode; - }else{//将之前的头节点的前一个指向现在的头节点 - fistNode.prev = newNode; - } - size++; - } - - /** - * 向尾添加元素 - * @param o - */ - public void addLast(Object o) { - Node lastNode = last; - Node newNode = new Node(lastNode, o, null); - last = newNode;//将新增的节点设置为最后一个节点 - if(null == lastNode){//如果之前最后一个节点为空,则代表这是第一次增加节点,进行头节点设置 - head = newNode; - }else{ - lastNode.next = newNode; - } - size++; - } - - public Object removeFirst() { - return null; - } - - public Object removeLast() { - return null; - } - - public Iterator iterator() { - return null; - } - - //参照LinkedList源码实现 - private static class Node { - Object data; - Node prev; - Node next; - - Node(Node prev,Object object,Node next){ - this.prev = prev; - this.data = object; - this.next = next; - } - } - - /** - * 查找指定位置的Node节点 - * @param index - * @return - */ - Node findNode(int index){ - Node currentNode = head; - - - } - - /** - * 把该链表逆置 例如链表为 3->7->10 , 逆置后变为 10->7->3 - */ - public void reverse() { - - } - - /** - * 删除一个单链表的前半部分 例如:list = 2->5->7->8 , 删除以后的值为 7->8 如果list = 2->5->7->8->10 - * ,删除以后的值为7,8,10 - * - */ - public void removeFirstHalf() { - - } - - /** - * 从第i个元素开始, 删除length 个元素 , 注意i从0开始 - * - * @param i - * @param length - */ - public void remove(int i, int length) { - - } - - /** - * 假定当前链表和listB均包含已升序排列的整数 从当前链表中取出那些listB所指定的元素 例如当前链表 = - * 11->101->201->301->401->501->601->701 listB = 1->3->4->6 - * 返回的结果应该是[101,301,401,601] - * - * @param list - */ - public int[] getElements(LinkedList list) { - return null; - } - - /** - * 已知链表中的元素以值递增有序排列,并以单链表作存储结构。 从当前链表中中删除在listB中出现的元素 - * - * @param list - */ - - public void subtract(LinkedList list) { - - } - - /** - * 已知当前链表中的元素以值递增有序排列,并以单链表作存储结构。 删除表中所有值相同的多余元素(使得操作后的线性表中所有元素的值均不相同) - */ - public void removeDuplicateValues() { - - } - - /** - * 已知链表中的元素以值递增有序排列,并以单链表作存储结构。 试写一高效的算法,删除表中所有值大于min且小于max的元素(若表中存在这样的元素) - * - * @param min - * @param max - */ - public void removeRange(int min, int max) { - - } - - /** - * 假设当前链表和参数list指定的链表均以元素依值递增有序排列(同一表中的元素值各不相同) - * 现要求生成新链表C,其元素为当前链表和list中元素的交集,且表C中的元素有依值递增有序排列 - * - * @param list - */ - public LinkedList intersection(LinkedList list) { - return null; - } -} +package collections; + + +/** + * + * @author Mahone Wu + * @date:2017-03-11 + * @description:链表实现 + * @version:1.0.0 + */ +public class LinkedList implements List { + + //定义头节点 + private Node head; + + //最后一个节点 + private Node last; + + //链表大小 + private int size; + + /** + * 添加元素 + */ + public void add(Object o) { + addLast(o); + } + + /** + * 指定位置添加元素 + */ + public void add(int index, Object o) { + if(!(index >= 0 && index <= size)){ + //超出索引范围 + } + Node currentNode =null; + + + } + + + + + /** + * 获取指定元素 + */ + public Object get(int index) { + return null; + } + + public Object remove(int index) { + return null; + } + + public int size() { + return size; + } + + public void addFirst(Object o) { + Node fistNode = head; + Node newNode = new Node(null, o, head); + head = newNode; + if(null == fistNode){ + last = newNode; + }else{//将之前的头节点的前一个指向现在的头节点 + fistNode.prev = newNode; + } + size++; + } + + /** + * 向尾添加元素 + * @param o + */ + public void addLast(Object o) { + Node lastNode = last; + Node newNode = new Node(lastNode, o, null); + last = newNode;//将新增的节点设置为最后一个节点 + if(null == lastNode){//如果之前最后一个节点为空,则代表这是第一次增加节点,进行头节点设置 + head = newNode; + }else{ + lastNode.next = newNode; + } + size++; + } + + public Object removeFirst() { + return null; + } + + public Object removeLast() { + return null; + } + + public Iterator iterator() { + return null; + } + + //参照LinkedList源码实现 + private static class Node { + Object data; + Node prev; + Node next; + + Node(Node prev,Object object,Node next){ + this.prev = prev; + this.data = object; + this.next = next; + } + } + + /** + * 查找指定位置的Node节点 + * @param index + * @return + */ + Node findNode(int index){ + Node currentNode = head; + + + } + + /** + * 把该链表逆置 例如链表为 3->7->10 , 逆置后变为 10->7->3 + */ + public void reverse() { + + } + + /** + * 删除一个单链表的前半部分 例如:list = 2->5->7->8 , 删除以后的值为 7->8 如果list = 2->5->7->8->10 + * ,删除以后的值为7,8,10 + * + */ + public void removeFirstHalf() { + + } + + /** + * 从第i个元素开始, 删除length 个元素 , 注意i从0开始 + * + * @param i + * @param length + */ + public void remove(int i, int length) { + + } + + /** + * 假定当前链表和listB均包含已升序排列的整数 从当前链表中取出那些listB所指定的元素 例如当前链表 = + * 11->101->201->301->401->501->601->701 listB = 1->3->4->6 + * 返回的结果应该是[101,301,401,601] + * + * @param list + */ + public int[] getElements(LinkedList list) { + return null; + } + + /** + * 已知链表中的元素以值递增有序排列,并以单链表作存储结构。 从当前链表中中删除在listB中出现的元素 + * + * @param list + */ + + public void subtract(LinkedList list) { + + } + + /** + * 已知当前链表中的元素以值递增有序排列,并以单链表作存储结构。 删除表中所有值相同的多余元素(使得操作后的线性表中所有元素的值均不相同) + */ + public void removeDuplicateValues() { + + } + + /** + * 已知链表中的元素以值递增有序排列,并以单链表作存储结构。 试写一高效的算法,删除表中所有值大于min且小于max的元素(若表中存在这样的元素) + * + * @param min + * @param max + */ + public void removeRange(int min, int max) { + + } + + /** + * 假设当前链表和参数list指定的链表均以元素依值递增有序排列(同一表中的元素值各不相同) + * 现要求生成新链表C,其元素为当前链表和list中元素的交集,且表C中的元素有依值递增有序排列 + * + * @param list + */ + public LinkedList intersection(LinkedList list) { + return null; + } +} diff --git a/group26/2070509107/src/basic/collections/List.java b/group26/2070509107/src/basic/collections/List.java index c4401a476d..8cc886f400 100644 --- a/group26/2070509107/src/basic/collections/List.java +++ b/group26/2070509107/src/basic/collections/List.java @@ -1,13 +1,13 @@ -package collections; - -public interface List { - public void add(Object o); - - public void add(int index, Object o); - - public Object get(int index); - - public Object remove(int index); - - public int size(); -} +package collections; + +public interface List { + public void add(Object o); + + public void add(int index, Object o); + + public Object get(int index); + + public Object remove(int index); + + public int size(); +} diff --git a/group26/2070509107/src/basic/collections/Queue.java b/group26/2070509107/src/basic/collections/Queue.java index 49c916dbb6..47f4116e2f 100644 --- a/group26/2070509107/src/basic/collections/Queue.java +++ b/group26/2070509107/src/basic/collections/Queue.java @@ -1,20 +1,20 @@ -package collections; - -public class Queue { - - public void enQueue(Object o) { - - } - - public Object deQueue() { - return null; - } - - public boolean isEmpty() { - return false; - } - - public int size() { - return -1; - } -} +package collections; + +public class Queue { + + public void enQueue(Object o) { + + } + + public Object deQueue() { + return null; + } + + public boolean isEmpty() { + return false; + } + + public int size() { + return -1; + } +} diff --git a/group26/2070509107/src/basic/collections/Stack.java b/group26/2070509107/src/basic/collections/Stack.java index bec13a4191..7665278d45 100644 --- a/group26/2070509107/src/basic/collections/Stack.java +++ b/group26/2070509107/src/basic/collections/Stack.java @@ -1,69 +1,69 @@ -package collections; - -/** - * - * @author wuhao - * @date:2017-03-11 - * @description:栈的实现,栈是先进后出; - * @version:1.0.0 - * - */ -public class Stack { - - private ArrayList elementData = new ArrayList(); - - /** - * 存放元素 - * - * @param o - */ - public void push(Object o) { - elementData.add(o); - } - - /** - * 弹出元素,从最末尾弹出 - * - * @return - */ - public Object pop() { - if (elementData.size() == 0) { - return null; - } - return elementData.remove(elementData.size() - 1); - } - - /** - * 获取栈定元素 - * - * @return - */ - public Object peek() { - if (elementData.size() == 0) { - return null; - } - return elementData.get(elementData.size()); - } - - /** - * 判断是否为空 - * - * @return - */ - public boolean isEmpty() { - if (0 == elementData.size()) { - return false; - } - return true; - } - - /** - * 栈大小 - * - * @return - */ - public int size() { - return elementData.size(); - } - -} +package collections; + +/** + * + * @author wuhao + * @date:2017-03-11 + * @description:栈的实现,栈是先进后出; + * @version:1.0.0 + * + */ +public class Stack { + + private ArrayList elementData = new ArrayList(); + + /** + * 存放元素 + * + * @param o + */ + public void push(Object o) { + elementData.add(o); + } + + /** + * 弹出元素,从最末尾弹出 + * + * @return + */ + public Object pop() { + if (elementData.size() == 0) { + return null; + } + return elementData.remove(elementData.size() - 1); + } + + /** + * 获取栈定元素 + * + * @return + */ + public Object peek() { + if (elementData.size() == 0) { + return null; + } + return elementData.get(elementData.size()); + } + + /** + * 判断是否为空 + * + * @return + */ + public boolean isEmpty() { + if (0 == elementData.size()) { + return false; + } + return true; + } + + /** + * 栈大小 + * + * @return + */ + public int size() { + return elementData.size(); + } + +} diff --git a/group26/2411685663/src/nishuibaichuan/homework/first/ArrayList.java b/group26/2411685663/src/nishuibaichuan/homework/first/ArrayList.java new file mode 100644 index 0000000000..efa9ee9bd1 --- /dev/null +++ b/group26/2411685663/src/nishuibaichuan/homework/first/ArrayList.java @@ -0,0 +1,123 @@ +package JEE_2411685663; + +import java.util.Arrays; +import java.util.NoSuchElementException; + +public class ArrayList implements List { + + private static int size = 0; //全局静态变量 + + private Object[] elementData = new Object[100]; + + public void add(Object o) { + isCapacity(size + 1);//判断是否扩容 + elementData[size++] = o; + } + + public void add(int index, Object o) { + checkRangeForAdd(index);//判断下标是否越界 + isCapacity(size + 1); + //使用arraycopy将index下标以后元素后移动 (size - index)长度 + System.arraycopy(elementData, index, elementData, index + 1, size - index); + elementData[index] = o; + size++; + } + + public Object get(int index) { + checkRangeForAdd(index); + return (Object)elementData[index]; + } + + public Object remove(int index) { + checkRangeForAdd(index); + Object oldValue = get(index); + int numMoved = size - index - 1; + if (numMoved > 0) + System.arraycopy(elementData, index+1, elementData, index, + numMoved); + elementData[--size] = null; // index后面数据依次往前移动,将最后一个位置赋值为0,让gc来回收空间。 + return oldValue; + } + + public int size() { + return size; + } + + /** + * 迭代器 + * @return + */ + public Iterator iterator() { + return new SubIterator(this); + } + + private static class SubIterator implements Iterator{ + + private ArrayList arrayList; + private static int ret = 0; + + private SubIterator(){} + + private SubIterator(ArrayList arrayList){ + this.arrayList = arrayList ; + } + + public boolean hasNext() { + return ret != size; + } + + public Object next() { + if (ret > size) { + throw new NoSuchElementException();//没有这样的元素异常 + } + return arrayList.elementData[ret++]; + } + + public void remove() { + arrayList.remove(ret--); + } + + } + + /** + * 下标是否越界 + * @param index + */ + public void checkRangeForAdd(int index){ + if (index < 0 || index > size) { + throw new ArrayIndexOutOfBoundsException("index下标越界" + ", Size: " + size + + ",Index: " + index); + } + } + + /** + * 是否扩容 + */ + public void isCapacity(int size){ + if (size > 100) { + Capacity(size); + } + /** + * size小于0主要是因为当size超过Integer.MAX_VALUE就会变成负数。 + */ + if (size < 0) { + throw new ArrayIndexOutOfBoundsException("数组长度溢出"); + } + } + + public void Capacity(int capacity){ + int newLength = elementData.length + 1000;//再原来基础上扩容1000 + if (newLength - capacity < 0) { + newLength = capacity; //得到最大长度 + } + /** + * 保留了数组的头部信息在数组中,因此实际存放数据的大小就是整数的最大值 - 8 + * 很难执行下面的判断 + */ + if (newLength > Integer.MAX_VALUE - 8) { + newLength = capacity > Integer.MAX_VALUE - 8 ? Integer.MAX_VALUE : Integer.MAX_VALUE - 8; + } + elementData = Arrays.copyOf(elementData, newLength);//获取扩容后的数组 + } + +} diff --git a/group26/2411685663/src/nishuibaichuan/homework/first/BinaryTreeNode.java b/group26/2411685663/src/nishuibaichuan/homework/first/BinaryTreeNode.java new file mode 100644 index 0000000000..17984ab8d1 --- /dev/null +++ b/group26/2411685663/src/nishuibaichuan/homework/first/BinaryTreeNode.java @@ -0,0 +1,37 @@ +package nishuibaichuan.homework.first; + +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; + } + +} diff --git a/group26/2411685663/src/nishuibaichuan/homework/first/Iterator.java b/group26/2411685663/src/nishuibaichuan/homework/first/Iterator.java new file mode 100644 index 0000000000..a0d81a47ba --- /dev/null +++ b/group26/2411685663/src/nishuibaichuan/homework/first/Iterator.java @@ -0,0 +1,9 @@ +package nishuibaichuan.homework.first; + +public interface Iterator { + public boolean hasNext(); + + public Object next(); + + public void remove(); +} diff --git a/group26/2411685663/src/nishuibaichuan/homework/first/LinkedList.java b/group26/2411685663/src/nishuibaichuan/homework/first/LinkedList.java new file mode 100644 index 0000000000..bf38c91470 --- /dev/null +++ b/group26/2411685663/src/nishuibaichuan/homework/first/LinkedList.java @@ -0,0 +1,125 @@ +package nishuibaichuan.homework.first; + +public class LinkedList implements List { + + private Node head; + + public void add(Object o) { + + } + + public void add(int index, Object o) { + + } + + public Object get(int index) { + return null; + } + + public Object remove(int index) { + return null; + } + + public int size() { + return -1; + } + + public void addFirst(Object o) { + + } + + public void addLast(Object o) { + + } + + public Object removeFirst() { + return null; + } + + public Object removeLast() { + return null; + } + + public Iterator iterator() { + return null; + } + + private static class Node { + Object data; + Node next; + + } + + /** + * 把该链表逆置 例如链表为 3->7->10 , 逆置后变为 10->7->3 + */ + public void reverse() { + + } + + /** + * 删除一个单链表的前半部分 例如:list = 2->5->7->8 , 删除以后的值为 7->8 如果list = 2->5->7->8->10 + * ,删除以后的值为7,8,10 + */ + public void removeFirstHalf() { + + } + + /** + * 从第i个元素开始, 删除length 个元素 , 注意i从0开始 + * + * @param i + * @param length + */ + public void remove(int i, int length) { + + } + + /** + * 假定当前链表和list均包含已升序排列的整数 从当前链表中取出那些list所指定的元素 例如当前链表 = + * 11->101->201->301->401->501->601->701 listB = 1->3->4->6 + * 返回的结果应该是[101,301,401,601] + * + * @param list + */ + public static int[] getElements(LinkedList list) { + return null; + } + + /** + * 已知链表中的元素以值递增有序排列,并以单链表作存储结构。 从当前链表中中删除在list中出现的元素 + * + * @param list + */ + + public void subtract(LinkedList list) { + + } + + /** + * 已知当前链表中的元素以值递增有序排列,并以单链表作存储结构。 删除表中所有值相同的多余元素(使得操作后的线性表中所有元素的值均不相同) + */ + public void removeDuplicateValues() { + + } + + /** + * 已知链表中的元素以值递增有序排列,并以单链表作存储结构。 试写一高效的算法,删除表中所有值大于min且小于max的元素(若表中存在这样的元素) + * + * @param min + * @param max + */ + public void removeRange(int min, int max) { + + } + + /** + * 假设当前链表和参数list指定的链表均以元素依值递增有序排列(同一表中的元素值各不相同) + * 现要求生成新链表C,其元素为当前链表和list中元素的交集,且表C中的元素有依值递增有序排列 + * + * @param list + */ + public LinkedList intersection(LinkedList list) { + return null; + } +} diff --git a/group26/2411685663/src/nishuibaichuan/homework/first/List.java b/group26/2411685663/src/nishuibaichuan/homework/first/List.java new file mode 100644 index 0000000000..ca9279d5fc --- /dev/null +++ b/group26/2411685663/src/nishuibaichuan/homework/first/List.java @@ -0,0 +1,13 @@ +package nishuibaichuan.homework.first; + +public interface List { + public void add(Object o); + + public void add(int index, Object o); + + public Object get(int index); + + public Object remove(int index); + + public int size(); +} diff --git a/group26/2411685663/src/nishuibaichuan/homework/first/Queue.java b/group26/2411685663/src/nishuibaichuan/homework/first/Queue.java new file mode 100644 index 0000000000..cf7798678d --- /dev/null +++ b/group26/2411685663/src/nishuibaichuan/homework/first/Queue.java @@ -0,0 +1,19 @@ +package nishuibaichuan.homework.first; + +public class Queue { + + public void enQueue(Object o) { + } + + public Object deQueue() { + return null; + } + + public boolean isEmpty() { + return false; + } + + public int size() { + return -1; + } +} diff --git a/group26/2411685663/src/nishuibaichuan/homework/first/Stack.java b/group26/2411685663/src/nishuibaichuan/homework/first/Stack.java new file mode 100644 index 0000000000..8d9a2f8a0a --- /dev/null +++ b/group26/2411685663/src/nishuibaichuan/homework/first/Stack.java @@ -0,0 +1,24 @@ +package nishuibaichuan.homework.first; + +public class Stack { + private ArrayList elementData = new ArrayList(); + + public void push(Object o) { + } + + public Object pop() { + return null; + } + + public Object peek() { + return null; + } + + public boolean isEmpty() { + return false; + } + + public int size() { + return -1; + } +} diff --git a/group26/2411685663/src/nishuibaichuan/homework/first/TestArrayList.java b/group26/2411685663/src/nishuibaichuan/homework/first/TestArrayList.java new file mode 100644 index 0000000000..b992de37ee --- /dev/null +++ b/group26/2411685663/src/nishuibaichuan/homework/first/TestArrayList.java @@ -0,0 +1,48 @@ +package nishuibaichuan.homework.first; + +import static org.junit.Assert.*; + +import org.junit.Assert; +import org.junit.Test; + +/** + * @Desc: () + * @date: 2017年3月12日 下午7:00:22 + * @email:2411685663@qq.com + */ +@SuppressWarnings("unused") +public class TestArrayList { + + private ArrayList arrayList = new ArrayList(); + + @Test + public void testAll() { + arrayList.add(0); + arrayList.add(1); + arrayList.add(2); + arrayList.add(3); + arrayList.add(4); + arrayList.add(5); + arrayList.add(6); + + Assert.assertEquals(arrayList.size(), 7); + Assert.assertEquals(arrayList.get(1), 1); + System.out.println(arrayList.get(3)); + + arrayList.add(0, 100); + Assert.assertEquals(arrayList.size(), 8); + Assert.assertEquals(arrayList.get(0), 100); + + arrayList.remove(0); + Assert.assertEquals(arrayList.size(), 7); + Assert.assertEquals(arrayList.get(0), 0); + + Iterator iterator = arrayList.iterator(); + while(iterator.hasNext()){ + iterator.next(); + iterator.remove(); + } + Assert.assertEquals(arrayList.size(), 0); + } + +} diff --git "a/group26/26\347\273\204\346\203\205\345\206\265\347\273\237\350\256\241.md" "b/group26/26\347\273\204\346\203\205\345\206\265\347\273\237\350\256\241.md" index a1f2d56510..a38b933f0f 100644 --- "a/group26/26\347\273\204\346\203\205\345\206\265\347\273\237\350\256\241.md" +++ "b/group26/26\347\273\204\346\203\205\345\206\265\347\273\237\350\256\241.md" @@ -1,18 +1,23 @@ -| | | | | | | -| -------------------- | :-------------------: | ---- | ---- | ---- | ---- | -| 抓狂 | 作业1 | | | | | -| | 文章1 | | | | | -| 723161901 | 已完成 | | | | | -| | | | | | | -| jiaxun1990(89460886) | 已完成 | | | | | -| | https://goo.gl/Wvz3Od | | | | | -| 1515345281 | 已完成 | | | | | -| | | | | | | -| 2070509107 | 已完成 | | | | | -| | | | | | | -| lizhy2017 | 部分完成 | | | | | -| | | | | | | -| | | | | | | -| | | | | | | -| | | | | | | -| | | | | | | \ No newline at end of file +| | | | | | | +| -------------------- | :--------------------------------------: | ---- | ---- | ---- | ---- | +| 抓狂 | 作业1 | | | | | +| | 文章1 | | | | | +| 723161901 | 已完成 | | | | | +| | | | | | | +| jiaxun1990(89460886) | 已完成 | | | | | +| | https://goo.gl/Wvz3Od | | | | | +| 1515345281 | 已完成 | | | | | +| | | | | | | +| 2070509107 | 已完成 | | | | | +| | | | | | | +| lizhy2017 | 部分完成 | | | | | +| | | | | | | +| JEE-逆水百川 | 部分完成 | | | | | +| | http://blog.csdn.net/u012759397/article/details/61618612 | | | | | +| | | | | | | +| | | | | | | +| | | | | | | +| | | | | | | +| | | | | | | +| | | | | | | +| | | | | | | \ No newline at end of file