📄 delivervector.java
字号:
/********************************************************************************
*
* 为提高速度和内存利用效率,自建deliverStruct的Vector结构
*
*/
package com.ut.smgp.api.structure;
public class deliverVector {
private deliverStruct[] data;
private int count;
public deliverVector() {
this(10); // default size is 10
}
public deliverVector(int initialSize)
{
data = new deliverStruct[initialSize];
}
public void add(deliverStruct str)
{
// ignore null strings
if(str == null) { return; }
ensureCapacity(count + 1);
data[count++] = str;
}
private void ensureCapacity(int minCapacity)
{
int oldCapacity = data.length;
if (minCapacity > oldCapacity) {
deliverStruct oldData[] = data;
int newCapacity = oldCapacity * 30;
//if(oldCapacity>300000) oldCapacity+=100000;
data = new deliverStruct[newCapacity];
System.arraycopy(oldData, 0, data, 0, count);
}
}
public void clear()
{
data=new deliverStruct[10];
count=0;
}
public int size()
{
return count;
}
public deliverStruct get(int i)
{
return data[i];
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -