几种常见的数据结构的JAVA实现
ITree
package utility.structure.def;
/**
*
* @author odie.tang
*
* @version 1.0 10/30/09
*/
public interface ITree<E>{
E getData();
E remove();
void setData(E e);
int getDepth();
int getLevel();
ITree<E> getRoot();
ITree<E> getParent();
ITree<E> getFirstChild();
ITree<E> addFirtChild(E e);
ITree<E> getLastChild();
ITree<E> addLastChild(E e);
ITree<E> getNode(E e);
boolean isLeaf();
boolean isRoot();
boolean remove(E e);
}
IBinaryTree
package utility.structure.def;
public interface IBinaryTree<E> extends ITree<E>{
boolean hasLeftChild();
boolean isLeftChild();
IBinaryTree<E> getLeftChild();
IBinaryTree<E> addLeftChild(E e);
boolean hasRightChild();
boolean isRightChild();
IBinaryTree<E> getRightChild();
IBinaryTree<E> addRightChild(E e);
}
BinaryTree
package utility.structure;
import java.io.Serializable;
import java.util.ConcurrentModificationException;
import utility.structure.def.IBinaryTree;
import utility.structure.def.ITree;
/**
*
* @author odie.tang
*
* @since 1.0 11/01/09
*/
public class BinaryTree<E> implements IBinaryTree<E>,Serializable{
private static final long serialVersionUID = 1565285530988892541L;
private E data;
private BinaryTree<E> parent = null;
private BinaryTree<E> leftChild = null;
private BinaryTree<E> rightChild = null;
private int level;
private enum Child{left,right}
public BinaryTree(E root) {
this.data = root;
this.level = 1;
}
public BinaryTree(E root, E leftChild){
this.data = root;
this.level = 1;
new BinaryTree<E>(this,Child.left,leftChild);
}
public BinaryTree(E root, E leftChild,E rightChild){
this.data = root;
this.level = 1;
new BinaryTree<E>(this,Child.left,leftChild);
new BinaryTre
相关文档:
到http://download.csdn.net/source/1781441下载JLDAP.jar文件
验证代码段如下:
DirContext ctx = null;
String account = "aa"; //用户名
String password = "123"; //登录密码
String root = "dc=scut,dc=edu,dc=cn"; // root
Hashtable env = new Hashtable() ......
import java.io.File;
import java.io.IOException;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import jxl.Workbook;
import jxl.format.Alignment;
import jxl.format.Border;
import jxl.format.BorderLineStyle;
......
比如applet文件是AppletTest.class
1)
在AppletTest.java的代码中
使用默认包,即不用package语句
在html页中的代码是
<applet code="AppletTest.class" width="400" height="300">
</applet>
AppletTest.class文件和html页放在一个文件夹中
2)
在AppletTest.java的代码中
package xx.yy;
在html页 ......
把树形的结构抽象了一下。
ITree
package utility.structure.def;
/**
*
* @author odie.tang
*
* @version 1.0 10/30/09
*/
public interface ITree<E>{
E getData();
E remove();
void setData(E e);
int getDepth();
int getLevel();
ITree<E> getRoot();
......