哪位高手帮分析一下如下代码,研究了半天没搞明白,感谢
public void add(int location, E object) {
int size = lastIndex - firstIndex;
if (0 < location && location < size) {
if (firstIndex == 0 && lastIndex == array.length) {
growForInsert(location, 1);
} else if ((location < size / 2 && firstIndex > 0)
|| lastIndex == array.length) {
System.arraycopy(array, firstIndex, array, --firstIndex,
location);
} else {
int index = location + firstIndex;
System.arraycopy(array, index, array, index + 1, size
- location);
lastIndex++;
}
array[location + firstIndex] = object;
} else if (location == 0) {
if (firstIndex == 0) {
growAtFront(1);
}
array[--firstIndex] = object;
} else if (location == size) {
if (lastIndex == array.length) {
growAtEnd(1);
}
array[lastIndex++] = object;
} else {
throw new IndexOutOfBoundsException(Messages.getString("luni.0A",
location, lastIndex - firstIndex));
}
modCount++;
}
int size = lastIndex - firstIndex;
if (0 < location && location < size) {
if (firstIndex == 0 && lastIndex == array.length) {
growForInsert(location, 1);
} else if ((location < size / 2 && firstIndex > 0)
|| lastIndex == array.length) {
System.arraycopy(array, firstIndex, array, --firstIndex,
location);
} else {
int index = location + firstIndex;
System.arraycopy(array, index, array, index + 1, size
- location);
lastIndex++;
}
array[location + firstIndex] = object;
} else if (location == 0) {
if (firstIndex == 0) {
growAtFront(1);
}
array[--firstIndex] = object;
} else if (location == size) {
if (lastIndex == array.length) {
growAtEnd(1);
}
array[lastIndex++] = object;
} else {
throw new IndexOutOfBoundsException(Messages.getString("luni.0A",
location, lastIndex - firstIndex));
}
modCount++;
}
...全文
相关推荐
jquery.autocomplete.js 动态传参
研究了半天终于搞明白了,再此做个总结,供以后使用,也分享给用样为此纠结的“童鞋”们。调用:$("#tag").autocompl
烦恼的半天作文.doc
在教育过程中,应该让孩子明白,虽然学业重要,但身体健康和基本需求的满足同样不容忽视。体育课上,丰俊杰对跑步的反感和在课堂上的失误,揭示了他对运动的抵触心理以及在集体活动中可能遭遇的尴尬。
一个经典的小Java服务器
说了这么半天,你也不一定明白。看看我的
后凋excel财务系统
仿金蝶kis,EXCEL VBA与ACCESS数据库的结晶:后凋财务系统智能化,短小精悍,会计处理功能齐全,使用简单(没有长篇累赘看半天也不一定能令人明白的使用说明),无科目长度、级数限制(科目编码规
MFCTabCtrlDlg.rar_MFCTabCtrlDlg_Tab c++ontrol c++ _tab_tab for
不用愁,看了你就明白啦。(TNND,琢磨了我半天终于搞定了,与大家分享之,希望能给你帮助)


