com.google.common.collect.Multimap.hashCode()方法的使用及代码示例

x33g5p2x  于2022-01-24 转载在 其他  
字(7.4k)|赞(0)|评价(0)|浏览(138)

本文整理了Java中com.google.common.collect.Multimap.hashCode()方法的一些代码示例,展示了Multimap.hashCode()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Multimap.hashCode()方法的具体详情如下:
包路径:com.google.common.collect.Multimap
类名称:Multimap
方法名:hashCode

Multimap.hashCode介绍

[英]Returns the hash code for this multimap.

The hash code of a multimap is defined as the hash code of the map view, as returned by Multimap#asMap.

In general, two multimaps with identical key-value mappings may or may not have the same hash codes, depending on the implementation. For example, two SetMultimap instances with the same key-value mappings will have the same hashCode, but the hashCodeof ListMultimap instances depends on the ordering of the values for each key.
[中]返回此多重映射的哈希代码。
多重映射的哈希代码定义为映射视图的哈希代码,由多重映射#asMap返回。
通常,具有相同键值映射的两个多重映射可能具有相同的哈希代码,也可能不具有相同的哈希代码,具体取决于实现。例如,具有相同键值映射的两个SetMultimap实例将具有相同的哈希代码,但ListMultimap实例的哈希代码取决于每个键的值顺序。

代码示例

代码示例来源:origin: google/guava

@Override
public int hashCode() {
 synchronized (mutex) {
  return delegate().hashCode();
 }
}

代码示例来源:origin: google/guava

@Override
 public int hashCode() {
  return delegate().hashCode();
 }
}

代码示例来源:origin: google/j2objc

@Override
 public int hashCode() {
  return delegate().hashCode();
 }
}

代码示例来源:origin: google/j2objc

@Override
public int hashCode() {
 synchronized (mutex) {
  return delegate().hashCode();
 }
}

代码示例来源:origin: google/guava

public void testHashCodeMatchesAsMap() {
  assertEquals(multimap().asMap().hashCode(), multimap().hashCode());
 }
}

代码示例来源:origin: wildfly/wildfly

@Override
public int hashCode() {
 synchronized (mutex) {
  return delegate().hashCode();
 }
}

代码示例来源:origin: wildfly/wildfly

@Override
 public int hashCode() {
  return delegate().hashCode();
 }
}

代码示例来源:origin: google/guava

/**
 * The supplied multimap will be mutated and an unmodifiable instance used in its stead. If the
 * multimap does not support null keys or values, alternatives may be specified for tests
 * involving nulls.
 */
private static void checkUnmodifiableMultimap(
  Multimap<String, Integer> multimap,
  boolean permitsDuplicates,
  @Nullable String nullKey,
  @Nullable Integer nullValue) {
 Multimap<String, Integer> unmodifiable =
   prepareUnmodifiableTests(multimap, permitsDuplicates, nullKey, nullValue);
 UnmodifiableCollectionTests.assertMultimapIsUnmodifiable(unmodifiable, "test", 123);
 assertUnmodifiableIterableInTandem(unmodifiable.keys(), multimap.keys());
 assertUnmodifiableIterableInTandem(unmodifiable.keySet(), multimap.keySet());
 assertUnmodifiableIterableInTandem(unmodifiable.entries(), multimap.entries());
 assertUnmodifiableIterableInTandem(
   unmodifiable.asMap().entrySet(), multimap.asMap().entrySet());
 assertEquals(multimap.toString(), unmodifiable.toString());
 assertEquals(multimap.hashCode(), unmodifiable.hashCode());
 assertEquals(multimap, unmodifiable);
 assertThat(unmodifiable.asMap().get("bar")).containsExactly(5, -1);
 assertNull(unmodifiable.asMap().get("missing"));
 assertFalse(unmodifiable.entries() instanceof Serializable);
}

代码示例来源:origin: google/guava

public void testEmptyMultimapReads() {
 Multimap<String, Integer> multimap = ImmutableSetMultimap.of();
 assertFalse(multimap.containsKey("foo"));
 assertFalse(multimap.containsValue(1));
 assertFalse(multimap.containsEntry("foo", 1));
 assertTrue(multimap.entries().isEmpty());
 assertTrue(multimap.equals(HashMultimap.create()));
 assertEquals(Collections.emptySet(), multimap.get("foo"));
 assertEquals(0, multimap.hashCode());
 assertTrue(multimap.isEmpty());
 assertEquals(HashMultiset.create(), multimap.keys());
 assertEquals(Collections.emptySet(), multimap.keySet());
 assertEquals(0, multimap.size());
 assertTrue(multimap.values().isEmpty());
 assertEquals("{}", multimap.toString());
}

代码示例来源:origin: google/guava

