< prev index next >

src/java.base/share/classes/java/util/TreeSet.java

Print this page




  57  * unsynchronized access to the set: <pre>
  58  *   SortedSet s = Collections.synchronizedSortedSet(new TreeSet(...));</pre>
  59  *
  60  * <p>The iterators returned by this class's {@code iterator} method are
  61  * <i>fail-fast</i>: if the set is modified at any time after the iterator is
  62  * created, in any way except through the iterator's own {@code remove}
  63  * method, the iterator will throw a {@link ConcurrentModificationException}.
  64  * Thus, in the face of concurrent modification, the iterator fails quickly
  65  * and cleanly, rather than risking arbitrary, non-deterministic behavior at
  66  * an undetermined time in the future.
  67  *
  68  * <p>Note that the fail-fast behavior of an iterator cannot be guaranteed
  69  * as it is, generally speaking, impossible to make any hard guarantees in the
  70  * presence of unsynchronized concurrent modification.  Fail-fast iterators
  71  * throw {@code ConcurrentModificationException} on a best-effort basis.
  72  * Therefore, it would be wrong to write a program that depended on this
  73  * exception for its correctness:   <i>the fail-fast behavior of iterators
  74  * should be used only to detect bugs.</i>
  75  *
  76  * <p>This class is a member of the
  77  * <a href="{@docRoot}/java/util/package-summary.html#CollectionsFramework">
  78  * Java Collections Framework</a>.
  79  *
  80  * @param <E> the type of elements maintained by this set
  81  *
  82  * @author  Josh Bloch
  83  * @see     Collection
  84  * @see     Set
  85  * @see     HashSet
  86  * @see     Comparable
  87  * @see     Comparator
  88  * @see     TreeMap
  89  * @since   1.2
  90  */
  91 
  92 public class TreeSet<E> extends AbstractSet<E>
  93     implements NavigableSet<E>, Cloneable, java.io.Serializable
  94 {
  95     /**
  96      * The backing map.
  97      */




  57  * unsynchronized access to the set: <pre>
  58  *   SortedSet s = Collections.synchronizedSortedSet(new TreeSet(...));</pre>
  59  *
  60  * <p>The iterators returned by this class's {@code iterator} method are
  61  * <i>fail-fast</i>: if the set is modified at any time after the iterator is
  62  * created, in any way except through the iterator's own {@code remove}
  63  * method, the iterator will throw a {@link ConcurrentModificationException}.
  64  * Thus, in the face of concurrent modification, the iterator fails quickly
  65  * and cleanly, rather than risking arbitrary, non-deterministic behavior at
  66  * an undetermined time in the future.
  67  *
  68  * <p>Note that the fail-fast behavior of an iterator cannot be guaranteed
  69  * as it is, generally speaking, impossible to make any hard guarantees in the
  70  * presence of unsynchronized concurrent modification.  Fail-fast iterators
  71  * throw {@code ConcurrentModificationException} on a best-effort basis.
  72  * Therefore, it would be wrong to write a program that depended on this
  73  * exception for its correctness:   <i>the fail-fast behavior of iterators
  74  * should be used only to detect bugs.</i>
  75  *
  76  * <p>This class is a member of the
  77  * <a href="{@docRoot}/java.base/java/util/package-summary.html#CollectionsFramework">
  78  * Java Collections Framework</a>.
  79  *
  80  * @param <E> the type of elements maintained by this set
  81  *
  82  * @author  Josh Bloch
  83  * @see     Collection
  84  * @see     Set
  85  * @see     HashSet
  86  * @see     Comparable
  87  * @see     Comparator
  88  * @see     TreeMap
  89  * @since   1.2
  90  */
  91 
  92 public class TreeSet<E> extends AbstractSet<E>
  93     implements NavigableSet<E>, Cloneable, java.io.Serializable
  94 {
  95     /**
  96      * The backing map.
  97      */


< prev index next >