Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions group14/641013587/14_641013587/.classpath
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/4"/>
<classpathentry kind="output" path="bin"/>
</classpath>
1 change: 1 addition & 0 deletions group14/641013587/14_641013587/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/bin/
17 changes: 17 additions & 0 deletions group14/641013587/14_641013587/.project
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>14_641013587</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>
Original file line number Diff line number Diff line change
@@ -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
79 changes: 79 additions & 0 deletions group14/641013587/14_641013587/src/com/coding/basic/ArrayList.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
package com.coding.basic;

public class ArrayList implements List {

private int size = 0;

private Object[] elementData = new Object[100];

public void add(Object o){
//�ҳ����һ���յ�λ�ø�ֵ
for(int i=0;i<elementData.length;i++){
if(elementData[i]==null){
elementData[i]=o;
break;
}
if(i==elementData.length){
this.expansion();
elementData[i]=o;
break;
}
}
size++;

}

private void expansion(){
Object[] newElementData = new Object[this.elementData.length+10];
System.arraycopy(elementData, 0, newElementData, 0, elementData.length-1);
this.elementData=newElementData;
}

public void add(int index, Object o){
if(elementData.length<=size){
expansion();
}
System.arraycopy(elementData,index,elementData,index+1,size);
elementData[index]=o;
size++;
}

public Object get(int index){
if(index>=size){
return this.elementData[elementData.length];
}else{
return this.elementData[index];
}
}

public Object remove(int index){
Object object = get(index);
System.arraycopy(elementData,index+1,elementData,index,size-1);
elementData[size-1]=null;
size--;
return object;
}

public int size(){
return size;
}

public Iterator iterator(){

return new Iterator() {

private int nextNum=0;

@Override
public Object next() {
return get(nextNum++);
}

@Override
public boolean hasNext() {
return nextNum>=size?false:true;
}
};
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package com.coding.basic;

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;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package com.coding.basic;

public interface Iterator {
public boolean hasNext();
public Object next();

}
123 changes: 123 additions & 0 deletions group14/641013587/14_641013587/src/com/coding/basic/LinkedList.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
package com.coding.basic;

public class LinkedList implements List {

private Node head=new Node();

public void add(Object o){
if(head.data==null){
head.data=o;
return;
}
Node node=head;
for(;node.next!=null;){
node=node.next;
}
node.next=new Node();
node.next.data=o;

}
public void add(int index , Object o){
if(index==0){
addFirst(o);
return;
}
Node node=head;
for(int i=0;i<index;i++){
node=node.next;
if(node==null){
node=new Node();
}

}
node.data=o;
return;
}
public Object get(int index){
Node node=head;
for(int i=0;i<index;i++){
node=node.next;
}
return node.data;
}
public Object remove(int index){
if(index==0){
Object data=head.data;
removeFirst();
return data;
}
Node node=head;
for(int i=0;i<index-1;i++){
node=node.next;
}
Object data=node.next.data;
node.next=node.next.next;
return data;
}

public int size(){
int i =0;
Node node=head;
while (node!=null) {
node=node.next;
i++;
}
return i;
}

public void addFirst(Object o){
Node node = new Node();
node.data=o;
node.next=head;
head=node;
}
public void addLast(Object o){
add(o);
}
public Object removeFirst(){
Object data=head.data;
head=head.next;
if(head==null){
head=new Node();
}
return data;
}
public Object removeLast(){
Object data = null;
Node node=head;
for(;node.next!=null;){
if(node.next.next==null){
data=node.next.next;
node.next=node.next.next;
break;
}
node=node.next;
}
return data;
}
public Iterator iterator(){
return new Iterator() {

Node node=head;

@Override
public Object next() {
Object data=node.data;
node=node.next;
return data;
}

@Override
public boolean hasNext() {
return node==null?false:true;
}
};
}


private static class Node{
Object data;
Node next;

}
}
9 changes: 9 additions & 0 deletions group14/641013587/14_641013587/src/com/coding/basic/List.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package com.coding.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();
}
19 changes: 19 additions & 0 deletions group14/641013587/14_641013587/src/com/coding/basic/Queue.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package com.coding.basic;

public class Queue {

public void enQueue(Object o){
}

public Object deQueue(){
return null;
}

public boolean isEmpty(){
return false;
}

public int size(){
return -1;
}
}
25 changes: 25 additions & 0 deletions group14/641013587/14_641013587/src/com/coding/basic/Stack.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package com.coding.basic;

public class Stack {
private ArrayList elementData = new ArrayList();

public void push(Object o){
elementData.add(0, o);
}

public Object pop(){
Object object = elementData.get(0);
elementData.remove(0);
return object;
}

public Object peek(){
return elementData.get(0);
}
public boolean isEmpty(){
return elementData.size()==0?true:false;
}
public int size(){
return elementData.size();
}
}
Loading