- 博客(9)
- 资源 (3)
- 收藏
- 关注
原创 无向图的广度优先遍历和深度优先遍历
public class MGraph { private char[] vexs;// 顶点 private int[][] edge;// 存储边的二维数组 private int arcNum;// 边的数目 private boolean[] visited;// 访问标志数组 // 确定顶点在图中的位置 public int locataVex(char ve...
2010-12-20 23:06:33
1538
原创 segments_N 和segments.gen
The active segments in the index are stored in the segment info file, segments_N. There may be one or more segments_N files in the index; however, the one with the largest generation is the active one...
2010-12-14 22:52:08
405
原创 采用孩子兄弟法构造树和遍历树
/** * 树用孩子兄弟表示法表示 * @author wanglianqin * * 2010-12-9 */public class TreeNode { private TreeNode firstChild;// 孩子 private TreeNode nextsibling;// 兄弟 public Object data;// 数据元素 ...
2010-12-09 22:52:32
838
原创 串的模式匹配算法一
最近,经常使用String的indexOf()方法,于是很想琢磨一下它的内部实现机制,如果我我来实现的话,会采用什么办法? 首先我想到的是使用简单模式匹配算法,思路很清楚,但是时间复杂度很高 最坏的情况是O(n*m)(n是主串的长度,m是模式串的长度). 后来想到KMP算法很强悍,时间复杂度好像是线性的,不过杯具的是我对kmp算法完全没有印象。花了点时间看了会书,写了段代码,...
2010-11-30 20:37:30
181
原创 Math.round()
Math.round(double val)方法返回最接近的long类型值val为正数时,如果小数点后数字小于5,则舍去;大于等于5,则进一位。val为负数时,如果小数点后数字小于等于5,则舍去;大于5,则向后进一位...
2010-11-24 23:08:20
107
原创 java运算符
在算术运算符部分,需要特别注意的一个语法现象是“晋升”。晋升指低于int的3种数字类型(byte、short和char)进行算术运算后,结果会自动提升成int类型。示例代码如下: byte b1 = 10; byte b2 = 20; byte b3 = b1 + b2; //...
2010-11-24 22:49:49
83
原创 protected访问权限问题
Test.javaclass MyObject {} public class Test { public static void main(String[] args) { MyObject obj = new MyObject(); obj.clone(); // Compile error. }}此时出现上文提到的错误:...
2010-11-24 22:44:59
107
原创 java对象的等价性
eg1: Integer n1=new Integer(45); Integer n2=new Integer(45); if(n1==n2) { System.out.println("n1=n2"); }else { System.out.println("n!=n2"); } 打印出结...
2010-11-24 22:40:53
109
原创 short s1 = 1;s1 =s1+1;有错而short s1 = 1; s1+=1正确,为何?
s1=s1+1和s1+=1是有区别的。 s1=s1+1会错因为s1是short,而1是int,所以运算时会自动转换为int,再将int赋值给s1是需要强制转换,所以会错。 JAVA规范上说e1+=e2 实际上是 e1=(T1)(e1+e2),其中T1是e1的数据类型s1+=1等效于 s1=(short)(s1+1),所以是正确的。下面是详细分析:基本型别 大小 最...
2010-11-24 21:23:23
189
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人