Changeset 7275 in josm for trunk/src/org/openstreetmap/josm/tools/MultiMap.java
- Timestamp:
- 2014-06-29T17:35:10+02:00 (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/tools/MultiMap.java
r7005 r7275 12 12 13 13 /** 14 * MultiMap - maps keys to multiple values 14 * MultiMap - maps keys to multiple values. 15 15 * 16 16 * Corresponds to Google guava LinkedHashMultimap and Apache Collections MultiValueMap 17 17 * but it is an independent (simple) implementation. 18 18 * 19 * @param <A> Key type 20 * @param <B> Value type 21 * 22 * @since 2702 19 23 */ 20 24 public class MultiMap<A, B> { … … 30 34 31 35 /** 32 * Constructs a new {@code MultiMap} with the specified initial capacity. 36 * Constructs a new {@code MultiMap} with the specified initial capacity. 33 37 * @param capacity the initial capacity 34 38 */ … … 41 45 * 42 46 * Can be called multiple times with the same key, but different value. 47 * @param key key with which the specified value is to be associated 48 * @param value value to be associated with the specified key 43 49 */ 44 50 public void put(A key, B value) { … … 56 62 * Afterwards containsKey(key) will return true and get(key) will return 57 63 * an empty Set instead of null. 64 * @param key key with which an empty set is to be associated 58 65 */ 59 66 public void putVoid(A key) { … … 67 74 * 68 75 * Adds to the mappings that are already there. 76 * @param key key with which the specified values are to be associated 77 * @param values values to be associated with the specified key 69 78 */ 70 79 public void putAll(A key, Collection<B> values) { … … 79 88 /** 80 89 * Get the keySet. 90 * @return a set view of the keys contained in this map 91 * @see Map#keySet() 81 92 */ 82 93 public Set<A> keySet() { … … 90 101 * Modifications of the returned list changes the underling map, 91 102 * but you should better not do that. 103 * @param key the key whose associated value is to be returned 104 * @return the set of values to which the specified key is mapped, or {@code null} if this map contains no mapping for the key 105 * @see Map#get(Object) 92 106 */ 93 107 public Set<B> get(A key) { … … 97 111 /** 98 112 * Like get, but returns an empty Set if nothing has been mapped to the key. 113 * @param key the key whose associated value is to be returned 114 * @return the set of values to which the specified key is mapped, or an empty set if this map contains no mapping for the key 99 115 */ 100 116 public Set<B> getValues(A key) { … … 104 120 } 105 121 122 /** 123 * Returns {@code true} if this map contains no key-value mappings. 124 * @return {@code true} if this map contains no key-value mappings 125 * @see Map#isEmpty() 126 */ 106 127 public boolean isEmpty() { 107 128 return map.isEmpty(); 108 129 } 109 130 131 /** 132 * Returns {@code true} if this map contains a mapping for the specified key. 133 * @param key key whose presence in this map is to be tested 134 * @return {@code true} if this map contains a mapping for the specified key 135 * @see Map#containsKey(Object) 136 */ 110 137 public boolean containsKey(A key) { 111 138 return map.containsKey(key); … … 124 151 } 125 152 153 /** 154 * Removes all of the mappings from this map. The map will be empty after this call returns. 155 * @see Map#clear() 156 */ 126 157 public void clear() { 127 158 map.clear(); 128 159 } 129 160 161 /** 162 * Returns a Set view of the mappings contained in this map. 163 * The set is backed by the map, so changes to the map are reflected in the set, and vice-versa. 164 * @return a set view of the mappings contained in this map 165 * @see Map#entrySet() 166 */ 130 167 public Set<Entry<A, Set<B>>> entrySet() { 131 168 return map.entrySet(); … … 134 171 /** 135 172 * Returns the number of keys. 173 * @return the number of key-value mappings in this map 174 * @see Map#size() 136 175 */ 137 176 public int size() { … … 141 180 /** 142 181 * Returns a collection of all value sets. 182 * @return a collection view of the values contained in this map 183 * @see Map#values() 143 184 */ 144 185 public Collection<Set<B>> values() { … … 147 188 148 189 /** 149 * Removes a cerain key=value mapping. 150 * 151 * @return true, if something was removed 190 * Removes a certain key=value mapping. 191 * @param key key whose mapping is to be removed from the map 192 * @param value value whose mapping is to be removed from the map 193 * 194 * @return {@code true}, if something was removed 152 195 */ 153 196 public boolean remove(A key, B value) { … … 161 204 /** 162 205 * Removes all mappings for a certain key. 206 * @param key key whose mapping is to be removed from the map 207 * @return the previous value associated with key, or {@code null} if there was no mapping for key. 208 * @see Map#remove(Object) 163 209 */ 164 210 public Set<B> remove(A key) {
Note:
See TracChangeset
for help on using the changeset viewer.