Changeset 9755 in josm for trunk/src/org/openstreetmap/josm/tools/MultiMap.java
- Timestamp:
- 2016-02-08T00:01:48+01:00 (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/tools/MultiMap.java
r9371 r9755 4 4 import java.util.ArrayList; 5 5 import java.util.Collection; 6 import java.util.Collections; 6 7 import java.util.HashMap; 7 8 import java.util.LinkedHashSet; … … 43 44 44 45 /** 46 * Constructs a new {@code MultiMap} from an ordinary {@code Map}. 47 * @param map0 the {@code Map} 48 */ 49 public MultiMap(Map<A, Set<B>> map0) { 50 if (map0 == null) { 51 map = new HashMap<>(); 52 } else { 53 map = new HashMap<>(Utils.hashMapInitialCapacity(map0.size())); 54 for (Entry<A, Set<B>> e : map0.entrySet()) { 55 map.put(e.getKey(), new LinkedHashSet<>(e.getValue())); 56 } 57 } 58 } 59 60 /** 45 61 * Map a key to a value. 46 62 * … … 216 232 public int hashCode() { 217 233 return Objects.hash(map); 234 } 235 236 /** 237 * Converts this {@code MultiMap} to a {@code Map} with {@code Set} values. 238 * @return the converted {@code Map} 239 */ 240 public Map<A, Set<B>> toMap() { 241 Map<A, Set<B>> result = new HashMap<>(); 242 for (Entry<A, Set<B>> e : map.entrySet()) { 243 result.put(e.getKey(), Collections.unmodifiableSet(e.getValue())); 244 } 245 return result; 218 246 } 219 247
Note:
See TracChangeset
for help on using the changeset viewer.