【发布时间】:2010-11-07 02:08:19
【问题描述】:
嘿,我正在尝试实现 ShellSort 算法,但现在我遇到了一个问题:
warning: [unchecked] unchecked castfound : java.util.Vectorrequired: java.util.Vector<java.lang.Object>Vector<Object> vcur = (Vector<Object>)currentCols[tcur];
与vtmp 相同。
我不知道问题出在哪里。如果你能帮助我,那就太好了。 :)
这是我的代码:
public static Vector<Object> shellSort(Vector<Object> ul) {
int lcount = ul.size();
int colcount = 4; // 2^x
Vector[] currentCols = { ul };
for(; colcount > 0; colcount = (colcount / 2)) {
Vector[] tmpCols = new Vector[colcount];
for(int t1 = 0; t1 < colcount; t1++) {
tmpCols[t1] = new Vector<Object>();
}
int tcur = 0;
int tcurlvl = 0;
int ttmp = 0;
for(int t2 = 0; t2 < lcount; t2++) {
Vector<Object> vcur = (Vector<Object>)currentCols[tcur];
Vector<Object> vtmp = (Vector<Object>)tmpCols[ttmp];
vtmp.addElement((Object)vcur.elementAt(tcurlvl));
// step to next place
tcur++;
ttmp++;
if(tcur == currentCols.length) { tcur = 0; tcurlvl++; }
if(ttmp == tmpCols.length) { ttmp = 0; }
}
}
return ul;
}
【问题讨论】: