Lines Matching refs:collection

46  * a multimap as a map that associates each key with a collection of values. All
51 * #createCollection()}, which creates an empty collection of values for a key.
56 * to create the collection of values for that key. The subclass should not call
65 * <p>Keys and values may be null, as long as the underlying collection classes
69 * allow duplicates. If the collection, such as a {@link Set}, does not support
72 * List} that allow duplicates, the collection will keep the existing key-value
92 * The map variable contains the collection of values associated with each
94 * contain any values for that key, a new collection generated by
95 * createCollection is added to the map. That same collection instance
97 * all values for the key are removed, the key and collection are removed
100 * The get method returns a WrappedCollection, which decorates the collection
101 * in the map (if the key is present) or an empty collection (if the key is
102 * not present). When the collection delegate in the WrappedCollection is
134 * Creates the collection of values for a single key.
139 * <p>The returned collection class determines whether duplicate key-value
142 * @return an empty collection of values
147 * Creates the collection of values for an explicitly provided key. By
152 * @param key key to associate with values in the collection
153 * @return an empty collection of values
182 for (Collection<V> collection : map.values()) {
183 if (collection.contains(value)) {
193 Collection<V> collection = map.get(key);
194 return collection != null && collection.contains(value);
201 Collection<V> collection = getOrCreateCollection(key);
203 if (collection.add(value)) {
212 Collection<V> collection = map.get(key);
213 if (collection == null) {
214 collection = createCollection(key);
215 map.put(key, collection);
217 return collection;
222 Collection<V> collection = map.get(key);
223 if (collection == null) {
227 boolean changed = collection.remove(value);
230 if (collection.isEmpty()) {
244 Collection<V> collection = getOrCreateCollection(key);
245 int oldSize = collection.size();
250 changed = collection.addAll(c);
253 changed |= collection.add(value);
257 totalSize += (collection.size() - oldSize);
273 * <p>The returned collection is immutable.
283 Collection<V> collection = getOrCreateCollection(key);
285 oldValues.addAll(collection);
287 totalSize -= collection.size();
288 collection.clear();
291 if (collection.add(iterator.next())) {
302 * <p>The returned collection is immutable.
306 Collection<V> collection = map.remove(key);
309 if (collection != null) {
310 output.addAll(collection);
311 totalSize -= collection.size();
312 collection.clear();
319 Collection<V> collection) {
320 if (collection instanceof SortedSet) {
321 return Collections.unmodifiableSortedSet((SortedSet<V>) collection);
322 } else if (collection instanceof Set) {
323 return Collections.unmodifiableSet((Set<V>) collection);
324 } else if (collection instanceof List) {
325 return Collections.unmodifiableList((List<V>) collection);
327 return Collections.unmodifiableCollection(collection);
333 // Clear each collection, to make previously returned collections empty.
334 for (Collection<V> collection : map.values()) {
335 collection.clear();
346 * <p>The returned collection is not serializable.
350 Collection<V> collection = map.get(key);
351 if (collection == null) {
352 collection = createCollection(key);
354 return wrapCollection(key, collection);
358 * Generates a decorated collection that remains consistent with the values in
360 * returned collection, and vice versa.
363 @Nullable K key, Collection<V> collection) {
364 if (collection instanceof SortedSet) {
365 return new WrappedSortedSet(key, (SortedSet<V>) collection, null);
366 } else if (collection instanceof Set) {
367 return new WrappedSet(key, (Set<V>) collection);
368 } else if (collection instanceof List) {
369 return wrapList(key, (List<V>) collection, null);
371 return new WrappedCollection(key, collection, null);
385 * have a delegate pointing to the underlying collection class.
394 * given key. Its ancestor field points to the full wrapped collection with
397 * of the full wrapped collection.
415 * If the delegate collection is empty, but the multimap has values for the
416 * key, replace the delegate with the new collection for the key.
436 * If collection is empty, remove it from {@code AbstractMultimap.this.map}.
437 * For subcollections, check whether the ancestor collection is empty.
454 * collection.
566 @Override public boolean addAll(Collection<? extends V> collection) {
567 if (collection.isEmpty()) {
571 boolean changed = delegate.addAll(collection);
639 private Iterator<V> iteratorOrListIterator(Collection<V> collection) {
640 return (collection instanceof List)
641 ? ((List<V>) collection).listIterator()
642 : collection.iterator();
910 Collection<V> collection = entry.getValue();
912 totalSize -= collection.size();
913 collection.clear();
922 Collection<V> collection = subMap.remove(key);
923 if (collection != null) {
924 count = collection.size();
925 collection.clear();
1010 Collection<V> collection;
1012 collection = map.remove(key);
1020 if (collection != null) {
1021 count = collection.size();
1022 collection.clear();
1033 * <p>The iterator generated by the returned collection traverses the values
1059 * <p>The iterator generated by the returned collection traverses the values
1064 * collection or its iterator.
1111 Collection<V> collection;
1126 collection = entry.getValue();
1127 valueIterator = collection.iterator();
1146 if (collection.isEmpty()) {
1191 Collection<V> collection = Maps.safeGet(submap, key);
1192 if (collection == null) {
1197 return wrapCollection(k, collection);
1210 Collection<V> collection = submap.remove(key);
1211 if (collection == null) {
1216 output.addAll(collection);
1217 totalSize -= collection.size();
1218 collection.clear();
1274 Collection<V> collection;
1285 collection = entry.getValue();
1286 return Maps.immutableEntry(key, wrapCollection(key, collection));
1292 totalSize -= collection.size();
1293 collection.clear();