| Method from org.apache.commons.collections.primitives.ArrayUnsignedIntList Detail: |
public void add(int index,
long element) {
assertValidUnsignedInt(element);
checkRangeIncludingEndpoint(index);
incrModCount();
ensureCapacity(_size+1);
int numtomove = _size-index;
System.arraycopy(_data,index,_data,index+1,numtomove);
_data[index] = fromLong(element);
_size++;
}
Inserts the specified element at the specified position
(optional operation). Shifts the element currently
at that position (if any) and any subsequent elements to the
right, increasing their indices.
Throws IllegalArgumentException if element
is less than #MIN_VALUE or greater than #MAX_VALUE . |
public void ensureCapacity(int mincap) {
incrModCount();
if(mincap > _data.length) {
int newcap = (_data.length * 3)/2 + 1;
int[] olddata = _data;
_data = new int[newcap < mincap ? mincap : newcap];
System.arraycopy(olddata,0,_data,0,_size);
}
}
Increases my capacity, if necessary, to ensure that I can hold at
least the number of elements specified by the minimum capacity
argument without growing. |
public long get(int index) {
checkRange(index);
return toLong(_data[index]);
}
Returns the element at the specified position within
me.
By construction, the returned value will be
between #MIN_VALUE and #MAX_VALUE , inclusive. |
public long removeElementAt(int index) {
checkRange(index);
incrModCount();
long oldval = toLong(_data[index]);
int numtomove = _size - index - 1;
if(numtomove > 0) {
System.arraycopy(_data,index+1,_data,index,numtomove);
}
_size--;
return oldval;
}
Removes the element at the specified position in
(optional operation). Any subsequent elements
are shifted to the left, subtracting one from their
indices. Returns the element that was removed.
By construction, the returned value will be
between #MIN_VALUE and #MAX_VALUE , inclusive. |
public long set(int index,
long element) {
assertValidUnsignedInt(element);
checkRange(index);
incrModCount();
long oldval = toLong(_data[index]);
_data[index] = fromLong(element);
return oldval;
}
|
public int size() {
return _size;
}
|
public void trimToSize() {
incrModCount();
if(_size < _data.length) {
int[] olddata = _data;
_data = new int[_size];
System.arraycopy(olddata,0,_data,0,_size);
}
}
Reduce my capacity, if necessary, to match my
current size . |