Skip to content

Commit

Permalink
Merge pull request #8 from lihhj/master
Browse files Browse the repository at this point in the history
20170226-176653813
  • Loading branch information
luoziyihao authored Feb 26, 2017
2 parents 9191dae + 893df80 commit b8ac309
Show file tree
Hide file tree
Showing 11 changed files with 345 additions and 0 deletions.
7 changes: 7 additions & 0 deletions group17/176653813/1766538130226Lesson/.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 group17/176653813/1766538130226Lesson/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/bin/
17 changes: 17 additions & 0 deletions group17/176653813/1766538130226Lesson/.project
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>1766538130226Lesson</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
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
package com.coding.basic;

public class ArrayList implements List {

private int size = 0;
private Object[] obj = new Object[5];

@Override
public void add(Object o) {
if(this.size < 0 )
System.out.print("Error");
this.extend(100);
obj[this.size] = o;
this.size ++;
}

@Override
public void add(int index, Object o) {

if(index < 0)
System.out.println("Error");
if(index < this.size){
extend(100);
for(int i = this.size;i < index; i--){
obj[i+1] = obj[i];
}
obj[index] = o;
}else if(index >= size){
extend(100);
obj[size] = o;
}
this.size++;
}

@Override
public Object get(int index) {
if(index < 0 || index > size){
System.out.println("Error");
return null;
}
return obj[index];
}

@Override
public Object remove(int index) {
if(index < 0 || index > size){
System.out.println("Error");
return null;
}
for(int i = index;i <= size;i++){
obj[i] = obj[i+1];
}
size--;
return obj[index];
}

@Override
public int size() {
return size;
}
public int length(){
return obj.length;
}
public void extend(int newLength){
if (this.size >= obj.length){
//À©Õ¹Êý×é
Object[] old = obj;
obj = new Object[size+newLength];
for(int i = 0;i < size; i++){
obj[i] = old[i];
}
}
return;
}
public void Iteror(){
for(int i = 0 ;i < size ; i++){
System.out.println(obj[i]);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
package com.coding.basic;

public class LinkList implements List{

private Node head; //头结点不计算个数
private static class Node{
Object data;
Node next;
}

@Override
public void add(Object o) {
//第一步没有想到
if(null == head){
head = new Node();
head.next = null;
head.data = o;
}else{
//尾插入法
//Node t = new Node();
Node t;
Node ins = new Node();
t = head;
while(t.next != null){
t = t.next;
}
t.next = ins;
ins.next = null;
ins.data = o;
}
}

@Override
public void add(int index, Object o) {
if(index < 0 ){
System.out.println("Error");
}else if(index == 0 || index == 1){
Node t = new Node();
t.next = head.next;
head.next = t;
t.data = o;
}else{
Node t = new Node();//当前节点
Node p = new Node();//前一个节点
t = head.next;
for(int i = 1;i < index;i++){
p = t;
t = t.next;
}
Node ins = new Node();
p.next = ins;
ins.next = t;
ins.data = o;
}

}

@Override
public Object get(int index) {
if(index < 0 || head == null){
System.out.println("Error");
return null;
}else{
Node t ;
t = head;
for(int i = 1;i < index;i++){
t = t.next;
}
return t.data;
}
}

@Override
public Object remove(int index) {

return null;
}

public void display(){
if(head == null){
System.out.println("No Data");
}else{
Node t ;
t = head;
while(t != null){
System.out.println("******"+t.data);
t = t.next;
}
}

}
@Override
public int size() {
return 0;
}
}
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();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package com.coding.basic;

public class Queue {

private LinkList elementData = new LinkList();
private int front = 0;
private int rear = 0;


public void enQueue(Object o){
elementData.add(o);
rear++;
}
public Object deQueue(){
if(!isEmpty()){
Object obj = elementData.remove(front);
front++;
return obj;
}else{
System.out.println("Queue is empty");
return null;
}
}
public boolean isEmpty(){
if(front > rear){
return true;
}
return false;
}

public int size(){
return rear-front+1;
}
}

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

public class Stack {

//
private ArrayList elementData = new ArrayList();
private int top = 0;

public void push(Object o){
elementData.add(o);
top++;
}

public Object pop(){
if(!isEmpty()){
System.out.println("stack is empoty");
return null;
}
Object obj = elementData.remove(top);
top--;
return obj;
}

public Object peek(){
return elementData.get(top);
}

public boolean isEmpty(){
if(top != 0){
return true;
}
return false;
}

public int size(){
return top++;
}



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

import static org.junit.Assert.*;

public class Test {

@org.junit.Test
public void test() {

/* ArrayList al = new ArrayList();
al.add(1);
al.add(2);
al.add(3);
al.add(4);
al.add(5);
al.add(200);
al.add(10,100);
al.Iteror();
//System.out.println(al.length());
//System.out.println(al.size());
System.out.println("==================");
al.remove(0);
al.Iteror();*/

LinkList ls = new LinkList();
ls.add(100);
ls.add(300);
ls.add(500);
ls.add(1000);
ls.add(3,2000);
ls.display();
System.out.println(ls.get(4));
}

}

12 changes: 12 additions & 0 deletions group17/176653813/RemoteSystemsTempFiles/.project
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>RemoteSystemsTempFiles</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
</buildSpec>
<natures>
<nature>org.eclipse.rse.ui.remoteSystemsTempNature</nature>
</natures>
</projectDescription>

0 comments on commit b8ac309

Please sign in to comment.