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

@Override
protected Map makeConfirmedMap() {
    return new IdentityHashMap();
}

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

@Override
protected Map makeEmptyMap() {
    return new IdentityHashMap();
}

From source file:org.jamocha.rating.fraj.RatingProvider.java

@Override
public double rateNetwork(final SideEffectFunctionToNetwork network) {
    final Map<Node, Double> nodeToCost = new IdentityHashMap<>();
    final Map<Node, Set<Pair<Set<Path>, Set<PathFilterList>>>> preNetwork = new HashMap<>();
    final Set<Node> nodes = network.getTerminalNodes().stream().map(TerminalNode::getEdge)
            .map(Edge::getSourceNode).collect(toHashSet());
    final StatisticsProvider statProvider = new org.jamocha.rating.fraj.StatisticsProvider();
    for (final Node node : nodes) {
        recursiveRateNode(node, nodeToCost, preNetwork, statProvider);
    }//from w w w .  jav a  2s .  co  m
    final double cost = nodeToCost.values().stream().mapToDouble(Double::doubleValue).sum();
    return cost;
}

From source file:com.painiu.pnfs.SockIOPool.java

/**
 * Adds a socket to a given pool for the given host. THIS METHOD IS NOT
 * THREADSAFE, SO BE CAREFUL WHEN USING!
 * //from w  w  w .  java2  s  .  co m
 * Internal utility method.
 * 
 * @param pool
 *            pool to add to
 * @param host
 *            host this socket is connected to
 * @param socket
 *            socket to add
 */
protected void addSocketToPool(Map<String, Map<SockIO, Long>> pool, String host, SockIO socket) {

    if (pool.containsKey(host)) {
        Map<SockIO, Long> sockets = pool.get(host);

        if (sockets != null) {
            sockets.put(socket, new Long(System.currentTimeMillis()));
            return;
        }
    }

    Map<SockIO, Long> sockets = new IdentityHashMap<SockIO, Long>();

    sockets.put(socket, new Long(System.currentTimeMillis()));
    pool.put(host, sockets);
}

From source file:org.occiware.clouddesigner.occi.docker.connector.ModelHandler.java

public static EList<EObject> toEObject(final String xmi, final boolean unsetID) {
    try {//from  w w  w . ja  v a 2  s. c  o  m
        Map<Object, Object> options = new HashMap<Object, Object>();
        options.put(XMLResource.OPTION_ENCODING, "UTF-8");
        options.put(XMLResource.OPTION_DEFER_IDREF_RESOLUTION, Boolean.TRUE);
        options.put(XMLResource.OPTION_DEFER_ATTACHMENT, Boolean.TRUE);
        ResourceSet resourceSet = new ResourceSetImpl();
        Resource.Factory.Registry _resourceFactoryRegistry = resourceSet.getResourceFactoryRegistry();
        Map<String, Object> _extensionToFactoryMap = _resourceFactoryRegistry.getExtensionToFactoryMap();
        XMIResourceFactoryImpl _xMIResourceFactoryImpl = new XMIResourceFactoryImpl();
        _extensionToFactoryMap.put("*", _xMIResourceFactoryImpl);
        EPackage.Registry _packageRegistry = resourceSet.getPackageRegistry();
        _packageRegistry.put(DockerPackage.eNS_URI, DockerPackage.eINSTANCE);
        StringReader _stringReader = new StringReader(xmi);
        URIConverter.ReadableInputStream input = new URIConverter.ReadableInputStream(_stringReader, "UTF-8");
        URI _createURI = URI.createURI("");
        Resource resource = resourceSet.createResource(_createURI);
        resource.load(input, options);
        if (((!resource.getErrors().isEmpty()) || (!resource.getWarnings().isEmpty()))) {
            EList<Resource.Diagnostic> _errors = resource.getErrors();
            String _plus = ("Unable to load the EObject. Errors:" + _errors);
            String _plus_1 = (_plus + "Warnings:");
            EList<Resource.Diagnostic> _warnings = resource.getWarnings();
            String _plus_2 = (_plus_1 + _warnings);
            throw new IllegalArgumentException(_plus_2);
        }
        EList<EObject> result = resource.getContents();
        if (((!Objects.equal(result, null)) && unsetID)) {
            Map<EObject, Boolean> preventCycles = new IdentityHashMap<EObject, Boolean>();
            ArrayList<EObject> rootList = new ArrayList<EObject>();
            for (final EObject eObj : result) {
                ModelHandler.readReferences(eObj, preventCycles, rootList);
            }
            for (final EObject eobj : rootList) {
                {
                    EClass _eClass = eobj.eClass();
                    EAttribute _eIDAttribute = _eClass.getEIDAttribute();
                    boolean _notEquals = (!Objects.equal(_eIDAttribute, null));
                    if (_notEquals) {
                        EClass _eClass_1 = eobj.eClass();
                        EAttribute _eIDAttribute_1 = _eClass_1.getEIDAttribute();
                        eobj.eSet(_eIDAttribute_1, null);
                    }
                    Iterator<EObject> iterator = eobj.eAllContents();
                    while (iterator.hasNext()) {
                        {
                            EObject dependentEObject = iterator.next();
                            EClass _eClass_2 = dependentEObject.eClass();
                            EAttribute _eIDAttribute_2 = _eClass_2.getEIDAttribute();
                            boolean _notEquals_1 = (!Objects.equal(_eIDAttribute_2, null));
                            if (_notEquals_1) {
                                EClass _eClass_3 = dependentEObject.eClass();
                                EAttribute _eIDAttribute_3 = _eClass_3.getEIDAttribute();
                                dependentEObject.eSet(_eIDAttribute_3, null);
                            }
                        }
                    }
                }
            }
        }
        return result;
    } catch (final Throwable _t) {
        if (_t instanceof IOException) {
            final IOException e = (IOException) _t;
            throw new IllegalArgumentException(e);
        } else {
            throw Exceptions.sneakyThrow(_t);
        }
    }
}