public void testEmptyMultimapReads() {
 Multimap<String, Integer> multimap = ImmutableListMultimap.of();
 assertFalse(multimap.containsKey("foo"));
 assertFalse(multimap.containsValue(1));
 assertFalse(multimap.containsEntry("foo", 1));
 assertTrue(multimap.entries().isEmpty());
 assertTrue(multimap.equals(ArrayListMultimap.create()));
 assertEquals(Collections.emptyList(), multimap.get("foo"));
 assertEquals(0, multimap.hashCode());
 assertTrue(multimap.isEmpty());
 assertEquals(HashMultiset.create(), multimap.keys());
 assertEquals(Collections.emptySet(), multimap.keySet());
 assertEquals(0, multimap.size());
 assertTrue(multimap.values().isEmpty());
 assertEquals("{}", multimap.toString());
}

代码示例来源:origin: google/guava

new ImmutableListMultimap.Builder<String, Integer>().put("foo", 1).put("bar", 2).build();
assertFalse("SetMultimap equals ListMultimap", multimapView.equals(listMultimap));
assertEquals(multimap.hashCode(), multimapView.hashCode());
assertEquals(multimap.size(), multimapView.size());
assertTrue(multimapView.containsKey("foo"));
multimap.clear();
assertEquals(multimap.toString(), multimapView.toString());
assertEquals(multimap.hashCode(), multimapView.hashCode());
assertEquals(multimap.size(), multimapView.size());
assertEquals(multimapView, ArrayListMultimap.create());

代码示例来源:origin: apache/metron

@Override
public int hashCode() {
  int result = errors.hashCode();
  result = 31 * result + successes.hashCode();
  return result;
}

代码示例来源:origin: linkedin/indextank-engine

@Override
public int hashCode() {
  final int prime = 31;
  int result = 1;
  result = prime * result
      + ((filteringFacets == null) ? 0 : filteringFacets.hashCode());
  result = prime * result + now;
  result = prime * result
      + ((originalStr == null) ? 0 : originalStr.hashCode());
  result = prime * result
      + ((rangeFilter == null) ? 0 : rangeFilter.hashCode());
  result = prime * result + ((root == null) ? 0 : root.hashCode());
  result = prime * result + ((vars == null) ? 0 : vars.hashCode());
  return result;
}

代码示例来源:origin: com.google.javascript/closure-compiler

@Override
 public int hashCode() {
  return mayUseMap.hashCode();
 }
}

代码示例来源:origin: jclouds/legacy-jclouds

@Override
public int hashCode() {
 final int prime = 31;
 int result = 1;
 result = prime * result + ((formParameters == null) ? 0 : formParameters.hashCode());
 result = prime * result + ((headers == null) ? 0 : headers.hashCode());
 result = prime * result + ((pathSuffix == null) ? 0 : pathSuffix.hashCode());
 result = prime * result + ((payload == null) ? 0 : payload.hashCode());
 result = prime * result + ((queryParameters == null) ? 0 : queryParameters.hashCode());
 return result;
}

代码示例来源:origin: com.github.tomakehurst/wiremock-jre8

@Override
public int hashCode() {
  int result = super.hashCode();
  result = 31 * result + (headers != null ? headers.hashCode() : 0);
  return result;
}

代码示例来源:origin: org.apache.jclouds/jclouds-compute

@Override
public int hashCode() {
 final int prime = 31;
 int result = 1;
 result = prime * result + ((additionalSections == null) ? 0 : additionalSections.hashCode());
 result = prime * result + ((diskSections == null) ? 0 : diskSections.hashCode());
 result = prime * result + ((networkSections == null) ? 0 : networkSections.hashCode());
 result = prime * result + ((virtualSystem == null) ? 0 : virtualSystem.hashCode());
 return result;
}

代码示例来源:origin: jclouds/legacy-jclouds

@Override
public int hashCode() {
 final int prime = 31;
 int result = 1;
 result = prime * result + ((additionalSections == null) ? 0 : additionalSections.hashCode());
 result = prime * result + ((diskSections == null) ? 0 : diskSections.hashCode());
 result = prime * result + ((networkSections == null) ? 0 : networkSections.hashCode());
 result = prime * result + ((virtualSystem == null) ? 0 : virtualSystem.hashCode());
 return result;
}

代码示例来源:origin: com.diffplug.guava/guava-collect

@Override
  public int hashCode() {
    return delegate().hashCode();
  }
}

代码示例来源:origin: ai.grakn/grakn-graql

@Override
public int structuralEquivalenceHashCode() {
  int equivalenceHashCode = baseHashCode();
  equivalenceHashCode = equivalenceHashCode * 37 + this.getRoleTypeMap(false).hashCode();
  equivalenceHashCode = equivalenceHashCode * 37 + this.getRoleConceptIdMap().keySet().hashCode();
  return equivalenceHashCode;
}

相关文章