src/share/classes/java/util/Collection.java

Print this page




  86  * terms of the {@link Object#equals(Object) equals} method.  For example,
  87  * the specification for the {@link #contains(Object) contains(Object o)}
  88  * method says: "returns <tt>true</tt> if and only if this collection
  89  * contains at least one element <tt>e</tt> such that
  90  * <tt>(o==null ? e==null : o.equals(e))</tt>."  This specification should
  91  * <i>not</i> be construed to imply that invoking <tt>Collection.contains</tt>
  92  * with a non-null argument <tt>o</tt> will cause <tt>o.equals(e)</tt> to be
  93  * invoked for any element <tt>e</tt>.  Implementations are free to implement
  94  * optimizations whereby the <tt>equals</tt> invocation is avoided, for
  95  * example, by first comparing the hash codes of the two elements.  (The
  96  * {@link Object#hashCode()} specification guarantees that two objects with
  97  * unequal hash codes cannot be equal.)  More generally, implementations of
  98  * the various Collections Framework interfaces are free to take advantage of
  99  * the specified behavior of underlying {@link Object} methods wherever the
 100  * implementor deems it appropriate.
 101  *
 102  * <p>This interface is a member of the
 103  * <a href="{@docRoot}/../technotes/guides/collections/index.html">
 104  * Java Collections Framework</a>.
 105  *


 106  * @author  Josh Bloch
 107  * @author  Neal Gafter
 108  * @see     Set
 109  * @see     List
 110  * @see     Map
 111  * @see     SortedSet
 112  * @see     SortedMap
 113  * @see     HashSet
 114  * @see     TreeSet
 115  * @see     ArrayList
 116  * @see     LinkedList
 117  * @see     Vector
 118  * @see     Collections
 119  * @see     Arrays
 120  * @see     AbstractCollection
 121  * @since 1.2
 122  */
 123 
 124 public interface Collection<E> extends Iterable<E> {
 125     // Query Operations




  86  * terms of the {@link Object#equals(Object) equals} method.  For example,
  87  * the specification for the {@link #contains(Object) contains(Object o)}
  88  * method says: "returns <tt>true</tt> if and only if this collection
  89  * contains at least one element <tt>e</tt> such that
  90  * <tt>(o==null ? e==null : o.equals(e))</tt>."  This specification should
  91  * <i>not</i> be construed to imply that invoking <tt>Collection.contains</tt>
  92  * with a non-null argument <tt>o</tt> will cause <tt>o.equals(e)</tt> to be
  93  * invoked for any element <tt>e</tt>.  Implementations are free to implement
  94  * optimizations whereby the <tt>equals</tt> invocation is avoided, for
  95  * example, by first comparing the hash codes of the two elements.  (The
  96  * {@link Object#hashCode()} specification guarantees that two objects with
  97  * unequal hash codes cannot be equal.)  More generally, implementations of
  98  * the various Collections Framework interfaces are free to take advantage of
  99  * the specified behavior of underlying {@link Object} methods wherever the
 100  * implementor deems it appropriate.
 101  *
 102  * <p>This interface is a member of the
 103  * <a href="{@docRoot}/../technotes/guides/collections/index.html">
 104  * Java Collections Framework</a>.
 105  *
 106  * @param <E> the type of elements in this collection
 107  *
 108  * @author  Josh Bloch
 109  * @author  Neal Gafter
 110  * @see     Set
 111  * @see     List
 112  * @see     Map
 113  * @see     SortedSet
 114  * @see     SortedMap
 115  * @see     HashSet
 116  * @see     TreeSet
 117  * @see     ArrayList
 118  * @see     LinkedList
 119  * @see     Vector
 120  * @see     Collections
 121  * @see     Arrays
 122  * @see     AbstractCollection
 123  * @since 1.2
 124  */
 125 
 126 public interface Collection<E> extends Iterable<E> {
 127     // Query Operations