Tabnine Logo
HashMap.containsKey
Code IndexAdd Tabnine to your IDE (free)

How to use
containsKey
method
in
java.util.HashMap

Best Java code snippets using java.util.HashMap.containsKey (Showing top 20 results out of 32,427)

Refine searchRefine arrow

  • HashMap.get
  • HashMap.put
  • HashMap.<init>
  • PrintStream.println
  • ArrayList.add
  • List.add
origin: libgdx/libgdx

public final int[] getIntArray(int argLength) {
 if (!aints.containsKey(argLength)) {
  aints.put(argLength, new int[argLength]);
 }
 assert (aints.get(argLength).length == argLength) : "Array not built with correct length";
 return aints.get(argLength);
}
origin: stanfordnlp/CoreNLP

private static final String coarsenUPOSTag(String uPOS) {
  if (coarserUPOSMap.containsKey(uPOS)) {
    return coarserUPOSMap.get(uPOS);
  }
  return uPOS;
}
origin: Tencent/tinker

void putSanitizeName(RType rType, String sanitizeName, String rawName) {
  HashMap<String, String> sanitizeNameMap;
  if (!sanitizeTypeMap.containsKey(rType)) {
    sanitizeNameMap = new HashMap<>();
    sanitizeTypeMap.put(rType, sanitizeNameMap);
  } else {
    sanitizeNameMap = sanitizeTypeMap.get(rType);
  }
  if (!sanitizeNameMap.containsKey(sanitizeName)) {
    sanitizeNameMap.put(sanitizeName, rawName);
  }
}
origin: alibaba/jstorm

public static <V> HashMap<V, Integer> multi_set(List<V> list) {
  HashMap<V, Integer> rtn = new HashMap<>();
  for (V v : list) {
    int cnt = 1;
    if (rtn.containsKey(v)) {
      cnt += rtn.get(v);
    }
    rtn.put(v, cnt);
  }
  return rtn;
}
origin: stackoverflow.com

 HashMap<ByteBuffer, byte[]> kvs = new HashMap<ByteBuffer, byte[]>();
byte[] k1 = new byte[]{1,2 ,3};
byte[] k2 = new byte[]{1,2 ,3};
byte[] val = new byte[]{12,23,43,4};

kvs.put(ByteBuffer.wrap(k1), val);
System.out.println(kvs.containsKey(ByteBuffer.wrap(k2)));
origin: oracle/opengrok

void addAlias(String alias) throws IllegalArgumentException {
  names.add(alias);
  
  if (options.containsKey(alias)) {
    throw new IllegalArgumentException("** Programmer error! Option " + alias + " already defined");
  }
  
  options.put(alias, this);
}

origin: geoserver/geoserver

