几种常见的数据结构的JAVA实现
依旧没有文字说明,只有少量的注释,二叉查找树有很多参考资料,这里就不多说了。下面奉上JAVA代码
package utility.structure;
import java.io.Serializable;
import java.security.InvalidParameterException;
import java.util.Comparator;
import java.util.ConcurrentModificationException;
/**
*
* @author odie.tang
* @version 1.0 11/09/09
*/
public class BinarySearchTree<E> implements Comparable<E>,Serializable{
private static final long serialVersionUID = -8154673525487170187L;
/**
* The comparator, or null if priority queue uses elements'
* natural ordering.
*/
private Comparator<? super E> comparator = null;
private E data;
private BinarySearchTree<E> parent = null;
private BinarySearchTree<E> leftChild = null;
private BinarySearchTree<E> rightChild = null;
/**
* level indicates node's level in the whole tree, eg: root's level is 1, and its children's level is 2...
*/
private int level;
/**
* to identify the whether the child is a left child or a right one
*/
enum Child{left,right};
public BinarySearchTree() {
this.level = 0;
}
public BinarySearchTree(Comparator<? super E> comparator){
this.comparator = comparator;
this.level = 0;
}
public BinarySearchTree(E root) {
this(root,null);
}
public BinarySearchTree(E root,Comparator<? super E> comparator){
this.data = root;
this.comparator = comparator;
this.level = 1;
}
private BinarySearchTree(BinarySearchTree<E> parent,Child childType,E child){
this.data = child;
this.parent = parent;
this.level = parent.level + 1;
if (childType == Child.left)
parent.leftChild = this;
else
parent.rightChild = this;
this.comparator = parent.comparator;
}
public void add(E e){
if (this.level == 0){
this.level = 1;
this.data = e;
}
else{
BinarySearchTree<
相关文档:
个人简历
个人信息
姓名
:
朱金国
性别
:
男
出生日期
:
1988
年
1
月
9
日
Email
:
zhujinguo2009@gmail.com
  ......
1. package book.io;
2.
3. import java.io.File;
4.
5. /**
6. *
7. * @author XWZ
8. * 20 ......
一个由 Carol Hamer 写的比较有代表性的源码,作者全力推荐,尤其是对于没有 J2ME 开发经验的朋友。自己动手敲出以下贴出的 Hello.java 和 HelloCanvas.java 源码,并运行,用心体会一下。相信你理解了此源码之后,即可步入 J2ME 开发。
注释都在源码里,运行环境自己配,自己动手看运行效果,理解之后,然后动手修 ......
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class BubbleSort {
private static int a[] = new int[12];
private static BufferedReader in = new BufferedReader(
new InputStreamReader(System.in));
public static void bubbleSort(int a[], i ......
RMI(Remote Method Invocation)
RMI是分布式对象软件包,它简化了在多台计算机上的JAVA应用之间的通信。
必须在jdk1.1以上
RMI用到的类
java.rmi.Remote 所有可以被远程调用的对象都必须实现该接口
java.rmi.server.UnicastRemoteObject 所有可以被远程调用的对象都必须扩展该类
什么是RMI
远程方法调用是 ......