java.util.HashMapcom.google.common.collect.Maps



Project Graylog2/graylog2-server in file ...ava.org.graylog2.inputs.gelf.GELFChunkManager.java (2012-04-30)
@@ -21,12 +21,13 @@
 package org.graylog2.inputs.gelf;
 
 import java.io.ByteArrayOutputStream;
-import java.util.HashMap;
 import java.util.Map;
 import java.util.concurrent.ConcurrentHashMap;
 import org.apache.log4j.Logger;
 import org.graylog2.GraylogServer;
 
+import com.google.common.collect.Maps;
+
 /**
  * GELFChunkManager.java: 13.04.2012 22:38:40
  *
@@ -155,7 +156,7 @@ public class GELFChunkManager extends Thread {
             chunks.get(chunk.getId()).put(chunk.getSequenceNumber(), chunk);
         } else {
             // First chunk of message.
-            Map<Integer, GELFMessageChunk> c = new HashMap<Integer, GELFMessageChunk>();
+            Map<Integer, GELFMessageChunk> c = Maps.newHashMap();
             c.put(chunk.getSequenceNumber(), chunk);
             chunks.put(chunk.getId(), c);
         }
Project SonarSource/sonarqube in file ...a.org.sonar.server.source.index.SourceLineDoc.java (2015-02-05)
@@ -20,6 +20,7 @@
 package org.sonar.server.source.index;
 
 import com.google.common.collect.ImmutableList;
+import com.google.common.collect.Maps;
 import org.sonar.server.search.BaseDoc;
 import org.sonar.server.search.BaseNormalizer;
 import org.sonar.server.search.IndexUtils;
@@ -29,7 +30,6 @@ import javax.annotation.Nullable;
 
 import java.util.Collection;
 import java.util.Date;
-import java.util.HashMap;
 import java.util.Map;
 
 public class SourceLineDoc extends BaseDoc {
@@ -40,7 +40,7 @@ public class SourceLineDoc extends BaseDoc {
 
   // For testing purpose
   public SourceLineDoc() {
-    this(new HashMap<String, Object>());
+    this(Maps.<String, Object>newHashMap());
   }
 
   public String projectUuid() {
Project SonarSource/sonarqube in file ....main.java.org.sonar.api.checks.NoSonarFilter.java (2011-12-05)
@@ -19,11 +19,11 @@
  */
 package org.sonar.api.checks;
 
+import com.google.common.collect.Maps;
 import org.sonar.api.resources.Resource;
 import org.sonar.api.rules.Violation;
 import org.sonar.api.rules.ViolationFilter;
 
-import java.util.HashMap;
 import java.util.Map;
 import java.util.Set;
 
@@ -32,7 +32,7 @@ import java.util.Set;
  */
 public class NoSonarFilter implements ViolationFilter {
 
-  private final Map<Resource, Set<Integer>> noSonarLinesByResource = new HashMap<Resource, Set<Integer>>();
+  private final Map<Resource, Set<Integer>> noSonarLinesByResource = Maps.newHashMap();
 
   public void addResource(Resource resource, Set<Integer> noSonarLines) {
     if (resource != null && noSonarLines != null) {
Project apache/mahout in file ...spectral.eigencuts.EigencutsSensitivityMapper.java (2011-06-10)
@@ -18,9 +18,9 @@
 package org.apache.mahout.clustering.spectral.eigencuts;
 
 import java.io.IOException;
-import java.util.HashMap;
 import java.util.Map;
 
+import com.google.common.collect.Maps;
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.io.IntWritable;
 import org.apache.hadoop.mapreduce.Mapper;
@@ -71,7 +71,7 @@ public class EigencutsSensitivityMapper extends
     
     // go through the vector, performing the calculations
     // sadly, no way to get around n^2 computations      
-    Map<Integer, EigencutsSensitivityNode> columns = new HashMap<Integer, EigencutsSensitivityNode>();
+    Map<Integer, EigencutsSensitivityNode> columns = Maps.newHashMap();
     Vector ev = vw.get();
     for (int i = 0; i < ev.size(); i++) {
       double minsij = Double.MAX_VALUE;
Project apache/mahout in file ...che.mahout.fpm.pfpgrowth.fpgrowth.LeastKCache.java (2011-06-10)
@@ -17,8 +17,9 @@
 
 package org.apache.mahout.fpm.pfpgrowth.fpgrowth;
 
+import com.google.common.collect.Maps;
+
 import java.util.Collections;
-import java.util.HashMap;
 import java.util.Map;
 import java.util.PriorityQueue;
 
@@ -30,7 +31,7 @@ public class LeastKCache<K extends Comparable<? super K>,V> {
   
   public LeastKCache(int capacity) {
     this.capacity = capacity;
-    cache = new HashMap<K,V>(capacity);
+    cache = Maps.newHashMapWithExpectedSize(capacity);
     queue = new PriorityQueue<K>(capacity + 1, Collections.reverseOrder());
   }