Changeset 409
- Timestamp:
- 06/14/10 14:36:59 (20 months ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
trunk/org.bridgedb/src/org/bridgedb/impl/InternalUtils.java
r308 r409 192 192 /** 193 193 * Generic method for multimaps, a map that can contain multiple values per key. 194 */ 194 * Unlike a regular map, if you insert a value for a key that already exists, the previous value 195 * will not be discared. 196 * @param <T> key type of multimap 197 * @param <U> value type of multimap 198 * @param map multimap to work on 199 * @param key key of the value to insert 200 * @param val value to insert. 201 */ 195 202 public static <T, U> void multiMapPut(Map<T, Set<U>> map, T key, U val) 196 203 { … … 210 217 /** 211 218 * Generic method for multimaps, a map that can contain multiple values per key. 219 * Unlike a regular map, if you insert a value for a key that already exists, the previous value 220 * will not be discared. 221 * <p> 222 * multiMapPutAll let's you insert a collection of items at once. 223 * @param <T> key type of multimap 224 * @param <U> value type of multimap 225 * @param map multimap to work on 226 * @param key key of the value to insert 227 * @param vals values to insert. 212 228 */ 213 229 public static <T, U> void multiMapPutAll(Map<T, Set<U>> map, T key, Collection<U> vals) … … 226 242 } 227 243 244 /** 245 * Split a heterogeneous Xref set into multiple homogeneous Xref sets. 246 * <p> 247 * If the input contains {L:3643, L:1234, X:1004_at, X:1234_at}, 248 * then the output will contain 249 * { L=> {L:3643, L:1234}, X=> {X:1004_at, X:1234_at} }. 250 * @param srcXrefs the set to split 251 * @return map with datasources as keys and homogeneous sets as values. 252 */ 253 public static Map<DataSource, Set<Xref>> groupByDataSource(Collection<Xref> srcXrefs) 254 { 255 Map<DataSource, Set<Xref>> result = new HashMap<DataSource, Set<Xref>>(); 256 for (Xref ref : srcXrefs) 257 { 258 multiMapPut(result, ref.getDataSource(), ref); 259 } 260 return result; 261 } 262 228 263 }
