コード例 #1
0
ファイル: AbstractList.java プロジェクト: sherckuith/jop
 /**
  * Returns the hash code value for this list.
  *
  * <p>This implementation uses exactly the code that is used to define the list hash function in
  * the documentation for the {@link List#hashCode} method.
  *
  * @return the hash code value for this list
  */
 public int hashCode() {
   int hashCode = 1;
   Iterator<E> i = iterator();
   while (i.hasNext()) {
     E obj = i.next();
     hashCode = 31 * hashCode + (obj == null ? 0 : obj.hashCode());
   }
   return hashCode;
 }
コード例 #2
0
ファイル: AbstractList.java プロジェクト: sherckuith/jop
 /**
  * {@inheritDoc}
  *
  * <p>This implementation gets an iterator over the specified collection and iterates over it,
  * inserting the elements obtained from the iterator into this list at the appropriate position,
  * one at a time, using {@code add(int, E)}. Many implementations will override this method for
  * efficiency.
  *
  * <p>Note that this implementation throws an {@code UnsupportedOperationException} unless {@link
  * #add(int, Object) add(int, E)} is overridden.
  *
  * @throws UnsupportedOperationException {@inheritDoc}
  * @throws ClassCastException {@inheritDoc}
  * @throws NullPointerException {@inheritDoc}
  * @throws IllegalArgumentException {@inheritDoc}
  * @throws IndexOutOfBoundsException {@inheritDoc}
  */
 public boolean addAll(int index, Collection<? extends E> c) {
   boolean modified = false;
   Iterator<? extends E> e = c.iterator();
   while (e.hasNext()) {
     add(index++, e.next());
     modified = true;
   }
   return modified;
 }