From source file:com.google.gwt.resources.rg.GssResourceGenerator.java

@Override
public void init(TreeLogger logger, ResourceContext context) throws UnableToCompleteException {
    cssParsingResultMap = new IdentityHashMap<>();
    errorManager = new LoggerErrorManager(logger);

    allowedNonStandardFunctions = new HashSet<>();
    allowedAtRules = Sets.newHashSet(ExternalClassesCollector.EXTERNAL_AT_RULE);

    try {/*from w  ww.j a  va  2  s .c om*/
        PropertyOracle propertyOracle = context.getGeneratorContext().getPropertyOracle();

        ConfigurationProperty styleProp = propertyOracle.getConfigurationProperty(KEY_STYLE);
        obfuscationStyle = CssObfuscationStyle.getObfuscationStyle(styleProp.getValues().get(0));
        obfuscationPrefix = getObfuscationPrefix(propertyOracle, context);

        ConfigurationProperty allowedAtRuleProperty = propertyOracle.getConfigurationProperty(ALLOWED_AT_RULE);
        allowedAtRules.addAll(allowedAtRuleProperty.getValues());

        ConfigurationProperty allowedFunctionsProperty = propertyOracle
                .getConfigurationProperty(ALLOWED_FUNCTIONS);
        allowedNonStandardFunctions.addAll(allowedFunctionsProperty.getValues());

        ClientBundleRequirements requirements = context.getRequirements();
        requirements.addConfigurationProperty(KEY_STYLE);
        requirements.addConfigurationProperty(KEY_OBFUSCATION_PREFIX);
        requirements.addConfigurationProperty(ALLOWED_AT_RULE);
        requirements.addConfigurationProperty(ALLOWED_FUNCTIONS);
        requirements.addConfigurationProperty(KEY_CONVERSION_MODE);
    } catch (BadPropertyValueException e) {
        logger.log(TreeLogger.ERROR, "Unable to query module property", e);
        throw new UnableToCompleteException();
    }

    TypeOracle typeOracle = context.getGeneratorContext().getTypeOracle();
    JClassType cssResourceInterface = typeOracle.findType(CssResource.class.getCanonicalName());
    JClassType resourcePrototypeInterface = typeOracle.findType(ResourcePrototype.class.getCanonicalName());

    try {
        getTextMethod = cssResourceInterface.getMethod("getText", new JType[0]);
        ensuredInjectedMethod = cssResourceInterface.getMethod("ensureInjected", new JType[0]);
        getNameMethod = resourcePrototypeInterface.getMethod("getName", new JType[0]);
    } catch (NotFoundException e) {
        logger.log(TreeLogger.ERROR,
                "Unable to lookup methods from CssResource and " + "ResourcePrototype interface", e);
        throw new UnableToCompleteException();
    }

    initReplacement(context);
}

