当前位置: 首页>>代码示例>>Java>>正文


Java HashMap.containsValue方法代码示例

本文整理汇总了Java中java.util.HashMap.containsValue方法的典型用法代码示例。如果您正苦于以下问题:Java HashMap.containsValue方法的具体用法?Java HashMap.containsValue怎么用?Java HashMap.containsValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.util.HashMap的用法示例。


在下文中一共展示了HashMap.containsValue方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: main

import java.util.HashMap; //导入方法依赖的package包/类
public static void main(String[] args) {

    //create HashMap object
    HashMap hMap = new HashMap();

    //add key value pairs to HashMap
    hMap.put("1", "One");
    hMap.put("2", "Two");
    hMap.put("3", "Three");

    /*
      To check whether a particular value exists in HashMap use
      boolean containsValue(Object key) method of HashMap class.
      It returns true if the value is mapped to one or more keys in the
      HashMap otherwise false.
    */

    boolean blnExists = hMap.containsValue("Two");
    System.out.println("Two exists in HashMap ? : " + blnExists);
  }
 
开发者ID:tranleduy2000,项目名称:javaide,代码行数:21,代码来源:CheckValueOfHashMapExample.java

示例2: fetchBrokerNameByAddr

import java.util.HashMap; //导入方法依赖的package包/类
public static String fetchBrokerNameByAddr(final MQAdminExt adminExt, final String addr) throws Exception {
    ClusterInfo clusterInfoSerializeWrapper = adminExt.examineBrokerClusterInfo();
    HashMap<String/* brokerName */, BrokerData> brokerAddrTable =
        clusterInfoSerializeWrapper.getBrokerAddrTable();
    Iterator<Map.Entry<String, BrokerData>> it = brokerAddrTable.entrySet().iterator();
    while (it.hasNext()) {
        Map.Entry<String, BrokerData> entry = it.next();
        HashMap<Long, String> brokerAddrs = entry.getValue().getBrokerAddrs();
        if (brokerAddrs.containsValue(addr))
            return entry.getKey();
    }
    throw new Exception(
        "Make sure the specified broker addr exists or the nameserver which connected is correct.");
}
 
开发者ID:lirenzuo,项目名称:rocketmq-rocketmq-all-4.1.0-incubating,代码行数:15,代码来源:CommandUtil.java

示例3: isBalanced

import java.util.HashMap; //导入方法依赖的package包/类
/**
Checks if a string is balanced or not.

 @param s is a non-null string
 @return true of the input <code>s</code> is balanced and false otherwise.
**/
public static boolean isBalanced(String s){
  Stack<Character> stack = new Stack<Character>();
  HashMap<Character, Character> symbols = new HashMap<Character, Character>();

  symbols.put(')' , '(');
  symbols.put('}' , '{');
  symbols.put(']' , '[');

  for (int i = 0; i < s.length(); i++) {
    char c = s.charAt(i);
    if (symbols.containsValue(c)) {
      stack.push(c);
    }
    if (symbols.containsKey(c)) {
      if (stack.empty()) {
        return false;
      } else {
        Character temp = stack.pop();
        if (temp != symbols.get(c)) {
          return false;
        }
      }
    }
  }
  if (stack.empty()) {
    return true;
  }
  return false;
}
 
开发者ID:hughxie,项目名称:class-code,代码行数:36,代码来源:Balanced.java

示例4: deleteClasses

import java.util.HashMap; //导入方法依赖的package包/类
private void deleteClasses(InstructionalOfferingModifyForm frm, InstrOfferingConfig ioc, Session hibSession, HashMap tmpClassIdsToRealClasses){
 	if (ioc.getSchedulingSubparts() != null) {
SchedulingSubpart ss = null;
ArrayList lst = new ArrayList();
      ArrayList subpartList = new ArrayList(ioc.getSchedulingSubparts());
      Collections.sort(subpartList, new SchedulingSubpartComparator());

      for(Iterator it = subpartList.iterator(); it.hasNext();){
      	ss = (SchedulingSubpart) it.next();
      	if (ss.getParentSubpart() == null){
      		buildClassList(ss.getClasses(), lst);
      	}
      }

      Class_ c;
      for (int i = (lst.size() - 1); i >= 0; i--){
      	c = (Class_) lst.get(i);
      	if (!frm.getClassIds().contains(c.getUniqueId().toString()) && !tmpClassIdsToRealClasses.containsValue(c)){
		if (c.getParentClass() != null){
			Class_ parent = c.getParentClass();
			parent.getChildClasses().remove(c);
			hibSession.update(parent);
		}
		c.getSchedulingSubpart().getClasses().remove(c);
		if (c.getPreferences() != null)
		    c.getPreferences().removeAll(c.getPreferences());
		
		c.deleteAllDependentObjects(hibSession, false);
		
		hibSession.delete(c);
      	}
      }
 	}
  }
 