/** Returns the old values of any changed properties. */
public List<Object> getOldValues() {
  List<Object> oldValues = new ArrayList<Object>();
  for (String propertyName : getDirtyProperties()) {
    if (oldCollectionValues().containsKey(propertyName)) {
      oldValues.add(oldCollectionValues.get(propertyName));
    } else {
      try {
        Method g = getter(propertyName);
        if (g == null) {
          throw new IllegalArgumentException("No such property: " + propertyName);
        }
        oldValues.add(g.invoke(proxyObject, null));
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
  }
  return oldValues;
}
origin: azkaban/azkaban

private void handleUpload(final HttpServletRequest req, final HttpServletResponse resp,
  final Map<String, Object> multipart, final Session session) throws ServletException,
  IOException {
 final HashMap<String, String> ret = new HashMap<>();
 final String projectName = (String) multipart.get("project");
 ajaxHandleUpload(req, resp, ret, multipart, session);
 if (ret.containsKey("error")) {
  setErrorMessageInCookie(resp, ret.get("error"));
 }
 if (ret.containsKey("warn")) {
  setWarnMessageInCookie(resp, ret.get("warn"));
 }
 resp.sendRedirect(req.getRequestURI() + "?project=" + projectName);
}
origin: spotbugs/spotbugs

@Override
public ValueNumberFrame getFactAfterLocation(Location location) {
  if (TRACE) {
    System.out.println("getting fact after " + location);
  }
  ValueNumberFrame fact = factAfterLocationMap.get(location);
  if (fact == null) {
    if (TRACE) {
      System.out
      .println("Initialized fact after " + location + " @ "
          + Integer.toHexString(System.identityHashCode(location)) + " in "
          + Integer.toHexString(System.identityHashCode(this)) + " : "
          + factAfterLocationMap.containsKey(location));
    }
    fact = createFact();
    makeFactTop(fact);
    factAfterLocationMap.put(location, fact);
  }
  return fact;
}
origin: Sable/soot

/**
 * @ast method
 * @aspect InnerClasses
 * @declaredat /Users/eric/Documents/workspaces/clara-soot/JastAddJ/Java1.4Backend/InnerClasses.jrag:173
 */
public ASTNode getAccessor(ASTNode source, String name) {
  ArrayList key = new ArrayList(2);
  key.add(source);
  key.add(name);
  if (accessorMap == null || !accessorMap.containsKey(key))
    return null;
  return (ASTNode) accessorMap.get(key);
}
origin: h2oai/h2o-2

public static Request addToNavbar(Request r, String name) {
 assert (!_navbar.containsKey(name));
 ArrayList<MenuItem> arl = new ArrayList();
 boolean useNewTab = false;
 arl.add(new MenuItem(r, name, useNewTab));
 _navbar.put(name, arl);
 _navbarOrdering.add(name);
 return r;
}
origin: Sable/soot

private soot.SootMethod addGetMethodAccessMeth(soot.SootClass conClass, polyglot.ast.Call call) {
 if ((InitialResolver.v().getPrivateMethodGetAccessMap() != null) && (InitialResolver.v().getPrivateMethodGetAccessMap()
   .containsKey(new polyglot.util.IdentityKey(call.methodInstance())))) {
  return InitialResolver.v().getPrivateMethodGetAccessMap().get(new polyglot.util.IdentityKey(call.methodInstance()));
 }
 String name = "access$" + soot.javaToJimple.InitialResolver.v().getNextPrivateAccessCounter() + "00";
 ArrayList paramTypes = new ArrayList();
 if (!call.methodInstance().flags().isStatic()) {
  // add this param type
  // paramTypes.add(Util.getSootType(call.methodInstance().container()));
  paramTypes.add(conClass.getType());
 }
 ArrayList sootParamsTypes = getSootParamsTypes(call);
 paramTypes.addAll(sootParamsTypes);
 soot.SootMethod meth = Scene.v().makeSootMethod(name, paramTypes, Util.getSootType(call.methodInstance().returnType()),
   soot.Modifier.STATIC);
 PrivateMethodAccMethodSource pmams = new PrivateMethodAccMethodSource(call.methodInstance());
 conClass.addMethod(meth);
 meth.setActiveBody(pmams.getBody(meth, null));
 InitialResolver.v().addToPrivateMethodGetAccessMap(call, meth);
 meth.addTag(new soot.tagkit.SyntheticTag());
 return meth;
}
origin: neo4j/neo4j

  @Override
  public Double getCost( Relationship relationship, Direction direction )
  {
    if ( !dirs.containsKey( relationship ) )
    {
      dirs.put( relationship, direction );
    }
    return 1.0;
  }
}
origin: alibaba/jstorm

public static <V> HashMap<V, Integer> multi_set(List<V> list) {
  HashMap<V, Integer> rtn = new HashMap<V, Integer>();
  for (V v : list) {
    int cnt = 1;
    if (rtn.containsKey(v)) {
      cnt += rtn.get(v);
    }
    rtn.put(v, cnt);
  }
  return rtn;
}
origin: jfinal/jfinal

public synchronized <T> AopFactory addMapping(Class<T> from, Class<? extends T> to) {
  if (from == null || to == null) {
    throw new IllegalArgumentException("The parameter from and to can not be null");
  }
  
  if (mapping == null) {
    mapping = new HashMap<Class<?>, Class<?>>(128, 0.25F);
  } else if (mapping.containsKey(from)) {
    throw new RuntimeException("Class already mapped : " + from.getName());
  }
  
  mapping.put(from, to);
  return this;
}
 
origin: plantuml/plantuml

if(getPoints().size() != shape.getPoints().size()) return false;
if(DEBUG) System.out.println("comparing shapes:");
if(DEBUG) System.out.println("points1: ");
HashMap points1 = new HashMap();
Iterator it = getPointsIterator(); 
while(it.hasNext()){
  ShapePoint point = (ShapePoint) it.next(); 
  points1.put( ""+((int) point.x)+","+((int) point.y), null);
  if(DEBUG) System.out.println(((int) point.x)+", "+((int) point.y));
if(DEBUG) System.out.println("points2: ");
HashMap points2 = new HashMap();
it = shape.getPointsIterator(); 
while(it.hasNext()){
  ShapePoint point = (ShapePoint) it.next(); 
  points2.put( ""+((int) point.x)+","+((int) point.y), null);
  if(DEBUG) System.out.println(((int) point.x)+", "+((int) point.y));
while(it.hasNext()){
  String key = (String) it.next();
  if(!points2.containsKey(key)) {
    if (DEBUG)
      System.out.println("\tare not equal");
origin: libgdx/libgdx

public final float[] getFloatArray(int argLength) {
 if (!afloats.containsKey(argLength)) {
  afloats.put(argLength, new float[argLength]);
 }
 assert (afloats.get(argLength).length == argLength) : "Array not built with correct length";
 return afloats.get(argLength);
}
origin: neo4j/neo4j

if ( distances.containsKey( node ) )
distances.put( node, (int) depth );
    if ( !distances.containsKey( targetNode ) )
      targetPreds.add( relationship );
origin: azkaban/azkaban

public void createAndSetScheduleOptions(final Object obj) {
 final HashMap<String, Object> schedObj = (HashMap<String, Object>) obj;
 if (schedObj.containsKey("executionOptions")) {
  final ExecutionOptions execOptions =
    ExecutionOptions.createFromObject(schedObj.get("executionOptions"));
  this.executionOptions = execOptions;
 } else if (schedObj.containsKey("flowOptions")) {
  final ExecutionOptions execOptions =
    ExecutionOptions.createFromObject(schedObj.get("flowOptions"));
  this.executionOptions = execOptions;
  execOptions.setConcurrentOption(ExecutionOptions.CONCURRENT_OPTION_SKIP);
 } else {
  this.executionOptions = new ExecutionOptions();
  this.executionOptions
    .setConcurrentOption(ExecutionOptions.CONCURRENT_OPTION_SKIP);
 }
 if (schedObj.containsKey("slaOptions")) {
  final List<Object> slaOptionsObject = (List<Object>) schedObj.get("slaOptions");
  final List<SlaOption> slaOptions = new ArrayList<>();
  for (final Object slaObj : slaOptionsObject) {
   slaOptions.add(SlaOption.fromObject(slaObj));
  }
  this.slaOptions = slaOptions;
 }
}
origin: azkaban/azkaban

public static Edge fromObject(final Object obj) {
 final HashMap<String, Object> edgeObj = (HashMap<String, Object>) obj;
 final String source = (String) edgeObj.get("source");
 final String target = (String) edgeObj.get("target");
 final String error = (String) edgeObj.get("error");
 final Edge edge = new Edge(source, target);
 edge.setError(error);
 if (edgeObj.containsKey("guides")) {
  final Map<String, Object> guideMap =
    (Map<String, Object>) edgeObj.get("guides");
  final List<Object> values = (List<Object>) guideMap.get("values");
  final String type = (String) guideMap.get("type");
  final ArrayList<Point2D> valuePoints = new ArrayList<>();
  for (final Object pointObj : values) {
   final Map<String, Double> point = (Map<String, Double>) pointObj;
   final Double x = point.get("x");
   final Double y = point.get("y");
   valuePoints.add(new Point2D.Double(x, y));
  }
  edge.setGuides(type, valuePoints);
 }
 return edge;
}
java.utilHashMapcontainsKey

Javadoc

Returns whether this map contains the specified key.

Popular methods of HashMap

  • <init>
    Constructs a new HashMap instance containing the mappings from the specified map.
  • put
    Maps the specified key to the specified value.
  • get
    Returns the value of the mapping with the specified key.
  • keySet
    Returns a set of the keys contained in this map. The set is backed by this map so changes to one are
  • remove
  • entrySet
    Returns a set containing all of the mappings in this map. Each mapping is an instance of Map.Entry.
  • values
    Returns a collection of the values contained in this map. The collection is backed by this map so ch
  • size
    Returns the number of elements in this map.
  • clear
    Removes all mappings from this hash map, leaving it empty.
  • isEmpty
    Returns whether this map is empty.
  • putAll
    Copies all the mappings in the specified map to this map. These mappings will replace all mappings t
  • clone
    Returns a shallow copy of this map.
  • putAll,
  • clone,
  • toString,
  • containsValue,
  • equals,
  • hashCode,
  • computeIfAbsent,
  • getOrDefault,
  • forEach

Popular in Java

  • Parsing JSON documents to java classes using gson
  • setRequestProperty (URLConnection)
  • getResourceAsStream (ClassLoader)
  • putExtra (Intent)
  • ConnectException (java.net)
    A ConnectException is thrown if a connection cannot be established to a remote host on a specific po
  • AtomicInteger (java.util.concurrent.atomic)
    An int value that may be updated atomically. See the java.util.concurrent.atomic package specificati
  • Manifest (java.util.jar)
    The Manifest class is used to obtain attribute information for a JarFile and its entries.
  • DataSource (javax.sql)
    An interface for the creation of Connection objects which represent a connection to a database. This
  • Response (javax.ws.rs.core)
    Defines the contract between a returned instance and the runtime when an application needs to provid
  • FileUtils (org.apache.commons.io)
    General file manipulation utilities. Facilities are provided in the following areas: * writing to a
  • From CI to AI: The AI layer in your organization
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now