当前位置: 首页>>代码示例>>Java>>正文


Java IdentityHashMap类代码示例

本文整理汇总了Java中java.util.IdentityHashMap的典型用法代码示例。如果您正苦于以下问题:Java IdentityHashMap类的具体用法?Java IdentityHashMap怎么用?Java IdentityHashMap使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


IdentityHashMap类属于java.util包,在下文中一共展示了IdentityHashMap类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: groupByVersion

import java.util.IdentityHashMap; //导入依赖的package包/类
protected Map<MicroserviceVersionMeta, Map<String, MicroserviceInstance>> groupByVersion(Invocation invocation,
    Map<String, MicroserviceInstance> instances) {
  OperationMeta latestOperationMeta = invocation.getOperationMeta();
  MicroserviceMeta latestMicroserviceMeta = latestOperationMeta.getSchemaMeta().getMicroserviceMeta();
  AppManager appManager = RegistryUtils.getServiceRegistry().getAppManager();
  MicroserviceVersions MicroserviceVersions =
      appManager.getOrCreateMicroserviceVersions(latestMicroserviceMeta.getAppId(), latestMicroserviceMeta.getName());

  Map<MicroserviceVersionMeta, Map<String, MicroserviceInstance>> versionMap = new IdentityHashMap<>();
  for (MicroserviceInstance instance : instances.values()) {
    MicroserviceVersionMeta versionMeta = MicroserviceVersions.getVersion(instance.getServiceId());
    Map<String, MicroserviceInstance> versionInstances = versionMap.computeIfAbsent(versionMeta, vm -> {
      return new HashMap<>();
    });
    versionInstances.put(instance.getInstanceId(), instance);
  }
  return versionMap;
}
 
开发者ID:apache,项目名称:incubator-servicecomb-java-chassis,代码行数:19,代码来源:OperationInstancesDiscoveryFilter.java

示例2: register

import java.util.IdentityHashMap; //导入依赖的package包/类
@Override
public synchronized String register(String subject, Schema schema)
    throws IOException, RestClientException {
  Map<Schema, String> schemaIdMap;
  if (schemaCache.containsKey(subject)) {
    schemaIdMap = schemaCache.get(subject);
  } else {
    schemaIdMap = new IdentityHashMap<Schema, String>();
    schemaCache.put(subject, schemaIdMap);
  }

  if (schemaIdMap.containsKey(schema)) {
    return schemaIdMap.get(schema);
  } else {
    String id = getIdFromRegistry(subject, schema);
    schemaIdMap.put(schema, id);
    idCache.get(null).put(id, schema);
    return id;
  }
}
 
开发者ID:thomas-young-2013,项目名称:wherehowsX,代码行数:21,代码来源:MockSchemaRegistryClient.java

示例3: register

import java.util.IdentityHashMap; //导入依赖的package包/类
@Override
public synchronized String register(String subject, Schema schema)
    throws IOException, RestClientException {
  Map<Schema, String> schemaIdMap;
  if (schemaCache.containsKey(subject)) {
    schemaIdMap = schemaCache.get(subject);
  } else {
    schemaIdMap = new IdentityHashMap<Schema, String>();
    schemaCache.put(subject, schemaIdMap);
  }

  if (schemaIdMap.containsKey(schema)) {
    return schemaIdMap.get(schema);
  } else {
    if (schemaIdMap.size() >= identityMapCapacity) {
      throw new IllegalStateException("Too many schema objects created for " + subject + "!");
    }
    String id = registerAndGetId(subject, schema);
    schemaIdMap.put(schema, id);
    idCache.get(null).put(id, schema);
    return id;
  }
}
 
开发者ID:thomas-young-2013,项目名称:wherehowsX,代码行数:24,代码来源:CachedSchemaRegistryClient.java

示例4: getVersion

import java.util.IdentityHashMap; //导入依赖的package包/类
@Override
public synchronized int getVersion(String subject, Schema schema)
    throws IOException, RestClientException{
  Map<Schema, Integer> schemaVersionMap;
  if (versionCache.containsKey(subject)) {
    schemaVersionMap = versionCache.get(subject);
  } else {
    schemaVersionMap = new IdentityHashMap<Schema, Integer>();
    versionCache.put(subject, schemaVersionMap);
  }

  if (schemaVersionMap.containsKey(schema)) {
    return schemaVersionMap.get(schema);
  }  else {
    if (schemaVersionMap.size() >= identityMapCapacity) {
      throw new IllegalStateException("Too many schema objects created for " + subject + "!");
    }
    int version = getVersionFromRegistry(subject, schema);
    schemaVersionMap.put(schema, version);
    return version;
  }
}
 
