Example usage for java.util IdentityHashMap IdentityHashMap

List of usage examples for java.util IdentityHashMap IdentityHashMap

Introduction

In this page you can find the example usage for java.util IdentityHashMap IdentityHashMap.

Prototype

public IdentityHashMap() 

Source Link

Document

Constructs a new, empty identity hash map with a default expected maximum size (21).

Usage

From source file:com.google.gwt.emultest.java.util.IdentityHashMapTest.java

/**
 * Test method for 'java.util.IdentityHashMap.remove(Object)'.
 */// ww  w . ja v a 2s . c o m
public void testRemove() {
    IdentityHashMap hashMap = new IdentityHashMap();
    checkEmptyHashMapAssumptions(hashMap);

    assertNull(hashMap.remove(null));
    hashMap.put(null, VALUE_TEST_REMOVE);
    assertNotNull(hashMap.remove(null));

    hashMap.put(KEY_TEST_REMOVE, VALUE_TEST_REMOVE);
    assertEquals(hashMap.remove(KEY_TEST_REMOVE), VALUE_TEST_REMOVE);
    assertNull(hashMap.remove(KEY_TEST_REMOVE));
}

From source file:org.jiemamy.utils.collection.CollectionsUtil.java

/**
 * {@link IdentityHashMap}?????//from   w  ww  .j  a  v a  2s  . c  o  m
 * 
 * @param <K> {@link IdentityHashMap}??
 * @param <V> {@link IdentityHashMap}??
 * @return {@link IdentityHashMap}???
 * @see IdentityHashMap#IdentityHashMap()
 * @deprecated use {@link Maps#newIdentityHashMap()}
 */
@Deprecated
public static <K, V> IdentityHashMap<K, V> newIdentityHashMap() {
    return new IdentityHashMap<K, V>();
}

From source file:ca.uhn.fhir.rest.server.provider.dstu2.ServerConformanceProvider.java

@Initialize
public void initializeOperations() {
    myOperationBindingToName = new IdentityHashMap<OperationMethodBinding, String>();
    myOperationNameToBindings = new HashMap<String, List<OperationMethodBinding>>();

    Map<String, List<BaseMethodBinding<?>>> resourceToMethods = collectMethodBindings();
    for (Entry<String, List<BaseMethodBinding<?>>> nextEntry : resourceToMethods.entrySet()) {
        List<BaseMethodBinding<?>> nextMethodBindings = nextEntry.getValue();
        for (BaseMethodBinding<?> nextMethodBinding : nextMethodBindings) {
            if (nextMethodBinding instanceof OperationMethodBinding) {
                OperationMethodBinding methodBinding = (OperationMethodBinding) nextMethodBinding;
                if (myOperationBindingToName.containsKey(methodBinding)) {
                    continue;
                }//from  w  w  w  .  ja v  a2s  .co m

                String name = createOperationName(methodBinding);
                myOperationBindingToName.put(methodBinding, name);
                if (myOperationNameToBindings.containsKey(name) == false) {
                    myOperationNameToBindings.put(name, new ArrayList<OperationMethodBinding>());
                }
                myOperationNameToBindings.get(name).add(methodBinding);
            }
        }
    }
}

From source file:de.javakaffee.web.msm.serializer.javolution.JavolutionTranscoderTest.java

private void assertDeepEquals(final Object one, final Object another) throws Exception {
    assertDeepEquals(one, another, new IdentityHashMap<Object, Object>());
}

From source file:ca.uhn.fhir.util.FhirTerser.java

/**
 * Visit all elements in a given resource
 * //w w  w .  j a  v  a 2 s.  c o m
 * <p>
 * Note on scope: This method will descend into any contained resources ({@link IResource#getContained()}) as well, but will not descend into linked resources (e.g.
 * {@link BaseResourceReferenceDt#getResource()}) or embedded resources (e.g. Bundle.entry.resource)
 * </p>
 * 
 * @param theResource
 *           The resource to visit
 * @param theVisitor
 *           The visitor
 */
public void visit(IBaseResource theResource, IModelVisitor theVisitor) {
    BaseRuntimeElementCompositeDefinition<?> def = myContext.getResourceDefinition(theResource);
    visit(new IdentityHashMap<Object, Object>(), theResource, theResource, null, null, def, theVisitor);
}

