List of usage examples for java.util IdentityHashMap size
int size
To view the source code for java.util IdentityHashMap size.
Click Source Link
From source file:Main.java
public static void main(String args[]) { IdentityHashMap<Integer, String> ihmap = new IdentityHashMap<Integer, String>(); ihmap.put(1, "from"); ihmap.put(2, "java2s.com"); ihmap.put(3, "tutorial"); System.out.println("Value of ihmap before: " + ihmap); System.out.println("Size of the map: " + ihmap.size()); }
From source file:com.google.gwt.dev.util.collect.IdentityHashSetTest.java
@SuppressWarnings("unchecked") @Override// w w w . ja va2 s .c o m public Collection makeConfirmedCollection() { final java.util.IdentityHashMap map = new java.util.IdentityHashMap(); return new AbstractSet() { @Override public boolean add(Object e) { return map.put(e, e) == null; } @Override public Iterator iterator() { return map.keySet().iterator(); } @Override public int size() { return map.size(); } }; }
From source file:ca.uhn.fhir.jpa.term.BaseHapiTerminologySvc.java
private void persistChildren(TermConcept theConcept, TermCodeSystemVersion theCodeSystem, IdentityHashMap<TermConcept, Object> theConceptsStack, int theTotalConcepts) { if (theConceptsStack.put(theConcept, PLACEHOLDER_OBJECT) != null) { return;/*from w ww.j a va2 s .c o m*/ } if (theConceptsStack.size() == 1 || theConceptsStack.size() % 10000 == 0) { float pct = (float) theConceptsStack.size() / (float) theTotalConcepts; ourLog.info("Have processed {}/{} concepts ({}%)", theConceptsStack.size(), theTotalConcepts, (int) (pct * 100.0f)); } theConcept.setCodeSystem(theCodeSystem); theConcept.setIndexStatus(BaseHapiFhirDao.INDEX_STATUS_INDEXED); if (theConceptsStack.size() <= myDaoConfig.getDeferIndexingForCodesystemsOfSize()) { saveConcept(theConcept); } else { myConceptsToSaveLater.add(theConcept); } for (TermConceptParentChildLink next : theConcept.getChildren()) { persistChildren(next.getChild(), theCodeSystem, theConceptsStack, theTotalConcepts); } for (TermConceptParentChildLink next : theConcept.getChildren()) { if (theConceptsStack.size() <= myDaoConfig.getDeferIndexingForCodesystemsOfSize()) { saveConceptLink(next); } else { myConceptLinksToSaveLater.add(next); } } }
From source file:com.google.gwt.emultest.java.util.IdentityHashMapTest.java
public void testAddEqualKeys() { final IdentityHashMap expected = new IdentityHashMap(); assertEquals(expected.size(), 0); iterateThrough(expected);// ww w. j a v a2 s .co m expected.put(new Long(45), new Object()); assertEquals(expected.size(), 1); iterateThrough(expected); expected.put(new Integer(45), new Object()); assertNotSame(new Integer(45), new Long(45)); assertEquals(expected.size(), 2); iterateThrough(expected); }
From source file:com.google.gwt.emultest.java.util.IdentityHashMapTest.java
private Iterator iterateThrough(final IdentityHashMap expected) { Iterator iter = expected.entrySet().iterator(); for (int i = 0; i < expected.size(); i++) { iter.next();//from w w w . j av a2 s. c om } return iter; }
From source file:com.google.gwt.emultest.java.util.IdentityHashMapTest.java
public void testClone() { IdentityHashMap srcMap = new IdentityHashMap(); checkEmptyHashMapAssumptions(srcMap); // Check empty clone behavior IdentityHashMap dstMap = (IdentityHashMap) srcMap.clone(); assertNotNull(dstMap);/*www.jav a 2 s.c o m*/ assertEquals(dstMap.size(), srcMap.size()); // assertTrue(dstMap.values().toArray().equals(srcMap.values().toArray())); assertTrue(dstMap.keySet().equals(srcMap.keySet())); assertTrue(dstMap.entrySet().equals(srcMap.entrySet())); // Check non-empty clone behavior srcMap.put(KEY_1, VALUE_1); srcMap.put(KEY_2, VALUE_2); srcMap.put(KEY_3, VALUE_3); dstMap = (IdentityHashMap) srcMap.clone(); assertNotNull(dstMap); assertEquals(dstMap.size(), srcMap.size()); assertTrue(dstMap.keySet().equals(srcMap.keySet())); assertTrue(dstMap.entrySet().equals(srcMap.entrySet())); }
From source file:com.google.gwt.emultest.java.util.IdentityHashMapTest.java
public void testHashMapMap() { IdentityHashMap srcMap = new IdentityHashMap(); assertNotNull(srcMap);/*from w w w . j a va2s . com*/ checkEmptyHashMapAssumptions(srcMap); srcMap.put(INTEGER_1, INTEGER_11); srcMap.put(INTEGER_2, INTEGER_22); srcMap.put(INTEGER_3, INTEGER_33); IdentityHashMap hashMap = new IdentityHashMap(srcMap); assertFalse(hashMap.isEmpty()); assertTrue(hashMap.size() == SIZE_THREE); Collection valColl = hashMap.values(); assertTrue(valColl.contains(INTEGER_11)); assertTrue(valColl.contains(INTEGER_22)); assertTrue(valColl.contains(INTEGER_33)); Collection keyColl = hashMap.keySet(); assertTrue(keyColl.contains(INTEGER_1)); assertTrue(keyColl.contains(INTEGER_2)); assertTrue(keyColl.contains(INTEGER_3)); }
From source file:com.google.gwt.emultest.java.util.IdentityHashMapTest.java
/** * Test method for 'java.util.IdentityHashMap.size()'. *//*from w w w .ja v a2 s . c o m*/ public void testSize() { IdentityHashMap hashMap = new IdentityHashMap(); checkEmptyHashMapAssumptions(hashMap); // Test size behavior on put assertEquals(hashMap.size(), SIZE_ZERO); hashMap.put(KEY_1, VALUE_1); assertEquals(hashMap.size(), SIZE_ONE); hashMap.put(KEY_2, VALUE_2); assertEquals(hashMap.size(), SIZE_TWO); hashMap.put(KEY_3, VALUE_3); assertEquals(hashMap.size(), SIZE_THREE); // Test size behavior on remove hashMap.remove(KEY_1); assertEquals(hashMap.size(), SIZE_TWO); hashMap.remove(KEY_2); assertEquals(hashMap.size(), SIZE_ONE); hashMap.remove(KEY_3); assertEquals(hashMap.size(), SIZE_ZERO); // Test size behavior on putAll hashMap.put(KEY_1, VALUE_1); hashMap.put(KEY_2, VALUE_2); hashMap.put(KEY_3, VALUE_3); IdentityHashMap srcMap = new IdentityHashMap(hashMap); hashMap.putAll(srcMap); assertEquals(hashMap.size(), SIZE_THREE); // Test size behavior on clear hashMap.clear(); assertEquals(hashMap.size(), SIZE_ZERO); }
From source file:com.google.gwt.emultest.java.util.IdentityHashMapTest.java
public void testClear() { IdentityHashMap hashMap = new IdentityHashMap(); checkEmptyHashMapAssumptions(hashMap); hashMap.put("Hello", "Bye"); assertFalse(hashMap.isEmpty());/*w w w. ja v a2 s .co m*/ assertTrue(hashMap.size() == SIZE_ONE); hashMap.clear(); assertTrue(hashMap.isEmpty()); assertTrue(hashMap.size() == 0); }
From source file:com.google.gwt.emultest.java.util.IdentityHashMapTest.java
public void testIsEmpty() { IdentityHashMap srcMap = new IdentityHashMap(); checkEmptyHashMapAssumptions(srcMap); IdentityHashMap dstMap = new IdentityHashMap(); checkEmptyHashMapAssumptions(dstMap); dstMap.putAll(srcMap);//from w w w. ja v a 2 s. c o m assertTrue(dstMap.isEmpty()); dstMap.put(KEY_KEY, VALUE_VAL); assertFalse(dstMap.isEmpty()); dstMap.remove(KEY_KEY); assertTrue(dstMap.isEmpty()); assertEquals(dstMap.size(), 0); }