From source file:com.espertech.esper.core.context.mgr.ContextManagerNested.java

private AgentInstanceFilterProxy getMergedFilterAddendums(ContextControllerStatementDesc statement,
        ContextController originator, Object partitionKey, int contextId) {

    IdentityHashMap<FilterSpecCompiled, FilterValueSetParam[]> result = new IdentityHashMap<FilterSpecCompiled, FilterValueSetParam[]>();
    originator.getFactory().populateFilterAddendums(result, statement, partitionKey, contextId);
    ContextControllerTreeEntry originatorEntry = subcontexts.get(originator);
    if (originatorEntry != null) {
        recursivePopulateFilterAddendum(statement, originatorEntry, contextId, result);
    }/* w w  w  . jav  a 2  s  .  c  o m*/
    return new AgentInstanceFilterProxyImpl(result);
}

From source file:org.occiware.clouddesigner.occi.docker.connector.ModelHandler.java

public static String toXMI(final EObject object) {
    try {//from w w w  . j av a2s  .  c o m
        Map<Object, Object> options = new HashMap<Object, Object>();
        options.put(XMLResource.OPTION_ENCODING, "UTF-8");
        options.put(XMLResource.OPTION_DEFER_IDREF_RESOLUTION, Boolean.TRUE);
        options.put(XMLResource.OPTION_DEFER_ATTACHMENT, Boolean.TRUE);
        final StringWriter sw = new StringWriter();
        final URIConverter.WriteableOutputStream uws = new URIConverter.WriteableOutputStream(sw, "UTF-8");
        final ResourceSet resourceSet = new ResourceSetImpl();
        Resource.Factory.Registry _resourceFactoryRegistry = resourceSet.getResourceFactoryRegistry();
        Map<String, Object> _extensionToFactoryMap = _resourceFactoryRegistry.getExtensionToFactoryMap();
        XMIResourceFactoryImpl _xMIResourceFactoryImpl = new XMIResourceFactoryImpl();
        _extensionToFactoryMap.put("*", _xMIResourceFactoryImpl);
        EPackage.Registry _packageRegistry = resourceSet.getPackageRegistry();
        _packageRegistry.put(DockerPackage.eNS_URI, DockerPackage.eINSTANCE);
        URI _createURI = URI.createURI("");
        Resource resource = resourceSet.createResource(_createURI);
        Map<EObject, Boolean> preventCycles = new IdentityHashMap<EObject, Boolean>();
        ArrayList<EObject> rootList = new ArrayList<EObject>();
        ModelHandler.readReferences(object, preventCycles, rootList);
        for (final EObject obj : rootList) {
            EList<EObject> _contents = resource.getContents();
            _contents.add(obj);
        }
        resource.save(uws, options);
        return sw.toString();
    } catch (final Throwable _t) {
        if (_t instanceof IOException) {
            final IOException e = (IOException) _t;
            throw new IllegalArgumentException(e);
        } else {
            throw Exceptions.sneakyThrow(_t);
        }
    }
}

From source file:com.google.gwt.resources.rg.GssResourceGenerator.java

@SuppressWarnings("unchecked")
private void initReplacement(ResourceContext context) {
    if (context.getCachedData(KEY_HAS_CACHED_DATA, Boolean.class) != Boolean.TRUE) {

        context.putCachedData(KEY_SHARED_METHODS, new IdentityHashMap<JMethod, String>());
        context.putCachedData(KEY_BY_CLASS_AND_METHOD, new IdentityHashMap<JClassType, Map<String, String>>());
        context.putCachedData(KEY_HAS_CACHED_DATA, Boolean.TRUE);
    }// w  ww  .j  av  a 2s . c o m

    replacementsByClassAndMethod = context.getCachedData(KEY_BY_CLASS_AND_METHOD, Map.class);
    replacementsForSharedMethods = context.getCachedData(KEY_SHARED_METHODS, Map.class);
}

From source file:de.javakaffee.kryoserializers.KryoTest.java

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