/** * {@inheritDoc} * * <p>This implementation iterates over the specified collection, and adds * each object returned by the iterator to this collection, in turn. * * <p>Note that this implementation will throw an * <tt>UnsupportedOperationException</tt> unless <tt>add</tt> is * overridden (assuming the specified collection is non-empty). * * @throws UnsupportedOperationException {@inheritDoc} * @throws ClassCastException {@inheritDoc} * @throws NullPointerException {@inheritDoc} * @throws IllegalArgumentException {@inheritDoc} * @throws IllegalStateException {@inheritDoc} * * @see #add(Object) */ publicbooleanaddAll(Collection<? extends E> c){ boolean modified = false; for (E e : c) if (add(e)) modified = true; return modified; }
/** * Returns a {@link Collection} view of the values contained in this map. * The collection is backed by the map, so changes to the map are * reflected in the collection, and vice-versa. If the map is * modified while an iteration over the collection is in progress * (except through the iterator's own <tt>remove</tt> operation), * the results of the iteration are undefined. The collection * supports element removal, which removes the corresponding * mapping from the map, via the <tt>Iterator.remove</tt>, * <tt>Collection.remove</tt>, <tt>removeAll</tt>, * <tt>retainAll</tt> and <tt>clear</tt> operations. It does not * support the <tt>add</tt> or <tt>addAll</tt> operations. * * @return a view of the values contained in this map */ public Collection<V> values(){ Collection<V> vs = values; if (vs == null) { vs = new Values(); values = vs; } return vs; }
finalclassValuesextendsAbstractCollection<V> { publicfinalintsize(){ return size; } publicfinalvoidclear(){ HashMap.this.clear(); } publicfinal Iterator<V> iterator(){ returnnew ValueIterator(); } publicfinalbooleancontains(Object o){ return containsValue(o); } publicfinal Spliterator<V> spliterator(){ returnnew ValueSpliterator<>(HashMap.this, 0, -1, 0, 0); } publicfinalvoidforEach(Consumer<? super V> action){ Node<K,V>[] tab; if (action == null) thrownew NullPointerException(); if (size > 0 && (tab = table) != null) { int mc = modCount; for (int i = 0; i < tab.length; ++i) { for (Node<K,V> e = tab[i]; e != null; e = e.next) action.accept(e.value); } if (modCount != mc) thrownew ConcurrentModificationException(); } } }
/** * Constructs a list containing the elements of the specified * collection, in the order they are returned by the collection's * iterator. * * @param c the collection whose elements are to be placed into this list * @throws NullPointerException if the specified collection is null */ publicArrayList(Collection<? extends E> c){ elementData = c.toArray(); if ((size = elementData.length) != 0) { // c.toArray might (incorrectly) not return Object[] (see 6260652) if (elementData.getClass() != Object[].class) elementData = Arrays.copyOf(elementData, size, Object[].class); } else { // replace with empty array. this.elementData = EMPTY_ELEMENTDATA; } }
List<ISynchro> allISynchros = new ArrayList<ISynchro>(synchroCache.values()); List<ISynchro> npcISynchros = new ArrayList<ISynchro>(synchroNpcCache.values());