# HG changeset patch
# User smarks
# Date 1495230410 25200
# Node ID bec8ca52804cfae07b02f193aaa6e9b938d4d18e
# Parent e23c712e1d9428e32241edb4255d1bfbcb1500d1
8177788: migrate collections technotes/guides into java/util/doc-files
Reviewed-by: mchung, bchristi, martin
diff -r e23c712e1d94 -r bec8ca52804c src/java.base/share/classes/java/util/doc-files/coll-designfaq.html
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/java.base/share/classes/java/util/doc-files/coll-designfaq.html Fri May 19 14:46:50 2017 -0700
@@ -0,0 +1,399 @@
+
+
+
+
+
+
+
+Java Collections API Design FAQ
+
+
+Java Collections API Design FAQ
+
+
+This document answers frequently asked questions concerning the
+design of the Java collections framework. It is derived from the
+large volume of traffic on the collections-comments alias. It
+serves as a design rationale for the collections framework.
+Core Interfaces - General Questions
+
+- Why don't you support immutability directly in
+the core collection interfaces so that you can do away with
+optional operations (and
+UnsupportedOperationException)?
+- Won't programmers have to surround any code
+that calls optional operations with a try-catch clause in case they
+throw an UnsupportedOperationException?
+- Why isn't there a core interface for "bags"
+(AKA multisets)?
+- Why didn't you use "Beans-style names" for
+consistency?
+
+Collection Interface
+
+- Why doesn't Collection extend Cloneable and
+Serializable?
+- Why don't you provide an "apply" method in
+Collection to apply a given method ("upcall") to all the elements
+of the Collection?
+- Why didn't you provide a "Predicate" interface,
+and related methods (e.g., a method to find the first element in
+the Collection satisfying the predicate)?
+- Why don't you provide a form of the addAll
+method that takes an Enumeration (or an Iterator)?
+- Why don't the concrete implementations in the
+JDK have Enumeration (or Iterator) constructors?
+- Why don't you provide an Iterator.add
+method?
+
+List Interface
+
+- Why don't you rename the List interface to
+Sequence; doesn't "list" generally suggest "linked list"? Also,
+doesn't it conflict with java.awt.List?
+- Why don't you rename List's set method to
+replace, to avoid confusion with Set.
+
+Map Interface
+
+- Why doesn't Map extend
+Collection?
+
+Iterator Interface
+
+- Why doesn't Iterator extend
+Enumeration?
+- Why don't you provide an Iterator.peek method
+that allows you to look at the next element in an iteration without
+advancing the iterator?
+
+Miscellaneous
+
+- Why did you write a new collections framework
+instead of adopting JGL (a preexisting collections package from
+ObjectSpace, Inc.) into the JDK?
+- Why don't you eliminate all of the methods and
+classes that return "views" (Collections backed by other
+collection-like objects). This would greatly reduce
+aliasing.
+- Why don't you provide for "observable"
+collections that send out Events when they're
+modified?
+
+
+Core Interfaces - General Questions
+
+- Why don't you support immutability
+directly in the core collection interfaces so that you can do away
+with optional operations (and
+UnsupportedOperationException)?
+
This is the most controversial design decision in the whole API.
+Clearly, static (compile time) type checking is highly desirable,
+and is the norm in Java. We would have supported it if we believed
+it were feasible. Unfortunately, attempts to achieve this goal
+cause an explosion in the size of the interface hierarchy, and do
+not succeed in eliminating the need for runtime exceptions (though
+they reduce it substantially).
+Doug Lea, who wrote a popular Java collections package that did
+reflect mutability distinctions in its interface hierarchy, no
+longer believes it is a viable approach, based on user experience
+with his collections package. In his words (from personal
+correspondence) "Much as it pains me to say it, strong static
+typing does not work for collection interfaces in Java."
+To illustrate the problem in gory detail, suppose you want to
+add the notion of modifiability to the Hierarchy. You need four new
+interfaces: ModifiableCollection, ModifiableSet, ModifiableList,
+and ModifiableMap. What was previously a simple hierarchy is now a
+messy heterarchy. Also, you need a new Iterator interface for use
+with unmodifiable Collections, that does not contain the remove
+operation. Now can you do away with UnsupportedOperationException?
+Unfortunately not.
+Consider arrays. They implement most of the List operations, but
+not remove and add. They are "fixed-size" Lists. If you want to
+capture this notion in the hierarchy, you have to add two new
+interfaces: VariableSizeList and VariableSizeMap. You don't have to
+add VariableSizeCollection and VariableSizeSet, because they'd be
+identical to ModifiableCollection and ModifiableSet, but you might
+choose to add them anyway for consistency's sake. Also, you need a
+new variety of ListIterator that doesn't support the add and remove
+operations, to go along with unmodifiable List. Now we're up to ten
+or twelve interfaces, plus two new Iterator interfaces, instead of
+our original four. Are we done? No.
+Consider logs (such as error logs, audit logs and journals for
+recoverable data objects). They are natural append-only sequences,
+that support all of the List operations except for remove and set
+(replace). They require a new core interface, and a new
+iterator.
+And what about immutable Collections, as opposed to unmodifiable
+ones? (i.e., Collections that cannot be changed by the client AND
+will never change for any other reason). Many argue that this is
+the most important distinction of all, because it allows multiple
+threads to access a collection concurrently without the need for
+synchronization. Adding this support to the type hierarchy requires
+four more interfaces.
+Now we're up to twenty or so interfaces and five iterators, and
+it's almost certain that there are still collections arising in
+practice that don't fit cleanly into any of the interfaces. For
+example, the collection-views returned by Map are natural
+delete-only collections. Also, there are collections that will
+reject certain elements on the basis of their value, so we still
+haven't done away with runtime exceptions.
+When all was said and done, we felt that it was a sound
+engineering compromise to sidestep the whole issue by providing a
+very small set of core interfaces that can throw a runtime
+exception.
+
+- Won't programmers have to surround any
+code that calls optional operations with a try-catch clause in case
+they throw an UnsupportedOperationException?
+
It was never our intention that programs should catch these
+exceptions: that's why they're unchecked (runtime) exceptions. They
+should only arise as a result of programming errors, in which case,
+your program will halt due to the uncaught exception.
+
+- Why isn't there a core interface for
+"bags" (AKA multisets)?
+
The Collection interface provides this functionality. We are not
+providing any public implementations of this interface, as we think
+that it wouldn't be used frequently enough to "pull its weight." We
+occasionally return such Collections, which are implemented easily
+atop AbstractCollection (for example, the Collection returned by
+Map.values).
+
+- Why didn't you use "Beans-style
+names" for consistency?
+
While the names of the new collections methods do not adhere to
+the "Beans naming conventions", we believe that they are
+reasonable, consistent and appropriate to their purpose. It should
+be remembered that the Beans naming conventions do not apply to the
+JDK as a whole; the AWT did adopt these conventions, but that
+decision was somewhat controversial. We suspect that the
+collections APIs will be used quite pervasively, often with
+multiple method calls on a single line of code, so it is important
+that the names be short. Consider, for example, the Iterator
+methods. Currently, a loop over a collection looks like this:
+
+ for (Iterator i = c.iterator(); i.hasNext(); )
+ System.out.println(i.next());
+
+Everything fits neatly on one line, even if the Collection name is
+a long expression. If we named the methods "getIterator",
+"hasNextElement" and "getNextElement", this would no longer be the
+case. Thus, we adopted the "traditional" JDK style rather than the
+Beans style.
+
+
+Collection Interface
+
+- Why doesn't Collection extend Cloneable
+and Serializable?
+
Many Collection implementations (including all of the ones
+provided by the JDK) will have a public clone method, but it would
+be mistake to require it of all Collections. For example, what does
+it mean to clone a Collection that's backed by a terabyte SQL
+database? Should the method call cause the company to requisition a
+new disk farm? Similar arguments hold for serializable.
+If the client doesn't know the actual type of a Collection, it's
+much more flexible and less error prone to have the client decide
+what type of Collection is desired, create an empty Collection of
+this type, and use the addAll method to copy the elements of the
+original collection into the new one.
+
+- Why don't you provide an "apply" method
+in Collection to apply a given method ("upcall") to all the
+elements of the Collection?
+
This is what is referred to as an "Internal Iterator" in the
+"Design Patterns" book (Gamma et al.). We considered providing it,
+but decided not to as it seems somewhat redundant to support
+internal and external iterators, and Java already has a precedent
+for external iterators (with Enumerations). The "throw weight" of
+this functionality is increased by the fact that it requires a
+public interface to describe upcalls.
+
+- Why didn't you provide a "Predicate"
+interface, and related methods (e.g., a method to find the first
+element in the Collection satisfying the predicate)?
+
It's easy to implement this functionality atop Iterators, and
+the resulting code may actually look cleaner as the user can inline
+the predicate. Thus, it's not clear whether this facility pulls its
+weight. It could be added to the Collections class at a later date
+(implemented atop Iterator), if it's deemed useful.
+
+- Why don't you provide a form of the
+addAll method that takes an Enumeration (or an Iterator)?
+
Because we don't believe in using Enumerations (or Iterators) as
+"poor man's collections." This was occasionally done in prior
+releases, but now that we have the Collection interface, it is the
+preferred way to pass around abstract collections of objects.
+
+- Why don't the concrete implementations
+in the JDK have Enumeration (or Iterator) constructors?
+
Again, this is an instance of an Enumeration serving as a "poor
+man's collection" and we're trying to discourage that. Note
+however, that we strongly suggest that all concrete implementations
+should have constructors that take a Collection (and create a new
+Collection with the same elements).
+
+- Why don't you provide an Iterator.add
+method?
+
The semantics are unclear, given that the contract for Iterator
+makes no guarantees about the order of iteration. Note, however,
+that ListIterator does provide an add operation, as it does
+guarantee the order of the iteration.
+
+
+
+List Interface
+
+- Why don't you rename the List
+interface to Sequence; doesn't "list" generally suggest "linked
+list"? Also, doesn't it conflict with java.awt.List?
+
People were evenly divided as to whether List suggests linked
+lists. Given the implementation naming convention,
+<Implementation><Interface>, there
+was a strong desire to keep the core interface names short. Also,
+several existing names (AbstractSequentialList, LinkedList) would
+have been decidedly worse if we changed List to Sequence. The
+naming conflict can be dealt with by the following incantation:
+
+ import java.util.*;
+ import java.awt.*;
+ import java.util.List; // Dictates interpretation of "List"
+
+- Why don't you rename List's set
+method to replace, to avoid confusion with Set.
+
It was decided that the "set/get" naming convention was strongly
+enough enshrined in the language that we'd stick with it.
+
+
+
+Map Interface
+
+- Why doesn't Map extend
+Collection?
+
This was by design. We feel that mappings are not collections
+and collections are not mappings. Thus, it makes little sense for
+Map to extend the Collection interface (or vice versa).
+If a Map is a Collection, what are the elements? The only
+reasonable answer is "Key-value pairs", but this provides a very
+limited (and not particularly useful) Map abstraction. You can't
+ask what value a given key maps to, nor can you delete the entry
+for a given key without knowing what value it maps to.
+Collection could be made to extend Map, but this raises the
+question: what are the keys? There's no really satisfactory answer,
+and forcing one leads to an unnatural interface.
+Maps can be viewed as Collections (of keys, values, or
+pairs), and this fact is reflected in the three "Collection view
+operations" on Maps (keySet, entrySet, and values). While it is, in
+principle, possible to view a List as a Map mapping indices to
+elements, this has the nasty property that deleting an element from
+the List changes the Key associated with every element before the
+deleted element. That's why we don't have a map view operation on
+Lists.
+
+
+
+Iterator Interface
+
+- Why doesn't Iterator extend
+Enumeration?
+
We view the method names for Enumeration as unfortunate. They're
+very long, and very frequently used. Given that we were adding a
+method and creating a whole new framework, we felt that it would be
+foolish not to take advantage of the opportunity to improve the
+names. Of course we could support the new and old names in
+Iterator, but it doesn't seem worthwhile.
+
+- Why don't you provide an
+Iterator.peek method that allows you to look at the next element in
+an iteration without advancing the iterator?
+
It can be implemented atop the current Iterators (a similar
+pattern to java.io.PushbackInputStream). We believe that its use
+would be rare enough that it isn't worth including in the interface
+that everyone has to implement.
+
+
+
+Miscellaneous
+
+- Why did you write a new collections
+framework instead of adopting JGL (a preexisting collections
+package from ObjectSpace, Inc.) into the JDK?
+
If you examine the goals for our Collections framework (in the
+Overview), you'll see that we are not really "playing in the same
+space" as JGL. Quoting from the "Design Goals" Section of the Java
+Collections Overview: "Our main design goal was to produce an API
+that was reasonably small, both in size, and (more importantly) in
+'conceptual weight.'"
+JGL consists of approximately 130 classes and interfaces; its
+main goal was consistency with the C++ Standard Template Library
+(STL). This was not one of our goals. Java has
+traditionally stayed away from C++'s more complex features (e.g.,
+multiple inheritance, operator overloading). Our entire framework,
+including all infrastructure, contains approximately 25 classes and
+interfaces.
+While this may cause some discomfort for some C++ programmers,
+we feel that it will be good for Java in the long run. As the Java
+libraries mature, they inevitably grow, but we are trying as hard
+as we can to keep them small and manageable, so that Java continues
+to be an easy, fun language to learn and to use.
+
+- Why don't you eliminate all of the
+methods and classes that return "views" (Collections backed by
+other collection-like objects). This would greatly reduce
+aliasing.
+
Given that we provide core collection interfaces behind which
+programmers can "hide" their own implementations, there will be
+aliased collections whether the JDK provides them or not.
+Eliminating all views from the JDK would greatly increase the cost
+of common operations like making a Collection out of an array, and
+would do away with many useful facilities (like synchronizing
+wrappers). One view that we see as being particularly useful is
+List.subList.
+The existence of this method means that people who write methods
+taking List on input do not have to write secondary forms taking an
+offset and a length (as they do for arrays).
+
+- Why don't you provide for
+"observable" collections that send out Events when they're
+modified?
+
Primarily, resource constraints. If we're going to commit to
+such an API, it has to be something that works for everyone, that
+we can live with for the long haul. We may provide such a facility
+some day. In the meantime, it's not difficult to implement such a
+facility on top of the public APIs.
+
+
+
+
+Copyright © 1998, 2017, Oracle and/or its affiliates. 500 Oracle Parkway
+ Redwood Shores, CA 94065 USA. All rights reserved.
+
+
+
diff -r e23c712e1d94 -r bec8ca52804c src/java.base/share/classes/java/util/doc-files/coll-index.html
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/java.base/share/classes/java/util/doc-files/coll-index.html Fri May 19 14:46:50 2017 -0700
@@ -0,0 +1,80 @@
+
+
+
+
+
+
+
+
+The Collections Framework
+
+
+
+
+The Collections Framework
+
+The collections framework is a unified architecture for
+representing and manipulating collections, enabling them to be
+manipulated independently of the details of their representation.
+It reduces programming effort while increasing performance. It
+enables interoperability among unrelated APIs, reduces effort in
+designing and learning new APIs, and fosters software reuse. The
+framework is based on more than a dozen collection interfaces. It
+includes implementations of these interfaces and algorithms to
+manipulate them.
+The documents in this section are non-normative portions of
+the Java™ Platform, Standard Edition API Specification.
+
+- Overview - An overview of
+the collections framework.
+
+
+- Annotated API Outline - An
+annotated outline of the classes and interfaces comprising the
+collections framework, with links into the API Specification.
+
+
+- Design FAQ - Answers to
+frequently asked questions (FAQ) about the design of the
+collections framework.
+
+
+
+Copyright © 1998, 2017, Oracle and/or its affiliates. 500 Oracle Parkway
+ Redwood Shores, CA 94065 USA. All rights reserved.
+
+
+
diff -r e23c712e1d94 -r bec8ca52804c src/java.base/share/classes/java/util/doc-files/coll-overview.html
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/java.base/share/classes/java/util/doc-files/coll-overview.html Fri May 19 14:46:50 2017 -0700
@@ -0,0 +1,359 @@
+
+
+
+
+
+
+
+Collections Framework Overview
+
+
+Collections Framework Overview
+
+Introduction
+The Java platform includes a collections framework. A
+collection is an object that represents a group of objects
+(such as the classic ArrayList class).
+A collections framework is a unified architecture for representing
+and manipulating collections, enabling collections to be
+manipulated independently of implementation details.
+The primary advantages of a collections framework are that
+it:
+
+- Reduces programming effort by providing data
+structures and algorithms so you don't have to write them
+yourself.
+- Increases performance by providing
+high-performance implementations of data structures and algorithms.
+Because the various implementations of each interface are
+interchangeable, programs can be tuned by switching
+implementations.
+- Provides interoperability between unrelated
+APIs by establishing a common language to pass collections
+back and forth.
+- Reduces the effort required to learn APIs by
+requiring you to learn multiple ad hoc collection APIs.
+- Reduces the effort required to design and implement
+APIs by not requiring you to produce ad hoc collections
+APIs.
+- Fosters software reuse by providing a standard
+interface for collections and algorithms with which to manipulate
+them.
+
+The collections framework consists of:
+
+- Collection interfaces. Represent different
+types of collections, such as sets, lists, and maps. These
+interfaces form the basis of the framework.
+- General-purpose implementations. Primary
+implementations of the collection interfaces.
+- Legacy implementations. The collection classes
+from earlier releases, Vector and Hashtable, were
+retrofitted to implement the collection interfaces.
+- Special-purpose implementations.
+Implementations designed for use in special situations. These
+implementations display nonstandard performance characteristics,
+usage restrictions, or behavior.
+- Concurrent implementations. Implementations
+designed for highly concurrent use.
+- Wrapper implementations. Add functionality,
+such as synchronization, to other implementations.
+- Convenience implementations. High-performance
+"mini-implementations" of the collection interfaces.
+- Abstract implementations. Partial
+implementations of the collection interfaces to facilitate custom
+implementations.
+- Algorithms. Static methods that perform useful
+functions on collections, such as sorting a list.
+- Infrastructure. Interfaces that provide
+essential support for the collection interfaces.
+- Array Utilities. Utility functions for arrays
+of primitive types and reference objects. Not, strictly speaking, a
+part of the collections framework, this feature was added to the
+Java platform at the same time as the collections framework and
+relies on some of the same infrastructure.
+
+
+Collection Interfaces
+The collection interfaces are divided into two groups.
+The most basic interface, java.util.Collection,
+has the following descendants:
+
+The other collection interfaces are based on java.util.Map and are
+not true collections. However, these interfaces contain
+collection-view operations, which enable them to be
+manipulated as collections. Map has the following
+offspring:
+
+Many of the modification methods in the collection interfaces
+are labeled optional. Implementations are permitted to not
+perform one or more of these operations, throwing a runtime
+exception (UnsupportedOperationException) if they are
+attempted. The documentation for each implementation must specify
+which optional operations are supported. Several terms are
+introduced to aid in this specification:
+
+- Collections that do not support modification operations (such
+as add, remove and clear) are referred
+to as unmodifiable. Collections that are not unmodifiable
+are modifiable.
+- Collections that additionally guarantee that no change in the
+Collection object will be visible are referred to as
+immutable. Collections that are not immutable are
+mutable.
+- Lists that guarantee that their size remains constant even
+though the elements can change are referred to as
+fixed-size. Lists that are not fixed-size are referred to as
+variable-size.
+- Lists that support fast (generally constant time) indexed
+element access are known as random access lists. Lists that
+do not support fast indexed element access are known as
+sequential access lists. The RandomAccess
+marker interface enables lists to advertise the fact that they
+support random access. This enables generic algorithms to change
+their behavior to provide good performance when applied to either
+random or sequential access lists.
+
+Some implementations restrict what elements (or in the case of
+Maps, keys and values) can be stored. Possible
+restrictions include requiring elements to:
+
+- Be of a particular type.
+- Be not null.
+- Obey some arbitrary predicate.
+
+Attempting to add an element that violates an implementation's
+restrictions results in a runtime exception, typically a
+ClassCastException, an IllegalArgumentException,
+or a NullPointerException. Attempting to remove or test
+for the presence of an element that violates an implementation's
+restrictions can result in an exception. Some restricted
+collections permit this usage.
+
+Collection Implementations
+Classes that implement the collection interfaces typically have
+names in the form of
+<Implementation-style><Interface>.
+The general purpose implementations are summarized in the following
+table:
+
+The general-purpose implementations support all of the
+optional operations in the collection interfaces and have no
+restrictions on the elements they may contain. They are
+unsynchronized, but the Collections class contains static
+factories called
+synchronization wrappers that can be used to add
+synchronization to many unsynchronized collections. All of the new
+implementations have fail-fast iterators, which detect
+invalid concurrent modification, and fail quickly and cleanly
+(rather than behaving erratically).
+The AbstractCollection, AbstractSet,
+AbstractList, AbstractSequentialList and
+AbstractMap classes provide basic implementations of the
+core collection interfaces, to minimize the effort required to
+implement them. The API documentation for these classes describes
+precisely how each method is implemented so the implementer knows
+which methods must be overridden, given the performance of the
+basic operations of a specific implementation.
+
+Concurrent Collections
+Applications that use collections from more than one thread must
+be carefully programmed. In general, this is known as concurrent
+programming. The Java platform includes extensive support for
+concurrent programming. See Java Concurrency
+Utilities for details.
+Collections are so frequently used that various concurrent
+friendly interfaces and implementations of collections are included
+in the APIs. These types go beyond the synchronization wrappers
+discussed previously to provide features that are frequently needed
+in concurrent programming.
+These concurrent-aware interfaces are available:
+
+The following concurrent-aware implementation classes are
+available. See the API documentation for the correct usage of these
+implementations.
+
+
+Design Goals
+The main design goal was to produce an API that was small in
+size and, more importantly, in "conceptual weight." It
+was critical that the new functionality not seem too different to
+current Java programmers; it had to augment current facilities,
+rather than replace them. At the same time, the new API had to be
+powerful enough to provide all the advantages described
+previously.
+To keep the number of core interfaces small, the interfaces do
+not attempt to capture such subtle distinctions as mutability,
+modifiability, and resizability. Instead, certain calls in the core
+interfaces are optional, enabling implementations to throw
+an UnsupportedOperationException to indicate that they do
+not support a specified optional operation. Collection implementers
+must clearly document which optional operations are supported by an
+implementation.
+To keep the number of methods in each core interface small, an
+interface contains a method only if either:
+
+- It is a truly fundamental operation: a basic operations
+in terms of which others could be reasonably defined,
+- There is a compelling performance reason why an important
+implementation would want to override it.
+
+It was critical that all reasonable representations of
+collections interoperate well. This included arrays, which cannot
+be made to implement the Collection interface directly
+without changing the language. Thus, the framework includes methods
+to enable collections to be moved into arrays, arrays to be viewed
+as collections, and maps to be viewed as collections.
+
+
+Copyright © 1998, 2017, Oracle and/or its affiliates. 500 Oracle Parkway
+ Redwood Shores, CA 94065 USA. All rights reserved.
+
+
+
diff -r e23c712e1d94 -r bec8ca52804c src/java.base/share/classes/java/util/doc-files/coll-reference.html
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/java.base/share/classes/java/util/doc-files/coll-reference.html Fri May 19 14:46:50 2017 -0700
@@ -0,0 +1,564 @@
+
+
+
+
+
+
+
+Outline of the Collections Framework
+
+
+Outline of the Collections Framework
+
+The collections framework consists of:
+
+- Collection interfaces - The primary means by
+which collections are manipulated.
+
+- Collection
+- A group of objects. No assumptions are made about the order of
+the collection (if any) or whether it can contain duplicate
+elements.
+- Set - The
+familiar set abstraction. No duplicate elements permitted. May or
+may not be ordered. Extends the Collection interface.
+- List -
+Ordered collection, also known as a sequence. Duplicates are
+generally permitted. Allows positional access. Extends the
+Collection interface.
+- Queue - A
+collection designed for holding elements before processing. Besides
+basic Collection operations, queues provide additional
+insertion, extraction, and inspection operations.
+- Deque - A
+double ended queue, supporting element insertion and
+removal at both ends. Extends the Queue interface.
+- Map - A
+mapping from keys to values. Each key can map to one value.
+- SortedSet
+- A set whose elements are automatically sorted, either in their
+natural ordering (see the Comparable
+interface) or by a Comparator
+object provided when a SortedSet instance is created.
+Extends the Set interface.
+- SortedMap
+- A map whose mappings are automatically sorted by key, either
+using the natural ordering of the keys or by a comparator
+provided when a SortedMap instance is created. Extends the
+Map interface.
+- NavigableSet
+- A SortedSet extended with navigation methods reporting
+closest matches for given search targets. A NavigableSet
+may be accessed and traversed in either ascending or descending
+order.
+- NavigableMap
+- A SortedMap extended with navigation methods returning
+the closest matches for given search targets. A
+NavigableMap can be accessed and traversed in either
+ascending or descending key order.
+- BlockingQueue
+- A Queue with operations that wait for the queue to
+become nonempty when retrieving an element and that wait for space
+to become available in the queue when storing an element. (This
+interface is part of the java.util.concurrent
+package.)
+- TransferQueue
+- A BlockingQueue in which producers can wait for
+consumers to receive elements. (This interface is part of the
+java.util.concurrent
+package.)
+- BlockingDeque
+- A Deque with operations that wait for the deque to
+become nonempty when retrieving an element and wait for space to
+become available in the deque when storing an element. Extends both
+the Deque and BlockingQueue interfaces. (This
+interface is part of the java.util.concurrent
+package.)
+- ConcurrentMap
+- A Map with atomic putIfAbsent, remove,
+and replace methods. (This interface is part of the
+java.util.concurrent package.)
+-
+ConcurrentNavigableMap - A ConcurrentMap that
+is also a NavigableMap.
+
+
+- General-purpose implementations - The primary
+implementations of the collection interfaces.
+
+- HashSet - Hash
+table implementation of the Set interface. The best
+all-around implementation of the Set interface.
+- TreeSet
+- Red-black tree implementation of the NavigableSet
+interface.
+- LinkedHashSet
+- Hash table and linked list implementation of the Set
+interface. An insertion-ordered Set implementation that
+runs nearly as fast as HashSet.
+- ArrayList -
+Resizable array implementation of the List interface (an
+unsynchronized Vector). The best all-around implementation
+of the List interface.
+- ArrayDeque -
+Efficient, resizable array implementation of the Deque
+interface.
+- LinkedList
+- Doubly-linked list implementation of the List interface.
+Provides better performance than the ArrayList
+implementation if elements are frequently inserted or deleted
+within the list. Also implements the Deque interface. When
+accessed through the Queue interface, LinkedList
+acts as a FIFO queue.
+- PriorityQueue
+- Heap implementation of an unbounded priority queue.
+- HashMap - Hash
+table implementation of the Map interface (an
+unsynchronized Hashtable that supports null keys
+and values). The best all-around implementation of the Map
+interface.
+- TreeMap
+Red-black tree implementation of the NavigableMap
+interface.
+- LinkedHashMap
+- Hash table and linked list implementation of the Map
+interface. An insertion-ordered Map implementation that
+runs nearly as fast as HashMap. Also useful for building
+caches (see
+removeEldestEntry(Map.Entry) ).
+
+
+- Wrapper implementations -
+Functionality-enhancing implementations for use with other
+implementations. Accessed solely through static factory methods.
+
+-
+Collections.unmodifiableInterface -
+Returns an unmodifiable view of a specified collection that throws
+an UnsupportedOperationException if the user attempts to
+modify it.
+- Collections.synchronizedInterface
+- Returns a synchronized collection that is backed by the specified
+(typically unsynchronized) collection. As long as all accesses to
+the backing collection are through the returned collection, thread
+safety is guaranteed.
+-
+Collections.checkedInterface - Returns
+a dynamically type-safe view of the specified collection, which
+throws a ClassCastException if a client attempts to add an
+element of the wrong type. The generics mechanism in the language
+provides compile-time (static) type checking, but it is possible to
+bypass this mechanism. Dynamically type-safe views eliminate this
+possibility.
+
+
+- Adapter implementations - Implementations that
+adapt one collections interface to another:
+
+-
+newSetFromMap(Map) - Creates a general-purpose
+Set implementation from a general-purpose Map
+implementation.
+-
+asLifoQueue(Deque) - Returns a view of a
+Deque as a Last In First Out (LIFO) Queue.
+
+
+- Convenience implementations - High-performance
+"mini-implementations" of the collection interfaces.
+
+
+- Legacy implementations - Older collection
+classes were retrofitted to implement the collection interfaces.
+
+- Vector -
+Synchronized resizable array implementation of the List
+interface with additional legacy methods.
+- Hashtable
+- Synchronized hash table implementation of the Map
+interface that does not allow null keys or values, plus
+additional legacy methods.
+
+
+- Special-purpose implementations
+
+- WeakHashMap
+- An implementation of the Map interface that stores only
+weak
+references to its keys. Storing only weak references
+enables key-value pairs to be garbage collected when the key is no
+longer referenced outside of the WeakHashMap. This class
+is the easiest way to use the power of weak references. It is
+useful for implementing registry-like data structures, where the
+utility of an entry vanishes when its key is no longer reachable by
+any thread.
+- IdentityHashMap
+- Identity-based Map implementation based on a hash table.
+This class is useful for topology-preserving object graph
+transformations (such as serialization or deep copying). To perform
+these transformations, you must maintain an identity-based "node
+table" that keeps track of which objects have already been seen.
+Identity-based maps are also used to maintain
+object-to-meta-information mappings in dynamic debuggers and
+similar systems. Finally, identity-based maps are useful in
+preventing "spoof attacks" resulting from intentionally perverse
+equals methods. (IdentityHashMap never invokes the equals
+method on its keys.) An added benefit of this implementation is
+that it is fast.
+- CopyOnWriteArrayList
+- A List implementation backed by an copy-on-write array.
+All mutative operations (such as add, set, and
+remove) are implemented by making a new copy of the array.
+No synchronization is necessary, even during iteration, and
+iterators are guaranteed never to throw
+ConcurrentModificationException. This implementation is
+well-suited to maintaining event-handler lists (where change is
+infrequent, and traversal is frequent and potentially
+time-consuming).
+- CopyOnWriteArraySet
+- A Set implementation backed by a copy-on-write array.
+This implementation is similar to CopyOnWriteArrayList.
+Unlike most Set implementations, the add,
+remove, and contains methods require time
+proportional to the size of the set. This implementation is well
+suited to maintaining event-handler lists that must prevent
+duplicates.
+- EnumSet - A
+high-performance Set implementation backed by a bit
+vector. All elements of each EnumSet instance must be
+elements of a single enum type.
+- EnumMap - A
+high-performance Map implementation backed by an array.
+All keys in each EnumMap instance must be elements of a
+single enum type.
+
+
+- Concurrent implementations - These
+implementations are part of java.util.concurrent.
+
+- ConcurrentLinkedQueue
+- An unbounded first in, first out (FIFO) queue based on linked
+nodes.
+-
+LinkedBlockingQueue - An optionally bounded FIFO
+blocking queue backed by linked nodes.
+-
+ArrayBlockingQueue - A bounded FIFO blocking queue
+backed by an array.
+-
+PriorityBlockingQueue - An unbounded blocking priority
+queue backed by a priority heap.
+- DelayQueue
+- A time-based scheduling queue backed by a priority heap.
+- SynchronousQueue
+- A simple rendezvous mechanism that uses the
+BlockingQueue interface.
+-
+LinkedBlockingDeque - An optionally bounded FIFO
+blocking deque backed by linked nodes.
+-
+LinkedTransferQueue - An unbounded
+TransferQueue backed by linked nodes.
+- ConcurrentHashMap
+- A highly concurrent, high-performance ConcurrentMap
+implementation based on a hash table. This implementation never
+blocks when performing retrievals and enables the client to select
+the concurrency level for updates. It is intended as a drop-in
+replacement for Hashtable. In
+addition to implementing ConcurrentMap, it supports all of
+the legacy methods of Hashtable.
+-
+ConcurrentSkipListSet - Skips list implementation of
+the NavigableSet interface.
+-
+ConcurrentSkipListMap - Skips list implementation of
+the ConcurrentNavigableMap interface.
+
+
+- Abstract implementations - Skeletal
+implementations of the collection interfaces to facilitate custom
+implementations.
+
+- AbstractCollection
+- Skeletal Collection implementation that is neither a set
+nor a list (such as a "bag" or multiset).
+- AbstractSet
+- Skeletal Set implementation.
+- AbstractList
+- Skeletal List implementation backed by a random access
+data store (such as an array).
+- AbstractSequentialList
+- Skeletal List implementation backed by a sequential
+access data store (such as a linked list).
+- AbstractQueue
+- Skeletal Queue implementation.
+- AbstractMap
+- Skeletal Map implementation.
+
+
+- Algorithms - The Collections
+class contains these useful static methods.
+
+- sort(List)
+- Sorts a list using a merge sort algorithm, which provides average
+case performance comparable to a high quality quicksort, guaranteed
+O(n*log n) performance (unlike quicksort), and stability
+(unlike quicksort). A stable sort is one that does not reorder
+equal elements.
+-
+binarySearch(List, Object) - Searches for an element
+in an ordered list using the binary search algorithm.
+- reverse(List)
+- Reverses the order of the elements in a list.
+- shuffle(List)
+- Randomly changes the order of the elements in a list.
+-
+fill(List, Object) - Overwrites every element in a
+list with the specified value.
+-
+copy(List dest, List src) - Copies the source list
+into the destination list.
+-
+min(Collection) - Returns the minimum element in a
+collection.
+-
+max(Collection) - Returns the maximum element in a
+collection.
+-
+rotate(List list, int distance) - Rotates all of the
+elements in the list by the specified distance.
+-
+replaceAll(List list, Object oldVal, Object newVal) -
+Replaces all occurrences of one specified value with another.
+-
+indexOfSubList(List source, List target) - Returns the
+index of the first sublist of source that is equal to target.
+-
+lastIndexOfSubList(List source, List target) - Returns
+the index of the last sublist of source that is equal to
+target.
+-
+swap(List, int, int) - Swaps the elements at the
+specified positions in the specified list.
+-
+frequency(Collection, Object) - Counts the number of
+times the specified element occurs in the specified
+collection.
+-
+disjoint(Collection, Collection) - Determines whether
+two collections are disjoint, in other words, whether they contain
+no elements in common.
+-
+addAll(Collection<? super T>, T...) - Adds all
+of the elements in the specified array to the specified
+collection.
+
+
+- Infrastructure
+
+- Iterators - Similar to the familiar Enumeration
+interface, but more powerful, and with improved method names.
+
+- Iterator
+- In addition to the functionality of the Enumeration
+interface, enables the user to remove elements from the backing
+collection with well-defined, useful semantics.
+- ListIterator
+- Iterator for use with lists. In addition to the functionality of
+the Iterator interface, supports bidirectional iteration,
+element replacement, element insertion, and index retrieval.
+
+
+- Ordering
+
+- Comparable
+- Imparts a natural ordering to classes that implement it.
+The natural ordering can be used to sort a list or maintain order
+in a sorted set or map. Many classes were retrofitted to implement
+this interface.
+- Comparator
+- Represents an order relation, which can be used to sort a list or
+maintain order in a sorted set or map. Can override a type's
+natural ordering or order objects of a type that does not implement
+the Comparable interface.
+
+
+- Runtime exceptions
+
+-
+UnsupportedOperationException - Thrown by collections
+if an unsupported optional operation is called.
+-
+ConcurrentModificationException - Thrown by iterators
+and list iterators if the backing collection is changed
+unexpectedly while the iteration is in progress. Also thrown by
+sublist views of lists if the backing list is changed
+unexpectedly.
+
+
+- Performance
+
+- RandomAccess
+- Marker interface that lets List implementations indicate
+that they support fast (generally constant time) random access.
+This lets generic algorithms change their behavior to provide good
+performance when applied to either random or sequential access
+lists.
+
+
+
+
+- Array Utilities
+
+- Arrays -
+Contains static methods to sort, search, compare, hash, copy,
+resize, convert to String, and fill arrays of primitives
+and objects.
+
+
+
+
+
+Copyright © 1998, 2017, Oracle and/or its affiliates. 500 Oracle Parkway
+ Redwood Shores, CA 94065 USA. All rights reserved.
+
+
+
diff -r e23c712e1d94 -r bec8ca52804c src/java.base/share/classes/java/util/package-info.java
--- a/src/java.base/share/classes/java/util/package-info.java Fri Jun 16 22:10:20 2017 +0000
+++ b/src/java.base/share/classes/java/util/package-info.java Fri May 19 14:46:50 2017 -0700
@@ -24,27 +24,24 @@
*/
/**
- * Contains the collections framework, legacy collection classes,
- * event model, date and time facilities, internationalization, and
- * miscellaneous utility classes (a string tokenizer, a random-number
- * generator, and a bit array).
+ * Contains the collections framework, some internationalization support classes,
+ * a service loader, properties, random number generation, string parsing
+ * and scanning classes, base64 encoding and decoding, a bit array, and
+ * several miscellaneous utility classes. This package also contains
+ * legacy collection classes and legacy date and time classes.
*
* {@index "Java Collections Framework"}
+ * For an overview, API outline, and design rationale, please see:
*
*
- * Related Documentation
- * For overviews, tutorials, examples, guides, and tool documentation,
- * please see:
+ * For a tutorial and programming guide with examples of use
+ * of the collections framework, please see:
*
*
* @since 1.0