几种常见的数据结构的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://blog.csdn.net/ilibaba/archive/2009/03/07/3965359.aspx
被架构师问的面试题
1. 异常机制
异常机制是指当程序出现错误后,程序如何处理。具体来说,异常机制提供了程序退出的安全通道。当出现错误后,程序执行的流程发生改变,程序的控制权转移到异常处理器。
......
String和StringBuffer的区别,网上资料可以说是数不胜数,但是看到这篇文章,感觉里面做的小例子很有代表性,所以转一下,并自己做了一点总结。
在java中有3个类来负责字符的操作。
1.Character 是进行单个字符操作的,
2.String 对一串字符进行操作。不可变类。
3.StringBuffer 也是对一串字符进行操作,但是可 ......
Java中的事务处理
一般情况下,J2EE应用服务器支持JDBC事务、JTA(Java Transaction API)事务、容器管理事务。一般情况下,最好不要在程序中同时使用上述三种事务类型,比如在JTA事务中嵌套JDBC事务。第二方面,事务要在尽可能短的时间内完成,不要在不同方法中实现事务的使用。下面我们列举两种事务处理方式。
......
猪年无聊,改了一个代码,有点D版那个意思,把WAP PUSH的C#代码改到了JAVA
原来出处:
http://www.codeproject.com/cs/internet/wappush.asp
改过后的代码在下面,程序好像可以输出了WAPPUSH的结构化的东西,但是,没有在CMPP协议上测试通过。
共7个文件:
package com.wap.wbxml;
public class Runner {
&nbs ......
把树形的结构抽象了一下。
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();
......