Skip to content

Commit

Permalink
Merge pull request diliuzuzhanghao#7 from DonaldY/master
Browse files Browse the repository at this point in the history
第10周作业拉取
  • Loading branch information
sdnb authored May 14, 2017
2 parents 726db02 + ed5f2cb commit 6bb6bc2
Show file tree
Hide file tree
Showing 178 changed files with 7,497 additions and 2,184 deletions.
Original file line number Diff line number Diff line change
@@ -1,40 +1,39 @@
# Mobile Tools for Java (J2ME)
.mtj.tmp/

# Package Files
*.war
*.ear
*.bk
.gradle
target
*.class
*.real

# virtual machine crash logs
# see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*

# Eclipse Files #
.project
.classpath
.settings

# Idea
*.iml
*.ipr
*.iws
.idea

# log
*_IS_UNDEFINED
logs
*.log

# other
*.bak
.directory
.DS_Store


Test.java
example
# Mobile Tools for Java (J2ME)
.mtj.tmp/

# Package Files
*.war
*.ear
*.bk
.gradle
target
*.class
*.real

# virtual machine crash logs
# see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*

# Eclipse Files #
.project
.classpath
.settings

# Idea
*.iml
*.ipr
*.iws
.idea

# log
*_IS_UNDEFINED
logs
*.log

# other
*.bak
.directory
.DS_Store


Test.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
package me.lzb.basic;

import java.io.File;

/**
* 给定一个目录,递归的列出下面所有的子目录和文件
*
* @author LZB
*/
public class FileList {

public void list(File f) {
System.out.println(f.getPath());

list(f, 0);
}


private void list(File file, int level) {
if (file.isDirectory()) {
print(file, level);
}
level++;
File[] files = file.listFiles();
for (int i = 0; i < files.length; i++) {
if (files[i].isDirectory()) {
list(files[i], level);
} else {
print(files[i], level);
}
}
}

private void print(File f, int level) {
System.out.println(getFileFormat(level) + f.getName());

}


private String getFileFormat(int level) {
StringBuffer sb = new StringBuffer();
if (level > 1) {
sb.append("|");
}

for (int i = 0; i < level - 1; i++) {
sb.append(" ");
}
if (level > 0) {
sb.append("|--");
}
return sb.toString();
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package me.lzb.basic;
package me.lzb.basic.list;

/**
* 简易ArrayList
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package me.lzb.basic;
package me.lzb.basic.list;

public class ArrayUtil {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package me.lzb.basic;
package me.lzb.basic.list;

/**
* Created by LZB on 2017/3/11.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package me.lzb.basic;
package me.lzb.basic.list;


/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package me.lzb.basic;
package me.lzb.basic.list;

/**
* list接口
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package me.lzb.basic.queue;

import me.lzb.basic.LinkedList;
import me.lzb.basic.list.LinkedList;

/**
* 先进先出
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package me.lzb.basic.stack;

import me.lzb.basic.ArrayList;
import me.lzb.basic.list.ArrayList;

/**
* 先进后出
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
package me.lzb.basic;
package me.lzb.basic.tree;

/**
* 左边比父节点小,右边比父节点大
* Created by LZB on 2017/3/11.
*/
public class BinaryTreeNode {
public class BTNode {

private int data;
private BinaryTreeNode left;
private BinaryTreeNode right;
private BTNode left;
private BTNode right;

public BinaryTreeNode(int data){
public BTNode(int data){
this.data = data;
}

Expand All @@ -21,7 +21,7 @@ public int getData() {

//这层满了就下一层继续add,直到找到空位
public void add(int d){
BinaryTreeNode b = new BinaryTreeNode(d);
BTNode b = new BTNode(d);
if(compareTo(b)){
//比父节点小,左边
if(this.left == null){
Expand All @@ -42,7 +42,7 @@ public void add(int d){
}


public boolean compareTo(BinaryTreeNode node){
public boolean compareTo(BTNode node){
if(this.data > node.getData()){
return true;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package me.lzb.basic.tree;

/**
* @author LZB
*/
public class BinaryTreeNode<T> {
private T data;
private BinaryTreeNode<T> left;
private BinaryTreeNode<T> right;

public BinaryTreeNode(T data) {
this.data = data;
}

public T getData() {
return data;
}

public void setData(T data) {
this.data = data;
}

public BinaryTreeNode<T> getLeft() {
return left;
}

public void setLeft(BinaryTreeNode<T> left) {
this.left = left;
}

public BinaryTreeNode<T> getRight() {
return right;
}

public void setRight(BinaryTreeNode<T> right) {
this.right = right;
}

public BinaryTreeNode<T> insert(Object o) {
return null;
}

}
Loading

0 comments on commit 6bb6bc2

Please sign in to comment.