diff --git "a/group14/1091149131/20170226_\344\275\234\344\270\2321_\346\225\260\346\215\256\347\273\223\346\236\204\345\217\212\346\226\207\347\253\240/basicstructuredemo/.classpath" "b/group14/1091149131/20170226_\344\275\234\344\270\2321_\346\225\260\346\215\256\347\273\223\346\236\204\345\217\212\346\226\207\347\253\240/basicstructuredemo/.classpath" new file mode 100644 index 0000000000..373dce4005 --- /dev/null +++ "b/group14/1091149131/20170226_\344\275\234\344\270\2321_\346\225\260\346\215\256\347\273\223\346\236\204\345\217\212\346\226\207\347\253\240/basicstructuredemo/.classpath" @@ -0,0 +1,7 @@ + + + + + + + diff --git "a/group14/1091149131/20170226_\344\275\234\344\270\2321_\346\225\260\346\215\256\347\273\223\346\236\204\345\217\212\346\226\207\347\253\240/basicstructuredemo/.gitignore" "b/group14/1091149131/20170226_\344\275\234\344\270\2321_\346\225\260\346\215\256\347\273\223\346\236\204\345\217\212\346\226\207\347\253\240/basicstructuredemo/.gitignore" new file mode 100644 index 0000000000..ae3c172604 --- /dev/null +++ "b/group14/1091149131/20170226_\344\275\234\344\270\2321_\346\225\260\346\215\256\347\273\223\346\236\204\345\217\212\346\226\207\347\253\240/basicstructuredemo/.gitignore" @@ -0,0 +1 @@ +/bin/ diff --git "a/group14/1091149131/20170226_\344\275\234\344\270\2321_\346\225\260\346\215\256\347\273\223\346\236\204\345\217\212\346\226\207\347\253\240/basicstructuredemo/.project" "b/group14/1091149131/20170226_\344\275\234\344\270\2321_\346\225\260\346\215\256\347\273\223\346\236\204\345\217\212\346\226\207\347\253\240/basicstructuredemo/.project" new file mode 100644 index 0000000000..194f47da7a --- /dev/null +++ "b/group14/1091149131/20170226_\344\275\234\344\270\2321_\346\225\260\346\215\256\347\273\223\346\236\204\345\217\212\346\226\207\347\253\240/basicstructuredemo/.project" @@ -0,0 +1,17 @@ + + + basicstructuredemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git "a/group14/1091149131/20170226_\344\275\234\344\270\2321_\346\225\260\346\215\256\347\273\223\346\236\204\345\217\212\346\226\207\347\253\240/basicstructuredemo/.settings/org.eclipse.jdt.core.prefs" "b/group14/1091149131/20170226_\344\275\234\344\270\2321_\346\225\260\346\215\256\347\273\223\346\236\204\345\217\212\346\226\207\347\253\240/basicstructuredemo/.settings/org.eclipse.jdt.core.prefs" new file mode 100644 index 0000000000..3a21537071 --- /dev/null +++ "b/group14/1091149131/20170226_\344\275\234\344\270\2321_\346\225\260\346\215\256\347\273\223\346\236\204\345\217\212\346\226\207\347\253\240/basicstructuredemo/.settings/org.eclipse.jdt.core.prefs" @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git "a/group14/1091149131/20170226_\344\275\234\344\270\2321_\346\225\260\346\215\256\347\273\223\346\236\204\345\217\212\346\226\207\347\253\240/basicstructuredemo/src/com/maple/basic/ArrayList.java" "b/group14/1091149131/20170226_\344\275\234\344\270\2321_\346\225\260\346\215\256\347\273\223\346\236\204\345\217\212\346\226\207\347\253\240/basicstructuredemo/src/com/maple/basic/ArrayList.java" new file mode 100644 index 0000000000..f6d3b4c44a --- /dev/null +++ "b/group14/1091149131/20170226_\344\275\234\344\270\2321_\346\225\260\346\215\256\347\273\223\346\236\204\345\217\212\346\226\207\347\253\240/basicstructuredemo/src/com/maple/basic/ArrayList.java" @@ -0,0 +1,66 @@ +package com.maple.basic; + +public class ArrayList implements List { + + private int size = 0; + + private Object[] elementData = new Object[100]; + + public void add(Object o){ + //不够了怎么扩容 + elementData[size++]=o; + } + public void add(int index, Object o){ + if(index<0||index>size){ + throw new IndexOutOfBoundsException("Joy Index "+index+", Size: "+size); + } + for(int i=size;i>index;i--){ + elementData[i-1]=elementData[i]; + } + elementData[index]=o; + size++; + } + + public Object get(int index){ + if(index<0||index>=size){ + throw new IndexOutOfBoundsException("Joy Index "+index+", Size: "+size); + } + return elementData[index]; + } + + public Object remove(int index){ + if(index<0||index>=size){ + throw new IndexOutOfBoundsException("Joy Index "+index+", Size: "+size); + } + Object removeObj=elementData[index]; + for(int i=index;i=size) return false; + return true; + } + }; + } + +} diff --git "a/group14/1091149131/20170226_\344\275\234\344\270\2321_\346\225\260\346\215\256\347\273\223\346\236\204\345\217\212\346\226\207\347\253\240/basicstructuredemo/src/com/maple/basic/BinaryTree.java" "b/group14/1091149131/20170226_\344\275\234\344\270\2321_\346\225\260\346\215\256\347\273\223\346\236\204\345\217\212\346\226\207\347\253\240/basicstructuredemo/src/com/maple/basic/BinaryTree.java" new file mode 100644 index 0000000000..5e63cf4d3c --- /dev/null +++ "b/group14/1091149131/20170226_\344\275\234\344\270\2321_\346\225\260\346\215\256\347\273\223\346\236\204\345\217\212\346\226\207\347\253\240/basicstructuredemo/src/com/maple/basic/BinaryTree.java" @@ -0,0 +1,45 @@ +package com.maple.basic; + +import org.omg.PortableInterceptor.ORBInitInfoPackage.DuplicateName; + +public class BinaryTree> { + private BinaryTreeNode root; + + public void traversal(BinaryTreeNode node){ + if(node.getLeft()!=null){ + traversal(node.getLeft()); + } + System.out.println("--"+node.getData()+"--"); + if(node.getRight()!=null){ + traversal(node.getRight()); + } + } + /** + * 如果根节点为null,则作为根节点,否则遍历下去插值 + * @param o + * @return + * 2017年2月23日 下午4:21:51 + * @Author Joy + */ + public BinaryTreeNode insert(T o){ + if(root==null){ + BinaryTreeNode newB=new BinaryTreeNode(); + newB.setData(o); + newB.setLeft(null); + newB.setRight(null); + root=newB; + return root; + } + + return root.insert(o); + } + public BinaryTreeNode getRoot() { + return root; + } + + public void setRoot(BinaryTreeNode root) { + this.root = root; + } + + +} diff --git "a/group14/1091149131/20170226_\344\275\234\344\270\2321_\346\225\260\346\215\256\347\273\223\346\236\204\345\217\212\346\226\207\347\253\240/basicstructuredemo/src/com/maple/basic/BinaryTreeNode.java" "b/group14/1091149131/20170226_\344\275\234\344\270\2321_\346\225\260\346\215\256\347\273\223\346\236\204\345\217\212\346\226\207\347\253\240/basicstructuredemo/src/com/maple/basic/BinaryTreeNode.java" new file mode 100644 index 0000000000..f702d48922 --- /dev/null +++ "b/group14/1091149131/20170226_\344\275\234\344\270\2321_\346\225\260\346\215\256\347\273\223\346\236\204\345\217\212\346\226\207\347\253\240/basicstructuredemo/src/com/maple/basic/BinaryTreeNode.java" @@ -0,0 +1,69 @@ +package com.maple.basic; + +import org.omg.PortableInterceptor.ORBInitInfoPackage.DuplicateName; + +public class BinaryTreeNode>{ + + private T data; + private BinaryTreeNode left; + private BinaryTreeNode right; + + /** + * 如果待插入的值等于节点的值,则抛出异常:duplicate value + * 如果小于节点的值,则往左边遍历 + * 如果大于节点的值,则往右边遍历 + * @param o + * @return + * 2017年2月23日 下午4:22:50 + * @Author Joy + */ + public BinaryTreeNode insert(T o){ + //assume that no duplicate key + + if(o.compareTo(data)==0){ + try { + throw new DuplicateName("duplicate value: "+o); + } catch (DuplicateName e) { + e.printStackTrace(); + } + } + BinaryTreeNode newB=new BinaryTreeNode(); + newB.setData(o); + newB.setLeft(null); + newB.setRight(null); + //o更大,在右边 + if(o.compareTo(data)>0){ + if(this.getRight()!=null){ + this.getRight().insert(o); + }else{ + this.setRight(newB); + } + }else if(o.compareTo(data)<0){ + if(this.getLeft()!=null){ + this.getLeft().insert(o); + }else{ + this.setLeft(newB); + } + } + return newB; + } + + public T getData() { + return data; + } + public void setData(T 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; + } +} diff --git "a/group14/1091149131/20170226_\344\275\234\344\270\2321_\346\225\260\346\215\256\347\273\223\346\236\204\345\217\212\346\226\207\347\253\240/basicstructuredemo/src/com/maple/basic/Iterator.java" "b/group14/1091149131/20170226_\344\275\234\344\270\2321_\346\225\260\346\215\256\347\273\223\346\236\204\345\217\212\346\226\207\347\253\240/basicstructuredemo/src/com/maple/basic/Iterator.java" new file mode 100644 index 0000000000..ac8ecd6050 --- /dev/null +++ "b/group14/1091149131/20170226_\344\275\234\344\270\2321_\346\225\260\346\215\256\347\273\223\346\236\204\345\217\212\346\226\207\347\253\240/basicstructuredemo/src/com/maple/basic/Iterator.java" @@ -0,0 +1,7 @@ +package com.maple.basic; + +public interface Iterator { + public boolean hasNext(); + public Object next(); + +} diff --git "a/group14/1091149131/20170226_\344\275\234\344\270\2321_\346\225\260\346\215\256\347\273\223\346\236\204\345\217\212\346\226\207\347\253\240/basicstructuredemo/src/com/maple/basic/LinkedList.java" "b/group14/1091149131/20170226_\344\275\234\344\270\2321_\346\225\260\346\215\256\347\273\223\346\236\204\345\217\212\346\226\207\347\253\240/basicstructuredemo/src/com/maple/basic/LinkedList.java" new file mode 100644 index 0000000000..d957f74bdc --- /dev/null +++ "b/group14/1091149131/20170226_\344\275\234\344\270\2321_\346\225\260\346\215\256\347\273\223\346\236\204\345\217\212\346\226\207\347\253\240/basicstructuredemo/src/com/maple/basic/LinkedList.java" @@ -0,0 +1,154 @@ +package com.maple.basic; + +import java.util.NoSuchElementException; + +public class LinkedList implements List { + + private Node head; + private int size = 0;//自己加的,觉得需要 + /** + * 与addList()是一样的 + */ + public void add(Object o){ + addLast(o); + } + public void add(int index , Object o){ + if(index<0||index>size){ + throw new IndexOutOfBoundsException("Joy Index "+index+", Size: "+size); + } + Node prevNode=head; + Node curNode=head.next; + int count=0; + while(count<=index){ + if(count==index){ + Node newNode=new Node(); + newNode.data=o; + + newNode.next=curNode; + prevNode.next=newNode; + size++; + break; + } + curNode=curNode.next; + prevNode=prevNode.next; + count++; + } + + + } + public Object get(int index){ + if(index<0||index>=size) + throw new IndexOutOfBoundsException("Joy Index "+index+", Size: "+size); + + Node curNode=head.next; + int count=0; + while(count<=index){ + if(count==index){ + return curNode.data; + } + curNode=curNode.next; + count++; + } + return null; + } + public Object remove(int index){ + if(index<0||index>=size) + throw new IndexOutOfBoundsException("Joy Index "+index+", Size: "+size); + Node prevNode=head; + Node curNode=head.next; + int count=0; + while(count<=index){ + if(count==index){ + prevNode.next=curNode.next; + size--; + return curNode.data; + } + curNode=curNode.next; + prevNode=prevNode.next; + count++; + } + return null; + } + + public int size(){ + return size; + } + + public void addFirst(Object o){ + Node objNode=new Node(); + objNode.data=o; + if(head==null) head=new Node(); + objNode.next=head.next; + size++; + head.next=objNode; + } + public void addLast(Object o){ + Node objNode=new Node(); + objNode.data=o; + if(head==null) head=new Node(); + + //也可以用iterator迭代,先不用吧 + Node curNode=head; + while(curNode.next!=null){ + curNode=curNode.next; + } + objNode.next=curNode.next; + curNode.next=objNode; + size++; + + } + public Object removeFirst(){ + if(head==null||head.next==null) + throw new NoSuchElementException(); + Node delNode=head.next; + head.next=delNode.next; + size--; + return delNode.data; + } + public Object removeLast(){ + if(head==null||head.next==null) + throw new NoSuchElementException(); + Node prevNode=head; + Node curNode=head.next; + while(curNode!=null){ + if(curNode.next==null){//说明是尾节点 + prevNode.next=curNode.next; + size--; + return curNode.data; + } + curNode=curNode.next; + prevNode=prevNode.next; + } + return null; + } + public Iterator iterator(){ + return new Iterator() { + private Node cur=head!=null?head.next:head; + @Override + public Object next() { + if(cur==null){ + throw new NoSuchElementException(); + } + Object object=cur.data; + cur=cur.next; + return object; + } + + @Override + public boolean hasNext() { + if(cur==null){ + return false; + }else{ + return true; + } + + } + }; + } + + + private static class Node{ + Object data; + Node next; + } +} diff --git "a/group14/1091149131/20170226_\344\275\234\344\270\2321_\346\225\260\346\215\256\347\273\223\346\236\204\345\217\212\346\226\207\347\253\240/basicstructuredemo/src/com/maple/basic/List.java" "b/group14/1091149131/20170226_\344\275\234\344\270\2321_\346\225\260\346\215\256\347\273\223\346\236\204\345\217\212\346\226\207\347\253\240/basicstructuredemo/src/com/maple/basic/List.java" new file mode 100644 index 0000000000..99bed9d96b --- /dev/null +++ "b/group14/1091149131/20170226_\344\275\234\344\270\2321_\346\225\260\346\215\256\347\273\223\346\236\204\345\217\212\346\226\207\347\253\240/basicstructuredemo/src/com/maple/basic/List.java" @@ -0,0 +1,9 @@ +package com.maple.basic; + +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/group14/1091149131/20170226_\344\275\234\344\270\2321_\346\225\260\346\215\256\347\273\223\346\236\204\345\217\212\346\226\207\347\253\240/basicstructuredemo/src/com/maple/basic/Queue.java" "b/group14/1091149131/20170226_\344\275\234\344\270\2321_\346\225\260\346\215\256\347\273\223\346\236\204\345\217\212\346\226\207\347\253\240/basicstructuredemo/src/com/maple/basic/Queue.java" new file mode 100644 index 0000000000..278d3dba7f --- /dev/null +++ "b/group14/1091149131/20170226_\344\275\234\344\270\2321_\346\225\260\346\215\256\347\273\223\346\236\204\345\217\212\346\226\207\347\253\240/basicstructuredemo/src/com/maple/basic/Queue.java" @@ -0,0 +1,21 @@ +package com.maple.basic; + +public class Queue { + private LinkedList elementData=new LinkedList(); + public void enQueue(Object o){ + elementData.addLast(o); + } + + public Object deQueue(){ + Object first=elementData.removeFirst(); + return first; + } + + public boolean isEmpty(){ + return elementData.size()<=0; + } + + public int size(){ + return elementData.size(); + } +} diff --git "a/group14/1091149131/20170226_\344\275\234\344\270\2321_\346\225\260\346\215\256\347\273\223\346\236\204\345\217\212\346\226\207\347\253\240/basicstructuredemo/src/com/maple/basic/Stack.java" "b/group14/1091149131/20170226_\344\275\234\344\270\2321_\346\225\260\346\215\256\347\273\223\346\236\204\345\217\212\346\226\207\347\253\240/basicstructuredemo/src/com/maple/basic/Stack.java" new file mode 100644 index 0000000000..cec4599237 --- /dev/null +++ "b/group14/1091149131/20170226_\344\275\234\344\270\2321_\346\225\260\346\215\256\347\273\223\346\236\204\345\217\212\346\226\207\347\253\240/basicstructuredemo/src/com/maple/basic/Stack.java" @@ -0,0 +1,26 @@ +package com.maple.basic; + +public class Stack { + private ArrayList elementData = new ArrayList(); + + public void push(Object o){ + elementData.add(o); + } + + public Object pop(){ + Object object=elementData.get(elementData.size()-1); + elementData.remove(elementData.size()-1); + return object; + } + + public Object peek(){ + Object object=elementData.get(elementData.size()-1); + return object; + } + public boolean isEmpty(){ + return elementData.size()<=0; + } + public int size(){ + return elementData.size(); + } +} diff --git "a/group14/1091149131/20170226_\344\275\234\344\270\2321_\346\225\260\346\215\256\347\273\223\346\236\204\345\217\212\346\226\207\347\253\240/basicstructuredemo/src/com/maple/test/TestAPIDemo.java" "b/group14/1091149131/20170226_\344\275\234\344\270\2321_\346\225\260\346\215\256\347\273\223\346\236\204\345\217\212\346\226\207\347\253\240/basicstructuredemo/src/com/maple/test/TestAPIDemo.java" new file mode 100644 index 0000000000..ee592fbb7b --- /dev/null +++ "b/group14/1091149131/20170226_\344\275\234\344\270\2321_\346\225\260\346\215\256\347\273\223\346\236\204\345\217\212\346\226\207\347\253\240/basicstructuredemo/src/com/maple/test/TestAPIDemo.java" @@ -0,0 +1,53 @@ +package com.maple.test; + +import java.util.ArrayList; +import java.util.Iterator; +import java.util.LinkedList; +import java.util.Queue; +import java.util.Stack; + + +/** + * 测试Java中的API + * @author group 14, QQ:1091149131 + */ +public class TestAPIDemo { + public static void main(String[] args) { + + //Stack + /*Stack stack=new Stack(); + stack.push(0); + stack.push(1); + stack.push(2); + System.out.println(stack.peek()); + System.out.println(stack.pop()); + System.out.println(stack.peek());*/ + + //LinkedList + /*LinkedList list2=new LinkedList<>(); + list2.add(0); + list2.add(1); + list2.add(2); + + list2.addLast(3); + list2.remove(0); + //list2.removeFirst(); + Iterator ite2=list2.iterator(); + ite2.next(); + while(ite2.hasNext()){ + System.out.println(ite2.next()); + }*/ + + + //ArrayList + /*ArrayList list1=new ArrayList(); + list1.add(0); + list1.add(1); + //list1.add(3, -1);//error + //list1.remove(2);//error + Iterator ite=list1.iterator(); + while(ite.hasNext()){ + System.out.println(ite.next()); + }*/ + } +} diff --git "a/group14/1091149131/20170226_\344\275\234\344\270\2321_\346\225\260\346\215\256\347\273\223\346\236\204\345\217\212\346\226\207\347\253\240/basicstructuredemo/src/com/maple/test/TestAll.java" "b/group14/1091149131/20170226_\344\275\234\344\270\2321_\346\225\260\346\215\256\347\273\223\346\236\204\345\217\212\346\226\207\347\253\240/basicstructuredemo/src/com/maple/test/TestAll.java" new file mode 100644 index 0000000000..9fd59e512e --- /dev/null +++ "b/group14/1091149131/20170226_\344\275\234\344\270\2321_\346\225\260\346\215\256\347\273\223\346\236\204\345\217\212\346\226\207\347\253\240/basicstructuredemo/src/com/maple/test/TestAll.java" @@ -0,0 +1,71 @@ +package com.maple.test; + +import org.junit.Test; + +import com.maple.basic.ArrayList; +import com.maple.basic.BinaryTree; +import com.maple.basic.Iterator; +import com.maple.basic.LinkedList; +import com.maple.basic.Queue; +import com.maple.basic.Stack; + +public class TestAll { + @Test + public void testArrayList(){ + ArrayList list1=new ArrayList(); + list1.add(0); + list1.add(1); + //list1.add(3, -1);//error + //list1.remove(2);//error + Iterator ite=list1.iterator(); + while(ite.hasNext()){ + System.out.println(ite.next()); + } + } + @Test + public void testLinkedList(){ + LinkedList list2=new LinkedList(); + list2.add(0); + list2.add(1); + list2.addFirst(-1); + list2.addLast(-2); + + list2.removeFirst(); + list2.removeLast(); + list2.remove(0); + + Iterator ite2=list2.iterator(); + while(ite2.hasNext()){ + System.out.println(ite2.next()); + } + } + @Test + public void testStack(){ + Stack stack=new Stack(); + stack.push(0); + stack.push(1); + stack.push(2); + System.out.println(stack.peek()); + System.out.println(stack.pop()); + System.out.println(stack.peek()); + } + @Test + public void testQueue(){ + Queue queue=new Queue(); + queue.enQueue(0); + queue.enQueue(1); + + System.out.println(queue.deQueue()); + } + @Test + public void testBinaryTree(){ + BinaryTree tree=new BinaryTree<>(); + tree.insert(3); + tree.insert(2); + tree.insert(5); + //tree.insert(5);//error,duplicate + tree.insert(1); + tree.traversal(tree.getRoot()); + } + +} diff --git "a/group14/1091149131/20170226_\344\275\234\344\270\2321_\346\225\260\346\215\256\347\273\223\346\236\204\345\217\212\346\226\207\347\253\240/basicstructuredemo/src/com/maple/test/TestArrayList.java" "b/group14/1091149131/20170226_\344\275\234\344\270\2321_\346\225\260\346\215\256\347\273\223\346\236\204\345\217\212\346\226\207\347\253\240/basicstructuredemo/src/com/maple/test/TestArrayList.java" new file mode 100644 index 0000000000..94ecec52f7 --- /dev/null +++ "b/group14/1091149131/20170226_\344\275\234\344\270\2321_\346\225\260\346\215\256\347\273\223\346\236\204\345\217\212\346\226\207\347\253\240/basicstructuredemo/src/com/maple/test/TestArrayList.java" @@ -0,0 +1,22 @@ +package com.maple.test; + +import org.junit.Test; + +import com.maple.basic.ArrayList; +import com.maple.basic.Iterator; + +public class TestArrayList{ + + @Test + public void testAdd(){ + ArrayList list1=new ArrayList(); + list1.add(0); + list1.add(1); + //list1.add(3, -1);//error + //list1.remove(2);//error + Iterator ite=list1.iterator(); + while(ite.hasNext()){ + System.out.println(ite.next()); + } + } +} diff --git "a/group14/1091149131/20170226_\344\275\234\344\270\2321_\346\225\260\346\215\256\347\273\223\346\236\204\345\217\212\346\226\207\347\253\240/basicstructuredemo/src/com/maple/test/TestMyDemo.java" "b/group14/1091149131/20170226_\344\275\234\344\270\2321_\346\225\260\346\215\256\347\273\223\346\236\204\345\217\212\346\226\207\347\253\240/basicstructuredemo/src/com/maple/test/TestMyDemo.java" new file mode 100644 index 0000000000..639aaa629b --- /dev/null +++ "b/group14/1091149131/20170226_\344\275\234\344\270\2321_\346\225\260\346\215\256\347\273\223\346\236\204\345\217\212\346\226\207\347\253\240/basicstructuredemo/src/com/maple/test/TestMyDemo.java" @@ -0,0 +1,75 @@ +package com.maple.test; + +import com.maple.basic.ArrayList; +import com.maple.basic.BinaryTree; +import com.maple.basic.BinaryTreeNode; +import com.maple.basic.Iterator; +import com.maple.basic.LinkedList; +import com.maple.basic.Queue; +import com.maple.basic.Stack; + +/** + * 测试自己写的数据结构 + * @author group 14, QQ:1091149131 + */ +public class TestMyDemo { + public static void main(String[] args) { + //BinaryTree + BinaryTree tree=new BinaryTree<>(); + tree.insert(3); + tree.insert(2); + tree.insert(5); + //tree.insert(5);//error,duplicate + tree.insert(1); + tree.traversal(tree.getRoot()); + + + //Queue + /*Queue queue=new Queue(); + queue.enQueue(0); + queue.enQueue(1); + + System.out.println(queue.deQueue());*/ + + //Stack + /*Stack stack=new Stack(); + stack.push(0); + stack.push(1); + stack.push(2); + System.out.println(stack.peek()); + System.out.println(stack.pop()); + System.out.println(stack.peek());*/ + + //LinkedList + /*LinkedList list2=new LinkedList(); + list2.add(0); + list2.add(1); + list2.addFirst(-1); + list2.addLast(-2); + + list2.removeFirst(); + list2.removeLast(); + list2.remove(0); + + Iterator ite2=list2.iterator(); + while(ite2.hasNext()){ + System.out.println(ite2.next()); + }*/ + + + //ArrayList + /*ArrayList list1=new ArrayList(); + list1.add(0); + list1.add(1); + //list1.add(3, -1);//error + //list1.remove(2);//error + Iterator ite=list1.iterator(); + while(ite.hasNext()){ + System.out.println(ite.next()); + }*/ + + + + + } +} diff --git "a/group14/1091149131/20170226_\344\275\234\344\270\2321_\346\225\260\346\215\256\347\273\223\346\236\204\345\217\212\346\226\207\347\253\240/\346\226\207\347\253\240\351\223\276\346\216\245_20170224.txt" "b/group14/1091149131/20170226_\344\275\234\344\270\2321_\346\225\260\346\215\256\347\273\223\346\236\204\345\217\212\346\226\207\347\253\240/\346\226\207\347\253\240\351\223\276\346\216\245_20170224.txt" new file mode 100644 index 0000000000..1ecad55f85 --- /dev/null +++ "b/group14/1091149131/20170226_\344\275\234\344\270\2321_\346\225\260\346\215\256\347\273\223\346\236\204\345\217\212\346\226\207\347\253\240/\346\226\207\347\253\240\351\223\276\346\216\245_20170224.txt" @@ -0,0 +1,5 @@ +����CPU���ڴ棬 Ӳ�̣�ָ��֮��Ĺ�ϵ�� + +�������ӣ�http://www.cnblogs.com/qingmaple/p/6437070.html + +QQ��1091149131 ����-Ҷ�� \ No newline at end of file