List of usage examples for java.util IdentityHashMap get
@SuppressWarnings("unchecked") public V get(Object key)
From source file:Main.java
public static void main(String[] argv) throws Exception { IdentityHashMap<Object, Object> objMap = new IdentityHashMap<Object, Object>(); Object o1 = new Integer(123); Object o2 = new Integer(123); objMap.put(o1, "first"); objMap.put(o2, "from java2s.com"); Object v1 = objMap.get(o1); System.out.println(v1);/*from w w w. j a v a 2 s. c om*/ Object v2 = objMap.get(o2); System.out.println(v2); // create a set view Set<Object> nset = objMap.keySet(); System.out.println("Set view is: " + nset); }
From source file:Main.java
public static void main(String[] argv) throws Exception { IdentityHashMap<Object, Object> objMap = new IdentityHashMap<Object, Object>(); Object o1 = new Integer(123); Object o2 = new Integer(123); objMap.put(o1, "first"); objMap.put(o2, "from java2s.com"); Object v1 = objMap.get(o1); System.out.println(v1);/*ww w.ja va 2 s . c o m*/ Object v2 = objMap.get(o2); System.out.println(v2); // create entry set from the map Set<Entry<Object, Object>> enset = objMap.entrySet(); System.out.println("Set view of the map: " + enset); }
From source file:Main.java
public static void main(String[] argv) throws Exception { IdentityHashMap<Object, Object> objMap = new IdentityHashMap<Object, Object>(); Object o1 = new Integer(123); Object o2 = new Integer(123); objMap.put(o1, "first"); objMap.put(o2, "from java2s.com"); Object v1 = objMap.get(o1); System.out.println(v1);/*from w w w . j a va 2 s .c o m*/ Object v2 = objMap.get(o2); System.out.println(v2); // clone the map IdentityHashMap ihmapclone = (IdentityHashMap) objMap.clone(); System.out.println("Cloned map content: " + ihmapclone); }
From source file:com.google.gerrit.server.project.SectionSortCache.java
private static boolean isIdentityTransform(List<AccessSection> sections, IdentityHashMap<AccessSection, Integer> srcMap) { for (int i = 0; i < sections.size(); i++) { if (i != srcMap.get(sections.get(i))) { return false; }/* w w w .j ava 2s. c o m*/ } return true; }
From source file:org.carrot2.workbench.vis.FlashViewPage.java
private static Cluster mirrorOf(Cluster c, IdentityHashMap<Document, Document> docMapping) { Cluster cMirror = new Cluster(c.getId(), null); for (Document doc : c.getDocuments()) { cMirror.addDocuments(docMapping.get(doc)); }// ww w .j av a 2 s . c o m cMirror.addPhrases(c.getPhrases()); for (Cluster sub : c.getSubclusters()) { cMirror.addSubclusters(mirrorOf(sub, docMapping)); } return cMirror; }
From source file:com.netflix.config.util.ConfigurationUtils.java
/** * Convert CombinedConfiguration into {@link ConcurrentCompositeConfiguration} as the later has better performance * and thread safety. /*ww w . j a v a 2s .co m*/ * * @param config Configuration to be converted */ public static ConcurrentCompositeConfiguration convertToConcurrentCompositeConfiguration( CombinedConfiguration config) { ConcurrentCompositeConfiguration root = new ConcurrentCompositeConfiguration(); IdentityHashMap<Configuration, String> reverseMap = new IdentityHashMap<Configuration, String>(); for (String name : (Set<String>) config.getConfigurationNames()) { Configuration child = config.getConfiguration(name); reverseMap.put(child, name); } for (int i = 0; i < config.getNumberOfConfigurations(); i++) { Configuration child = config.getConfiguration(i); String name = reverseMap.get(child); if (child instanceof CombinedConfiguration) { CombinedConfiguration combinedConf = (CombinedConfiguration) child; ConcurrentCompositeConfiguration newConf = convertToConcurrentCompositeConfiguration(combinedConf); root.addConfiguration(newConf, name); } else { Configuration conf = new ConcurrentMapConfiguration(child); root.addConfiguration((AbstractConfiguration) conf, name); } } return root; }
From source file:com.flipkart.flux.client.runtime.LocalContext.java
public String generateEventName(Event event) { final IdentityHashMap<Event, String> eventNamesMap = this.eventNames.get(); if (!eventNamesMap.containsKey(event)) { eventNamesMap.put(event, generateName(event)); }// w ww .j av a 2 s. c o m return eventNamesMap.get(event); }
From source file:com.qrmedia.commons.persistence.hibernate.clone.wiring.AbstractPropertyModifyingCommand.java
public void execute(IdentityHashMap<Object, Object> entityClones) { if (!entityClones.containsKey(originalEntity)) { throw new AssertionError("No clone for " + originalEntity + " available?!"); }/*w ww.j a v a 2s. c o m*/ wireUpProperty(target, propertyName, entityClones.get(originalEntity)); }
From source file:com.amazon.janusgraph.diskstorage.dynamodb.DynamoDBDelegate.java
/** * Helper method that can clone an Attribute Value * * @param val the AttributeValue to copy * @param sourceDestinationMap used to avoid loops by keeping track of references * @return a copy of val//from w ww. j av a 2 s . c o m */ public static AttributeValue clone(AttributeValue val, IdentityHashMap<AttributeValue, AttributeValue> sourceDestinationMap) { if (val == null) { return null; } if (sourceDestinationMap.containsKey(val)) { return sourceDestinationMap.get(val); } AttributeValue clonedVal = new AttributeValue(); sourceDestinationMap.put(val, clonedVal); if (val.getN() != null) { clonedVal.setN(val.getN()); } else if (val.getS() != null) { clonedVal.setS(val.getS()); } else if (val.getB() != null) { clonedVal.setB(val.getB()); } else if (val.getNS() != null) { clonedVal.setNS(val.getNS()); } else if (val.getSS() != null) { clonedVal.setSS(val.getSS()); } else if (val.getBS() != null) { clonedVal.setBS(val.getBS()); } else if (val.getBOOL() != null) { clonedVal.setBOOL(val.getBOOL()); } else if (val.getNULL() != null) { clonedVal.setNULL(val.getNULL()); } else if (val.getL() != null) { List<AttributeValue> list = new ArrayList<>(val.getL().size()); for (AttributeValue listItemValue : val.getL()) { if (!sourceDestinationMap.containsKey(listItemValue)) { sourceDestinationMap.put(listItemValue, clone(listItemValue, sourceDestinationMap)); } list.add(sourceDestinationMap.get(listItemValue)); } clonedVal.setL(list); } else if (val.getM() != null) { Map<String, AttributeValue> map = new HashMap<>(val.getM().size()); for (Entry<String, AttributeValue> pair : val.getM().entrySet()) { if (!sourceDestinationMap.containsKey(pair.getValue())) { sourceDestinationMap.put(pair.getValue(), clone(pair.getValue(), sourceDestinationMap)); } map.put(pair.getKey(), sourceDestinationMap.get(pair.getValue())); } clonedVal.setM(map); } return clonedVal; }
From source file:de.codesourcery.eve.skills.ui.model.impl.MarketGroupTreeModelBuilder.java
private ITreeNode getOrCreateTreeNode(MarketGroup group, IdentityHashMap<MarketGroup, ITreeNode> nodes) { ITreeNode result = nodes.get(group); if (result == null) { result = new DefaultTreeNode(group); nodes.put(group, result);/*from w w w.j av a 2 s . co m*/ } return result; }