s backed
by random access structures like arrays.
. Mutable subclasses
should also override
. Variably-sized
subclasses should also override
. All other methods
have at least some base implementation derived from
these. Subclasses may choose to override these methods
to provide a more efficient implementation.
| Method from org.apache.commons.collections.primitives.RandomAccessIntList Detail: |
public boolean add(int element) {
add(size(),element);
return true;
}
|
public void add(int index,
int element) {
throw new UnsupportedOperationException();
}
Unsupported in this implementation. |
public boolean addAll(int index,
IntCollection collection) {
boolean modified = false;
for(IntIterator iter = collection.iterator(); iter.hasNext(); ) {
add(index++,iter.next());
modified = true;
}
return modified;
}
|
public boolean equals(Object that) {
if(this == that) {
return true;
} else if(that instanceof IntList) {
IntList thatList = (IntList)that;
if(size() != thatList.size()) {
return false;
}
for(IntIterator thatIter = thatList.iterator(), thisIter = iterator(); thisIter.hasNext();) {
if(thisIter.next() != thatIter.next()) {
return false;
}
}
return true;
} else {
return false;
}
}
|
abstract public int get(int index)
|
protected int getModCount() {
return _modCount;
}
Get my count of structural modifications. |
public int hashCode() {
int hash = 1;
for(IntIterator iter = iterator(); iter.hasNext(); ) {
hash = 31*hash + iter.next();
}
return hash;
}
|
protected void incrModCount() {
_modCount++;
}
Increment my count of structural modifications. |
public int indexOf(int element) {
int i = 0;
for(IntIterator iter = iterator(); iter.hasNext(); ) {
if(iter.next() == element) {
return i;
} else {
i++;
}
}
return -1;
}
|
public IntIterator iterator() {
return listIterator();
}
|
public int lastIndexOf(int element) {
for(IntListIterator iter = listIterator(size()); iter.hasPrevious(); ) {
if(iter.previous() == element) {
return iter.nextIndex();
}
}
return -1;
}
|
public IntListIterator listIterator() {
return listIterator(0);
}
|
public IntListIterator listIterator(int index) {
return new RandomAccessIntListIterator(this,index);
}
|
public int removeElementAt(int index) {
throw new UnsupportedOperationException();
}
Unsupported in this implementation. |
public int set(int index,
int element) {
throw new UnsupportedOperationException();
}
Unsupported in this implementation. |
abstract public int size()
|
public IntList subList(int fromIndex,
int toIndex) {
return new RandomAccessIntSubList(this,fromIndex,toIndex);
}
|
public String toString() {
StringBuffer buf = new StringBuffer();
buf.append("[");
for(IntIterator iter = iterator(); iter.hasNext();) {
buf.append(iter.next());
if(iter.hasNext()) {
buf.append(", ");
}
}
buf.append("]");
return buf.toString();
}
|