List of usage examples for java.util IdentityHashMap IdentityHashMap
public IdentityHashMap()
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);//from w ww. j a v a2 s .c o m System.out.println(v1); Object v2 = objMap.get(o2); System.out.println(v2); // check if key 3 exists boolean isavailable = objMap.containsKey(o1); System.out.println(isavailable); }
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);//w w w .j a v a 2s .c o m System.out.println(v1); Object v2 = objMap.get(o2); System.out.println(v2); objMap.clear(); System.out.println("Map content after clear: " + objMap); }
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);//from www . j av a2s.c o m System.out.println(v1); 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: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);/*from ww w .j a v a 2s .com*/ System.out.println(v1); 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);/*from w w w . ja v a 2s.c o m*/ System.out.println(v1); Object v2 = objMap.get(o2); System.out.println(v2); System.out.println("Value at key '2' is: " + objMap.get(o1)); }
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);/*from ww w.j a v a 2 s. c o m*/ System.out.println(v1); Object v2 = objMap.get(o2); System.out.println(v2); Map<Object, Object> objMap1 = new IdentityHashMap<Object, Object>(); System.out.println(objMap1.equals(objMap)); }
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);/*w w w . j a v a2 s . co m*/ System.out.println(v1); 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 <K, V> IdentityHashMap<K, V> getIdentityHashMap() { return new IdentityHashMap<K, V>(); }
From source file:Main.java
public static <K, V> IdentityHashMap<K, V> createIdentityHashMap() { return new IdentityHashMap<K, V>(); }
From source file:Main.java
public static <K, V> Map<K, V> makeIdentityMap() { return new IdentityHashMap<K, V>(); }