开发者ID:Jenner4S,项目名称:unitimes,代码行数:35,代码来源:InstructionalOfferingModifyAction.java

示例5: getName

import java.util.HashMap; //导入方法依赖的package包/类
private static String getName(Long param, HashMap hm) {
    if (param == null) return null;
    if (!hm.containsValue(param)) return null;

    for (Iterator it = hm.keySet().iterator(); it.hasNext(); ) {
        String key = (String) it.next();
        if (hm.get(key).equals(param)) return key;
    }

    //should not get normally here .... but who knows :)
    return null;
}
 
开发者ID:fast-data-transfer,项目名称:fdt,代码行数:13,代码来源:ApMonMonitoringConstants.java

示例6: main

import java.util.HashMap; //导入方法依赖的package包/类
public static void main(String[] args) {
    Scanner scann = new Scanner(System.in);

    String[] input = scann.nextLine().split("\\s+");
    char[] shorter = input[(input[0].length() > input[1].length()) ? 1 : 0].toCharArray();
    char[] longer = input[(input[0].length() <= input[1].length()) ? 1 : 0].toCharArray();

    boolean output = true;
    HashMap<Character, Character> mapper = new HashMap<Character, Character>();
    for (int i = 0; i < shorter.length; i++) {
        if(!mapper.containsKey(shorter[i])){
            if(mapper.containsValue(longer[i])){
                output = false;
                break;
            } else {
                mapper.put(shorter[i], longer[i]);
            }
        } else {
            if(longer[i] != mapper.get(shorter[i])){
                output = false;
                return;
            }
        }
    }

    for (int i = shorter.length; i < longer.length; i++) {
        if(!mapper.containsValue(longer[i])){
            output = false;
            break;
        }
    }

    System.out.println(output);
}
 
开发者ID:kostovhg,项目名称:SoftUni,代码行数:35,代码来源:p06_MagicExchaneableWords.java

示例7: go

import java.util.HashMap; //导入方法依赖的package包/类
@SingleClick // 防止连续点击
public static void go(String actionName, HashMap data, View view) {
    if (data.containsValue(null)) return;
    TRouter.go(actionName, data, view);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:6,代码来源:RouterHelper.java

示例8: doInBackground

import java.util.HashMap; //导入方法依赖的package包/类
@Override
 protected Void doInBackground(Void... voids) {
     // Get Contact list from Phone

     if (phones != null) {
if(dbContact != null)
         	dbContact.truncateContactTable();
         HashMap<String, String> data = new HashMap<String, String>();
         while (phones.moveToNext()) {
             Bitmap bit_thumb = null;
             String id          = phones.getString(phones.getColumnIndex(ContactsContract.CommonDataKinds.Phone.CONTACT_ID));
             String name        = phones.getString(phones.getColumnIndex(ContactsContract.CommonDataKinds.Phone.DISPLAY_NAME));
             String phoneNumber = phones.getString(phones.getColumnIndex(ContactsContract.CommonDataKinds.Phone.NUMBER));
             String EmailAddr   = phones.getString(phones.getColumnIndex(ContactsContract.CommonDataKinds.Email.DATA2));
             String newPhinr    = phoneNumber.replaceAll("\\s+","").replaceAll("\\-", "").replaceAll("\\(", "").replaceAll("\\)", "").replaceAll("\\#", "").replaceAll("\\_", "");
             String image_thumb = phones.getString(phones.getColumnIndex(ContactsContract.CommonDataKinds.Phone.PHOTO_THUMBNAIL_URI));
             try {
                 if (image_thumb != null) {
                     bit_thumb = MediaStore.Images.Media.getBitmap(resolver, Uri.parse(image_thumb));
                 } else {

                 }
             } catch (IOException e) {
                 e.printStackTrace();
             }
             ContactBean selectUser = new ContactBean();
             if (!data.containsValue(newPhinr)) {
             	selectUser.setThumb(bit_thumb);
                 selectUser.setName(name);
                 selectUser.setNumber(newPhinr);
                 selectUser.setPhotoURI(image_thumb);
                 selectUser.setPinyin(HanziToPinyin.getPinYin(selectUser.getName()));
                 data.put(name, newPhinr);
		if(dbContact != null)
                 dbContact.addContact(selectUser);
                 if (newPhinr != null) {
                 	 selectUsers.add(selectUser);
                 	 nameNum.put(selectUser.getName(), selectUser.getNumber());
                 }
             }

         }
     } else {

     }
     phones.close();
     return null;
 }
 
开发者ID:mityung,项目名称:XERUNG,代码行数:49,代码来源:ContactList.java


注:本文中的java.util.HashMap.containsValue方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。