publicPriorityQueue(SortedSet<? extends E> coll)
Creates a new PriorityQueue whose initial contents are the contents of
coll. The capacity of the queue is initially 110% of the size of coll to
allow for some growth without resizing. This queue will be ordered the same
way as coll.
publicPriorityQueue(PriorityQueue<? extends E> coll)
Creates a new PriorityQueue whose initial contents are the contents of
coll. The capacity of the queue is initially 110% of the size of coll to
allow for some growth without resizing. This queue will be ordered the same
way as coll.
Since PriorityQueue does not accept null elements, all constructors that take collections throw
NullPointerException if a null element is encountered.
The comparator used to construct the priority queue can be retrieved with the comparator method. This has
the same contract as the comparator method in SortedSet, returning null if the elements' natural
ordering is being used.
21.8. Map and SortedMap
The interface Map<K,V> does not extend Collection because it has a contract that is different in
important ways. The primary difference is that you do not add an element to a Mapyou add a key/value pair.
A Map allows you to look up the value stored under a key. A given key (as defined by the equals method of
the key) maps to one value or no values. A value can be mapped to by as many keys as you like. For example,
you might use a map to store a mapping of a person's name to their address. If you have an address listed
under a name, there will be exactly one in the map. If you have no mapping, there will be no address value for
that name. Multiple people might share a single address, so the map might return the same value for two or
more names.
The basic methods of the Map interface are
public intsize()
Returns the size of this map, that is, the number of key/value mappings it
currently holds. The return value is limited to Integer.MAX_VALUE even
if the map contains more elements.
public booleanisEmpty()
Returns TRue if this collection currently holds no mappings.
public booleancontainsKey(Object key)
Returns true if the collection contains a mapping for the given key.
public booleancontainsValue(Object value)
Returns TRue if the collection contains at least one mapping to the given
value.