Methods Summary |
---|
public boolean | equals(java.lang.Object other){@inheritDoc}
if (this == other) {
// Easy out.
return true;
}
if ((other == null) || (getClass() != other.getClass())) {
// Another easy out.
return false;
}
FixedSizeList list = (FixedSizeList) other;
return Arrays.equals(arr, list.arr);
|
protected final java.lang.Object | get0(int n)Gets the indicated element. It is an error to call this with the
index for an element which was never set; if you do that, this
will throw NullPointerException . This method is
protected so that subclasses may offer a safe type-checked
public interface to their clients.
try {
Object result = arr[n];
if (result == null) {
throw new NullPointerException("unset: " + n);
}
return result;
} catch (ArrayIndexOutOfBoundsException ex) {
// Translate the exception.
return throwIndex(n);
}
|
protected final java.lang.Object | getOrNull0(int n)Gets the indicated element, allowing null s to be
returned. This method is protected so that subclasses may
(optionally) offer a safe type-checked public interface to
their clients.
return arr[n];
|
public int | hashCode(){@inheritDoc}
return Arrays.hashCode(arr);
|
protected final void | set0(int n, java.lang.Object obj)Sets the element at the given index, but without doing any type
checks on the element. This method is protected so that
subclasses may offer a safe type-checked public interface to
their clients.
throwIfImmutable();
try {
arr[n] = obj;
} catch (ArrayIndexOutOfBoundsException ex) {
// Translate the exception.
throwIndex(n);
}
|
public void | shrinkToFit()Shrinks this instance to fit, by removing any unset
(null ) elements, leaving the remaining elements in
their original order.
int sz = arr.length;
int newSz = 0;
for (int i = 0; i < sz; i++) {
if (arr[i] != null) {
newSz++;
}
}
if (sz == newSz) {
return;
}
throwIfImmutable();
Object[] newa = new Object[newSz];
int at = 0;
for (int i = 0; i < sz; i++) {
Object one = arr[i];
if (one != null) {
newa[at] = one;
at++;
}
}
arr = newa;
if (newSz == 0) {
setImmutable();
}
|
public final int | size()Gets the number of elements in this list.
return arr.length;
|
private java.lang.Object | throwIndex(int n)Throws the appropriate exception for the given index value.
if (n < 0) {
throw new IndexOutOfBoundsException("n < 0");
}
throw new IndexOutOfBoundsException("n >= size()");
|
public java.lang.String | toHuman(){@inheritDoc}
This method will only work if every element of the list
implements {@link ToHuman}.
String name = getClass().getName();
return toString0(name.substring(name.lastIndexOf('.") + 1) + '{",
", ",
"}",
true);
|
public java.lang.String | toHuman(java.lang.String prefix, java.lang.String separator, java.lang.String suffix)Gets a customized human string for this instance. This method will
only work if every element of the list implements {@link
ToHuman}.
return toString0(prefix, separator, suffix, true);
|
public java.lang.String | toString(){@inheritDoc}
String name = getClass().getName();
return toString0(name.substring(name.lastIndexOf('.") + 1) + '{",
", ",
"}",
false);
|
public java.lang.String | toString(java.lang.String prefix, java.lang.String separator, java.lang.String suffix)Gets a customized string form for this instance.
return toString0(prefix, separator, suffix, false);
|
private java.lang.String | toString0(java.lang.String prefix, java.lang.String separator, java.lang.String suffix, boolean human)Helper for {@link #toString} and {@link #toHuman}, which both of
those call to pretty much do everything.
int len = arr.length;
StringBuffer sb = new StringBuffer(len * 10 + 10);
if (prefix != null) {
sb.append(prefix);
}
for (int i = 0; i < len; i++) {
if ((i != 0) && (separator != null)) {
sb.append(separator);
}
if (human) {
sb.append(((ToHuman) arr[i]).toHuman());
} else {
sb.append(arr[i]);
}
}
if (suffix != null) {
sb.append(suffix);
}
return sb.toString();
|