From source file:com.google.gwt.emultest.java.util.IdentityHashMapTest.java

/**
 * Test method for 'java.util.IdentityHashMap.size()'.
 *//*ww  w  .  j av  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:org.hl7.fhir.dstu2016may.hapi.rest.server.ServerConformanceProvider.java

@Initialize
public void initializeOperations() {
    myOperationBindingToName = new IdentityHashMap<OperationMethodBinding, String>();
    myOperationNameToBindings = new HashMap<String, List<OperationMethodBinding>>();

    Map<String, List<BaseMethodBinding<?>>> resourceToMethods = collectMethodBindings();
    for (Entry<String, List<BaseMethodBinding<?>>> nextEntry : resourceToMethods.entrySet()) {
        List<BaseMethodBinding<?>> nextMethodBindings = nextEntry.getValue();
        for (BaseMethodBinding<?> nextMethodBinding : nextMethodBindings) {
            if (nextMethodBinding instanceof OperationMethodBinding) {
                OperationMethodBinding methodBinding = (OperationMethodBinding) nextMethodBinding;
                if (myOperationBindingToName.containsKey(methodBinding)) {
                    continue;
                }//from w  ww.  j a  v a  2 s  . co m

                String name = createOperationName(methodBinding);
                ourLog.debug("Detected operation: {}", name);

                myOperationBindingToName.put(methodBinding, name);
                if (myOperationNameToBindings.containsKey(name) == false) {
                    myOperationNameToBindings.put(name, new ArrayList<OperationMethodBinding>());
                }
                myOperationNameToBindings.get(name).add(methodBinding);
            }
        }
    }
}

From source file:org.jboss.errai.ioc.rebind.ioc.graph.impl.DependencyGraphBuilderImpl.java

private void resolveDependencies() {
    final Set<Injectable> visited = new HashSet<Injectable>();
    final Set<String> transientInjectableNames = new HashSet<String>();
    final List<String> dependencyProblems = new ArrayList<String>();
    final Map<String, Injectable> customProvidedInjectables = new IdentityHashMap<String, Injectable>();

    for (final Injectable concrete : concretesByName.values()) {
        if (concrete.isExtension()) {
            transientInjectableNames.add(concrete.getFactoryName());
        }/* w  ww  .  ja  v  a2  s.co m*/
        if (!visited.contains(concrete)) {
            for (final Dependency dep : concrete.getDependencies()) {
                resolveDependency(asBaseDependency(dep), concrete, dependencyProblems,
                        customProvidedInjectables);
            }
        }
    }

    concretesByName.keySet().removeAll(transientInjectableNames);
    concretesByName.putAll(customProvidedInjectables);

    if (!dependencyProblems.isEmpty()) {
        throw new RuntimeException(buildMessageFromProblems(dependencyProblems));
    }
}

From source file:com.google.gwt.emultest.java.util.IdentityHashMapTest.java

/**
 * Test method for 'java.util.AbstractMap.toString()'.
 *///from   w w  w  .  j av  a  2 s .  co m
public void testToString() {
    IdentityHashMap hashMap = new IdentityHashMap();
    checkEmptyHashMapAssumptions(hashMap);
    hashMap.put(KEY_KEY, VALUE_VAL);
    String entryString = makeEntryString(KEY_KEY, VALUE_VAL);
    assertTrue(entryString.equals(hashMap.toString()));
}

From source file:com.google.gwt.emultest.java.util.IdentityHashMapTest.java

/**
 * Test method for 'java.util.AbstractMap.values()'.
 *//*from  ww w .j av  a  2  s .co  m*/
public void testValues() {
    IdentityHashMap hashMap = new IdentityHashMap();
    checkEmptyHashMapAssumptions(hashMap);

    assertNotNull(hashMap.values());

    hashMap.put(KEY_KEY, VALUE_VAL);

    Collection valColl = hashMap.values();
    assertNotNull(valColl);
    assertEquals(valColl.size(), SIZE_ONE);

    Iterator itVal = valColl.iterator();
    String val = (String) itVal.next();
    assertEquals(val, VALUE_VAL);
}