开发者ID:thomas-young-2013,项目名称:wherehowsX,代码行数:23,代码来源:CachedSchemaRegistryClient.java

示例5: findRedirect

import java.util.IdentityHashMap; //导入依赖的package包/类
static CloneableEditorSupport findRedirect(CloneableEditorSupport one, boolean check) {
    Map<Lookup,CloneableEditorSupport> all = CHECKED.get();
    if (all == null) {
        all = new IdentityHashMap<Lookup, CloneableEditorSupport>();
        CHECKED.set(all);
    }
    final Lookup lkp = one.getLookup();
    try {
        if (check && all.containsKey(lkp)) {
            return null;
        }
        all.put(lkp, one);
        for (CloneableEditorSupportRedirector r : Lookup.getDefault().lookupAll(CloneableEditorSupportRedirector.class)) {
            CloneableEditorSupport ces = r.redirect(lkp);
            if (ces != null && ces != one) {
                return ces;
            }
        }
        return null;
    } finally {
        all.remove(lkp);
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:24,代码来源:CloneableEditorSupportRedirector.java

示例6: sortFiles

import java.util.IdentityHashMap; //导入依赖的package包/类
public static Map<ClasspathInfo, Collection<FileObject>> sortFiles(Collection<? extends FileObject> from) {
    Map<CPCategorizer, Collection<FileObject>> m = new HashMap<CPCategorizer, Collection<FileObject>>();

    for (FileObject f : from) {
        CPCategorizer cpCategorizer = new CPCategorizer(f);

        Collection<FileObject> files = m.get(cpCategorizer);

        if (files == null) {
            m.put(cpCategorizer, files = new LinkedList<FileObject>());
        }

        files.add(f);
    }
    
    Map<ClasspathInfo, Collection<FileObject>> result = new IdentityHashMap<ClasspathInfo, Collection<FileObject>>();

    for (Entry<CPCategorizer, Collection<FileObject>> e : m.entrySet()) {
        result.put(ClasspathInfo.create(e.getKey().boot, e.getKey().compile, e.getKey().source), e.getValue());
    }
    
    return result;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:24,代码来源:BatchUtilities.java

示例7: vulOnderzoeken

import java.util.IdentityHashMap; //导入依赖的package包/类
private static Map<Onderzoek, Lo3Onderzoek> vulOnderzoeken(final Collection<Onderzoek> onderzoeken) {
    final Map<Onderzoek, Lo3Onderzoek> resultaat = new IdentityHashMap<>();

    for (final Onderzoek onderzoek : onderzoeken) {

        final OnderzoekStandaardRecord onderzoekActueel = bepaalLaatsteRecord(onderzoek.getStandaard());
        Assert.notNull(onderzoekActueel, "Geen actueel record voor onderzoek gevonden.");
        if (onderzoekActueel != null) {
            final String lo3GegevensInOnderzoek = bepaalGegevensInOnderzoek(onderzoekActueel);
            final Lo3Datum datumIngangOnderzoek = new BrpDatum(onderzoekActueel.getDatumAanvang(), null).converteerNaarLo3Datum();

            final boolean isOnderzoekBeindigd = StatusOnderzoek.AFGESLOTEN.getNaam().equals(onderzoekActueel.getStatus());
            final Lo3Datum datumEindeOnderzoek = isOnderzoekBeindigd ? new BrpDatum(onderzoekActueel.getDatumEinde(), null).converteerNaarLo3Datum() : null;

            final Lo3Onderzoek lo3Onderzoek = new Lo3Onderzoek(new Lo3Integer(lo3GegevensInOnderzoek, null), datumIngangOnderzoek, datumEindeOnderzoek);

            resultaat.put(onderzoek, lo3Onderzoek);
        }
    }
    return resultaat;
}
 
开发者ID:MinBZK,项目名称:OperatieBRP,代码行数:22,代码来源:OnderzoekMapperImpl.java

示例8: computeDataFlow

import java.util.IdentityHashMap; //导入依赖的package包/类
private void computeDataFlow() {
    Map<Tree, Collection<Tree>> res = new IdentityHashMap<Tree, Collection<Tree>>(7);
    for (Map.Entry<Tree, Iterable<? extends TreePath>> e : assignmentsForUse.entrySet()) {
        Tree k = e.getKey();
        for (TreePath p : e.getValue()) {
            if (p == null) {
                continue;
            }
            Tree l = p.getLeaf();
            Collection<Tree> users = res.get(l);
            if (users == null) {
                users = new ArrayList<Tree>(2);
                res.put(l, users);
            }
            users.add(k);
        }
    }
    dataFlow = res;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:20,代码来源:Flow.java

示例9: testIdentityHashMap

import java.util.IdentityHashMap; //导入依赖的package包/类
@Test
public void testIdentityHashMap() {
    for (int i = 0; i < 100000; i++) {
        Map<Integer,String> test = new IdentityHashMap<>();
        for (int k = 0; k < 7; k++) {
            test.put(new Integer(k), "");
        }
        Iterator<Integer> testIter = test.keySet().iterator();
        while (testIter.hasNext()) {
            Integer elem = testIter.next();
            if (elem.intValue() != 6) {
                testIter.remove();
            }
        }
        assertEquals(1, test.keySet().size());
        assertEquals(Collections.singleton(new Integer(6)), test.keySet());
    }
}
 
开发者ID:meteoorkip,项目名称:JavaGraph,代码行数:19,代码来源:IdentityHashMapTest.java

示例10: main

import java.util.IdentityHashMap; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
    final IdentityHashMap<String, String> identityHashMap =
        new IdentityHashMap<>();

    identityHashMap.put("One", "Un");
    identityHashMap.put("Two", "Deux");
    identityHashMap.put("Three", "Trois");

    Set<Map.Entry<String, String>> entrySet = identityHashMap.entrySet();
    HashSet<Map.Entry<String, String>> hashSet = new HashSet<>(entrySet);

    // NB: These comparisons are valid in this case because none of the
    //     keys put into 'identityHashMap' above are equal to any other.
    if (false == hashSet.equals(entrySet)) {
        throw new RuntimeException("Test FAILED: Sets are not equal.");
    }
    if (hashSet.hashCode() != entrySet.hashCode()) {
        throw new RuntimeException("Test FAILED: Set's hashcodes are not equal.");
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:21,代码来源:DistinctEntrySetElements.java

示例11: main

import java.util.IdentityHashMap; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
    final IdentityHashMap<String, String> identityHashMap =
        new IdentityHashMap<>();

    identityHashMap.put("One", "Un");
    identityHashMap.put("Two", "Deux");
    identityHashMap.put("Three", "Trois");

    Iterator<Map.Entry<String, String>> entrySetIterator =
        identityHashMap.entrySet().iterator();
    Map.Entry<String, String> entry = entrySetIterator.next();

    entrySetIterator.remove();

    try {
        entry.getKey();
        throw new RuntimeException("Test FAILED: Entry not invalidated by removal.");
    } catch (Exception e) { }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:20,代码来源:EntrySetIteratorRemoveInvalidatesEntry.java

示例12: invoke

import java.util.IdentityHashMap; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
    if (method.getDeclaringClass() == Object.class) {
        return method.invoke(map, args);
    }
    String methodName = method.getName();
    Object value = null;
    if (methodName.length() > 3 && methodName.startsWith("get")) {
        value = map.get(methodName.substring(3, 4).toLowerCase() + methodName.substring(4));
    } else if (methodName.length() > 2 && methodName.startsWith("is")) {
        value = map.get(methodName.substring(2, 3).toLowerCase() + methodName.substring(3));
    } else {
        value = map.get(methodName.substring(0, 1).toLowerCase() + methodName.substring(1));
    }
    if (value instanceof Map<?,?> && ! Map.class.isAssignableFrom(method.getReturnType())) {
        value = realize0((Map<String, Object>) value, method.getReturnType(), null, new IdentityHashMap<Object, Object>());
    }
    return value;
}
 
开发者ID:tiglabs,项目名称:jsf-sdk,代码行数:20,代码来源:PojoUtils.java

示例13: testReconcile

import java.util.IdentityHashMap; //导入依赖的package包/类
@Test
public void testReconcile() throws Exception {

    Map<Instruction, String> values = new IdentityHashMap<>();
    values.put(CreateInstruction.builder().build(), "i1");
    values.put(CancelInstruction.builder().build(), "i2");
    values.put(null, "i3");
    values.put(CancelInstruction.builder().build(), null);
    Request request = Request.builder().build();
    doReturn(TRUE).when(target).checkCreated(same(context), any(), eq("i1"), any(), any());
    doReturn(TRUE).when(target).checkCancelled(same(context), any(), eq("i2"), any(), any());

    Map<Instruction, Boolean> results = target.reconcile(context, request, values);
    assertEquals(results.size(), 2);
    results.values().forEach(Assert::assertTrue);
    verify(target).checkCreated(same(context), any(), eq("i1"), any(), any());
    verify(target).checkCancelled(same(context), any(), eq("i2"), any(), any());

    // No input
    assertEquals(target.reconcile(context, request, null).size(), 0);

}
 
开发者ID:after-the-sunrise,项目名称:cryptotrader,代码行数:23,代码来源:TemplateAgentTest.java

示例14: makeMapsMoreTypes

import java.util.IdentityHashMap; //导入依赖的package包/类
private static <T> Collection<Object[]> makeMapsMoreTypes(String desc,
                                                          T[] keys,
                                                          T val) {
    Collection<Object[]> cases = new ArrayList<>();
    cases.add(createCase("Hashtable with " + desc,
                         new Hashtable<>(), keys, val));
    cases.add(createCase("IdentityHashMap with " + desc,
                         new IdentityHashMap<>(), keys, val));
    cases.add(createCase("TreeMap with " + desc,
                         new TreeMap<>(), keys, val));
    cases.add(createCase("WeakHashMap with " + desc,
                         new WeakHashMap<>(), keys, val));
    cases.add(createCase("ConcurrentHashMap with " + desc,
                         new ConcurrentHashMap<>(), keys, val));
    cases.add(createCase("ConcurrentSkipListMap with " + desc,
                         new ConcurrentSkipListMap<>(), keys, val));
    return cases;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:19,代码来源:MapWithCollisionsProviders.java

示例15: getRedisService

import java.util.IdentityHashMap; //导入依赖的package包/类
/**
 * 获取单例
 *
 * @param redisPropertiesFilename
 * @param tClass
 * @param <T>
 * @return
 */
public static <T extends AbstractRedisService> T getRedisService(String redisPropertiesFilename, Class<T> tClass) {
    IdentityHashMap<Class, ? extends AbstractRedisService> redisServices = INSTANCES.get(redisPropertiesFilename);
    if (redisServices != null) {
        return (T) redisServices.get(tClass);
    }
    IdentityHashMap<Class, AbstractRedisService> newRedisServices = new IdentityHashMap<>();
    RedisConfig redisConfig = getRedisConfig(redisPropertiesFilename);
    newRedisServices.put(AppInfoCacheServiceAbstract.class, new AppInfoCacheServiceAbstract(redisConfig));
    newRedisServices.put(InterfaceInfoCacheServiceAbstract.class, new InterfaceInfoCacheServiceAbstract(redisConfig));
    newRedisServices.put(TokenInfoCacheServiceAbstract.class, new TokenInfoCacheServiceAbstract(redisConfig));
    newRedisServices.put(FrequencyCacheServiceAbstract.class, new FrequencyCacheServiceAbstract(redisConfig));
    newRedisServices.put(StatisticsCacheServiceAbstract.class, new StatisticsCacheServiceAbstract(redisConfig));
    newRedisServices.put(VerificationCodeServiceAbstract.class, new VerificationCodeServiceAbstract(redisConfig));
    newRedisServices.put(AuthCodeCacheServiceAbstract.class, new AuthCodeCacheServiceAbstract(redisConfig));
    redisServices = INSTANCES.putIfAbsent(redisPropertiesFilename, newRedisServices);
    if (redisServices == null) {
        redisServices = newRedisServices;
    }
    return (T) redisServices.get(tClass);
}
 
开发者ID:wxz1211,项目名称:dooo,代码行数:29,代码来源:AbstractRedisService.java


注:本文中的java.util.IdentityHashMap类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。