本文整理匯總了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);
}
示例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.");
}
示例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;
}
示例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);
}
}
}
}
示例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;
}
示例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);
}
示例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);
}
示例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;
}