public class Hash_Map_Demo { 
    public static void main(String[] args) 
    { 
  
        // Creating an empty HashMap 
        HashMap<Integer, String> hash_map = new HashMap<Integer, String>(); 
  
        // Mapping string values to int keys 
        hash_map.put(10, "Geeks"); 
        hash_map.put(15, "4"); 
        hash_map.put(20, "Geeks"); 
        hash_map.put(25, "Welcomes"); 
        hash_map.put(30, "You"); 
  
        // Displaying the HashMap 
        System.out.println("Initial Mappings are: " + hash_map); 
  
        // Checking for the Value 'Geeks' 
        System.out.println("Is the value 'Geeks' present? " +  
        hash_map.containsValue("Geeks")); 
  
        // Checking for the Value 'World' 
        System.out.println("Is the value 'World' present? " +  
        hash_map.containsValue("World")); 
    } 
}

        

public class HashMapDemo {
   public static void main(String args[]) {
      
      // create hash map
      HashMap newmap = new HashMap();

      // populate hash map
      newmap.put(1, "tutorials");
      newmap.put(2, "point");
      newmap.put(3, "is best"); 

      // check existence of value 'point'
      System.out.println("Check if value 'point' exists: " + 
      newmap.containsValue("point"));
   }    
}

        

public class HashMapContainsValueExample {

	public static void main(String args[]) throws InterruptedException {

		// initialize the hashmap object with Integer as key and String as value
		HashMap<Integer, String> mapStudent = new HashMap<Integer, String>();
		
		// populate the student map
		mapStudent.put(13215, "Steve Atkins");
		mapStudent.put(17891, "Albert Travis");
		mapStudent.put(98412, "Paolo Quintos");
		
		// get the user input of student name
		Scanner scan = new Scanner(System.in);
		System.out.print("Enter Student Name:");
		String name = scan.nextLine();
		
		// check if the student name were in student HashMap
		if(mapStudent.containsValue(name)){
			System.out.println("Student "+name +" found on the database");			
		}
		else{
			System.out.println("Student "+name +" not found");
		}
		
		// close the scanner object to avoid memory leak
		scan.close();			

	}
}

        

public class ContainsValueMethodHashMapExample 
{
    public static void main(String args[])
    {
        // create an empty HashMap
        HashMap<Integer,String>  hashMap1 = new HashMap<Integer,String>();
        
        // use put() method to put elements to the HashMap
        hashMap1.put(1,"Element1");
        hashMap1.put(2,"Element2");
        hashMap1.put(3,"Element3");
        hashMap1.put(4,"Element4");
        hashMap1.put(5,"Element5");
        
        //Check if the hashmap1 contains value "Element3"
        System.out.println("Does \"hashMap1\" contains value \"Element3\" : "+hashMap1.containsValue("Element3"));
    }
}

        

public class Main {
   public static void main(String args[]) {
      HashMap<Integer, String> newmap = new HashMap<Integer, String>();      
      
      // populate hash map
      newmap.put(1, "tutorials");
      newmap.put(2, "from");
      newmap.put(3, "java2s.com");
      
      // check existence of value 'point'
      System.out.println("Check if value 'point' exists: " + 
      newmap.containsValue("point"));
   }    
}

        

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.");
}

        

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;
}

        

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);
      	}
      }
 	}
  }

        

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;
}

        

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.");
}        
main