/** * Returns a hash code computed from each object's hash code. * @return a hash code. */ @Override public int hashCode() { int hashCode = 1; for (int i = 0, size = size(); i < size; ++i) { Object object = primitiveGet(i); hashCode = 31 * hashCode + (object == null ? 0 : object.hashCode()); } return hashCode; }
/** * Returns a string of the form <code>"[object1, object2]"</code>. * @return a string of the form <code>"[object1, object2]"</code>. */ @Override public String toString() { StringBuffer stringBuffer = new StringBuffer(); stringBuffer.append("["); for (int i = 0, size = size(); i < size; ) { stringBuffer.append(String.valueOf(primitiveGet(i))); if (++i < size) { stringBuffer.append(", "); } } stringBuffer.append("]"); return stringBuffer.toString(); }
/** * Removes each object of the collection from the list and returns whether any object was actually contained by the list. * @param collection the collection of objects to be removed. * @return whether any object was actually contained by the list. */ @Override public boolean removeAll(Collection<?> collection) { boolean modified = false; for (int i = size(); --i >= 0; ) { if (collection.contains(primitiveGet(i))) { remove(i); modified = true; } } return modified; }
/** * Returns the object at the index without {@link #resolve resolving} it. * @param index the position in question. * @return the object at the index. * @exception IndexOutOfBoundsException if the index isn't within the size range. * @see #resolve * @see #get */ protected E basicGet(int index) { int size = size(); if (index >= size) throw new BasicIndexOutOfBoundsException(index, size); return primitiveGet(index); }
Object o1 = primitiveGet(i); Object o2 = objects.next(); if (o1 == null ? o2 != null : !o1.equals(o2)) Object o1 = primitiveGet(i); Object o2 = objects.next(); if (o1 != o2)
/** * Removes from the list each object not contained by the collection * and returns whether any object was actually removed. * This delegates to {@link #remove(int) remove(int)} * in the case that it finds an object that isn't retained. * @param collection the collection of objects to be retained. * @return whether any object was actually removed. */ @Override public boolean retainAll(Collection<?> collection) { boolean modified = false; for (int i = size(); --i >= 0; ) { if (!collection.contains(primitiveGet(i))) { remove(i); modified = true; } } return modified; }