List of usage examples for java.util HashMap containsValue
public boolean containsValue(Object value)
From source file:Main.java
public static void main(String[] args) { HashMap<String, String> hMap = new HashMap<String, String>(); hMap.put("1", "One"); hMap.put("2", "Two"); hMap.put("3", "Three"); System.out.println(hMap.containsValue("Two")); }
From source file:Main.java
public static void main(String[] a) { HashMap<String, String> map = new HashMap<String, String>(); map.put("key1", "value1"); map.put("key2", "value2"); map.put("key3", "value3"); System.out.println(map.containsKey("key1")); System.out.println(map.containsValue("value2")); }
From source file:Main.java
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")); }
From source file:lsafunctions.LSA.java
private static HashMap addToDicry(String[] listLema1, HashMap dicry, int i) { for (String item : listLema1) { if (!dicry.containsValue(item.toLowerCase())) { dicry.put(i, item.toLowerCase()); i++;/* ww w .j av a 2 s .c o m*/ } } return dicry; }
From source file:Main.java
public static HashMap<Integer, String> newDictLZW(String inMsg) { HashMap<Integer, String> dict = new HashMap<Integer, String>(); int j = 0;/*from w w w .jav a 2s .c o m*/ for (int i = 0; i < inMsg.length(); i++) { if (dict.containsValue(Character.toString(inMsg.charAt(i))) == false && inMsg.charAt(i) != '\n') { dict.put((Integer) j, Character.toString(inMsg.charAt(i))); j++; } } return dict; }
From source file:Main.java
public static boolean encodeLZW(String inText, int dictSize, int[] encodedData) { int[] returnData = { 0 }; try {/*from w w w . j a v a 2s .c o m*/ encodedData = new int[inText.length()]; int outCount = 0; HashMap<Integer, String> dict = newDictLZW(inText); String teststring = ""; for (int i = 0; i < inText.length() - 1; i++) { teststring = String.valueOf(inText.charAt(i)); String prevstring = teststring; int j = 0; // System.out.println("teststring = " + teststring + // "; prevstring= " + prevstring + "; i= " + i); while (dict.containsValue(teststring) && i + j < inText.length() - 1) { prevstring = teststring; j++; teststring = teststring.concat(String.valueOf(inText.charAt(i + j))); } // get key value for the string that matched Integer mapIndex = (getKeyByValue(dict, prevstring)); // add this key to the encoded outText as string (ASCII 8 bit) outText = // outText.concat(String.valueOf(((char)Integer.parseInt(mapIndex)))); encodedData[outCount] = mapIndex; outCount++; // add to dictionary the string that matched plus the next char in // sequence in inText // test that the new dictionary entry is not in the dictionary and // does not contain the new-line character if (!dict.containsValue(teststring) && teststring.charAt(teststring.length() - 1) != '\n' && dict.size() < dictSize) dict.put(dict.size(), teststring); // set index value i to point to that next char in sequence i = i + j - 1; } // TODO add switch to turn printing on and off System.out.println("\n-- Dictionary --"); printDictionary(dict); returnData = new int[outCount]; // count entries and use here. for (int i = 0; i < outCount; i++) { returnData[i] = encodedData[i]; } encodedData = returnData; } catch (Exception ex) { System.err.println( "---------------------------------------------\nencodeLZW() method failed\nprobably tried to encode an incompatable file\n---------------------------------------------"); return false; } return true; }
From source file:Main.java
public static String decodeLZW(int[] encodedText, HashMap<Integer, String> dict, int dictSize) { String decodedText = ""; for (int i = 0; i < encodedText.length; i++) { String nextString = ""; String currentEntry = dict.get(encodedText[i]); decodedText = decodedText.concat(currentEntry); if (i + 1 < encodedText.length && dict.size() < dictSize) { if (encodedText[i + 1] < dict.size()) nextString = dict.get(encodedText[i + 1]); else//from w ww .j a v a2 s.co m nextString = currentEntry; String nextChar = String.valueOf(nextString.charAt(0)); if (!dict.containsValue(currentEntry.concat(nextChar))) { dict.put(dict.size(), currentEntry.concat(nextChar)); } } } return decodedText; }
From source file:org.starnub.starnubserver.connections.player.character.CharacterIP.java
public HashSet<CharacterIP> getCompleteAssociations(PlayerCharacter playerCharacter) { HashSet<CharacterIP> completeSeenList = new HashSet<>(); HashMap<Object, Boolean> hasNotBeenChecked = new HashMap<>(); hasNotBeenChecked.put(playerCharacter, false); while (hasNotBeenChecked.containsValue(false)) { for (Map.Entry<Object, Boolean> entry : hasNotBeenChecked.entrySet()) { Object key = entry.getKey(); List<CharacterIP> characterIPs; if (key instanceof PlayerCharacter) { characterIPs = CharacterIP.getCharacterIpLogsByCharacter((PlayerCharacter) key); } else { characterIPs = CharacterIP.getCharacterIpLogsByIP((String) key); }//from w w w. ja v a 2 s .c o m entry.setValue(true); completeSeenList.addAll(characterIPs); for (CharacterIP characterIP : characterIPs) { PlayerCharacter playerCharacter1 = characterIP.getPlayerCharacter(); String ipString = characterIP.getSessionIpString(); if (hasNotBeenChecked.containsKey(playerCharacter1)) { hasNotBeenChecked.put(playerCharacter1, false); } if (hasNotBeenChecked.containsKey(ipString)) { hasNotBeenChecked.put(ipString, false); } } } } return completeSeenList; }
From source file:org.kuali.ole.select.service.impl.OleDocStoreSearchService.java
/** * This method invokes docstore search query with multiple document uuids * * @param cl/*from w w w . j a va 2 s. c o m*/ * @param attr * @param vals * @return * @throws Exception */ public List getResult(Class cl, String attr, List<Object> vals) throws Exception { LOG.debug("Inside getResult of OleDocStoreSearchService"); List result = new ArrayList(0); int maxLimit = Integer.parseInt(SpringContext.getBean(ConfigurationService.class) .getPropertyValueAsString(OLEConstants.DOCSEARCH_ORDERQUEUE_LIMIT_KEY)); List<DocInfoBean> docInfoBeanList = new ArrayList<DocInfoBean>(0); StringBuilder query = new StringBuilder("q="); query.append("(DocType:bibliographic AND ("); HashMap titleIdMap = new HashMap(); int loop = 0; for (Object iv : vals) { String id = iv.toString(); boolean isIdExists = titleIdMap.containsValue(id); titleIdMap.put(id, id); if (!isIdExists) { if (loop != 0) query.append(" OR "); query.append("id:" + id + " "); loop++; } if (loop == maxLimit) break; } query.append("))"); // Changes to include userId in docstore URl. if (GlobalVariables.getUserSession() != null) { query.append("&userId=" + GlobalVariables.getUserSession().getPerson().getPrincipalName()); } query.append("&rows=" + loop); if (LOG.isDebugEnabled()) LOG.debug("Doc Store Query :" + query.toString()); if (loop > 0) { docInfoBeanList = getResponse(query.toString()); result = getDocResult(docInfoBeanList); } LOG.debug("Leaving getResult of OleDocStoreSearchService"); return result; }
From source file:net.wespot.pim.view.InqCommunicateFragment.java
@Override public void handleNotification(HashMap<String, String> map) { if (map.containsKey("type")) { if (map.containsValue("org.celstec.arlearn2.beans.notification.MessageNotification")) { Log.i(TAG, "retrieve messages"); if (!ARL.eventBus.isRegistered(this)) { ARL.eventBus.register(this); }//w w w . j a va 2s. c o m Long runId = Long.parseLong(map.get("runId")); INQ.runs.syncRun(runId); INQ.messages.syncMessagesForDefaultThread(runId); } } }