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

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

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

Multiset.equals介绍

[英]Compares the specified object with this multiset for equality. Returns true if the given object is also a multiset and contains equal elements with equal counts, regardless of order.
[中]将指定的对象与此多重集进行比较以确定相等性。如果给定对象也是一个多集,并且包含计数相等的相等元素,则无论顺序如何,都返回true。

代码示例

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

  1. /** Returns {@code true} if the second list is a permutation of the first. */
  2. private static boolean isPermutation(List<?> first, List<?> second) {
  3. if (first.size() != second.size()) {
  4. return false;
  5. }
  6. Multiset<?> firstMultiset = HashMultiset.create(first);
  7. Multiset<?> secondMultiset = HashMultiset.create(second);
  8. return firstMultiset.equals(secondMultiset);
  9. }
  10. }

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

  1. @Override
  2. public boolean equals(Object o) {
  3. if (o == this) {
  4. return true;
  5. }
  6. synchronized (mutex) {
  7. return delegate().equals(o);
  8. }
  9. }

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

  1. /** Returns {@code true} if the second list is a permutation of the first. */
  2. private static boolean isPermutation(List<?> first, List<?> second) {
  3. if (first.size() != second.size()) {
  4. return false;
  5. }
  6. Multiset<?> firstMultiset = HashMultiset.create(first);
  7. Multiset<?> secondMultiset = HashMultiset.create(second);
  8. return firstMultiset.equals(secondMultiset);
  9. }
  10. }

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

  1. @Override
  2. public boolean equals(Object o) {
  3. if (o == this) {
  4. return true;
  5. }
  6. synchronized (mutex) {
  7. return delegate().equals(o);
  8. }
  9. }

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

  1. @Override
  2. public boolean equals(@Nullable Object object) {
  3. return object == this || delegate().equals(object);
  4. }

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

  1. public void testEquals_yes() {
  2. assertTrue(
  3. "multiset doesn't equal a multiset with the same elements",
  4. getMultiset().equals(HashMultiset.create(getSampleElements())));
  5. }

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

  1. @Override
  2. public boolean equals(Object o) {
  3. if (o == this) {
  4. return true;
  5. }
  6. synchronized (mutex) {
  7. return delegate().equals(o);
  8. }
  9. }

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

  1. public void testEquals_differentSize() {
  2. Multiset<E> other = HashMultiset.create(getSampleElements());
  3. other.add(e0());
  4. assertFalse("multiset equals a multiset with a different size", getMultiset().equals(other));
  5. }

代码示例来源:origin: prestodb/presto

  1. public void sanityCheck()
  2. {
  3. Multiset<PlanFragmentId> exchangeIds = fragment.getRemoteSourceNodes().stream()
  4. .map(RemoteSourceNode::getSourceFragmentIds)
  5. .flatMap(List::stream)
  6. .collect(toImmutableMultiset());
  7. Multiset<PlanFragmentId> childrenIds = children.stream()
  8. .map(SubPlan::getFragment)
  9. .map(PlanFragment::getId)
  10. .collect(toImmutableMultiset());
  11. Preconditions.checkState(exchangeIds.equals(childrenIds), "Subplan exchange ids don't match child fragment ids (%s vs %s)", exchangeIds, childrenIds);
  12. for (SubPlan child : children) {
  13. child.sanityCheck();
  14. }
  15. }
  16. }

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

  1. @Override
  2. public boolean equals(@NullableDecl Object object) {
  3. return object == this || delegate().equals(object);
  4. }

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

  1. @CollectionSize.Require(absent = ZERO)
  2. public void testEquals_differentElements() {
  3. Multiset<E> other = HashMultiset.create(getSampleElements());
  4. other.remove(e0());
  5. other.add(e3());
  6. assertFalse("multiset equals a multiset with different elements", getMultiset().equals(other));
  7. }

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

  1. @Override
  2. public boolean equals(@NullableDecl Object object) {
  3. return object == this || delegate().equals(object);
  4. }

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

  1. Multiset<String> conjsOp1String = extractConjsIgnoringDPPPreds(op1Conf.getPredicate());
  2. Multiset<String> conjsOp2String = extractConjsIgnoringDPPPreds(op2Conf.getPredicate());
  3. if (conjsOp1String.equals(conjsOp2String)) {
  4. equalFilters = true;

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

  1. public void testToMultisetCountFunction() {
  2. BiPredicate<Multiset<String>, Multiset<String>> equivalence =
  3. (ms1, ms2) ->
  4. ms1.equals(ms2)
  5. && ImmutableList.copyOf(ms1.entrySet())
  6. .equals(ImmutableList.copyOf(ms2.entrySet()));
  7. CollectorTester.of(
  8. Multisets.<Multiset.Entry<String>, String, Multiset<String>>toMultiset(
  9. Multiset.Entry::getElement, Multiset.Entry::getCount, LinkedHashMultiset::create),
  10. equivalence)
  11. .expectCollects(ImmutableMultiset.<String>of())
  12. .expectCollects(
  13. ImmutableMultiset.of("a", "a", "b", "c", "c", "c"),
  14. Multisets.immutableEntry("a", 1),
  15. Multisets.immutableEntry("b", 1),
  16. Multisets.immutableEntry("a", 1),
  17. Multisets.immutableEntry("c", 3));
  18. }

代码示例来源:origin: org.hudsonci.lib.guava/guava

  1. /**
  2. * Returns {@code true} if the second list is a permutation of the first.
  3. */
  4. private static boolean isPermutation(List<?> first,
  5. List<?> second) {
  6. if (first.size() != second.size()) {
  7. return false;
  8. }
  9. Multiset<?> firstSet = HashMultiset.create(first);
  10. Multiset<?> secondSet = HashMultiset.create(second);
  11. return firstSet.equals(secondSet);
  12. }

代码示例来源:origin: com.google.guava/guava-jdk5

  1. @Override public boolean equals(Object o) {
  2. if (o == this) {
  3. return true;
  4. }
  5. synchronized (mutex) {
  6. return delegate().equals(o);
  7. }
  8. }

代码示例来源:origin: at.bestsolution.efxclipse.eclipse/com.google.guava

  1. @Override public boolean equals(Object o) {
  2. if (o == this) {
  3. return true;
  4. }
  5. synchronized (mutex) {
  6. return delegate().equals(o);
  7. }
  8. }

代码示例来源:origin: org.jboss.eap/wildfly-client-all

  1. @Override
  2. public boolean equals(Object o) {
  3. if (o == this) {
  4. return true;
  5. }
  6. synchronized (mutex) {
  7. return delegate().equals(o);
  8. }
  9. }

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

  1. @Override
  2. public boolean equals(Object o) {
  3. if (o == this) {
  4. return true;
  5. }
  6. synchronized (mutex) {
  7. return delegate().equals(o);
  8. }
  9. }

代码示例来源:origin: com.google.guava/guava-testlib

  1. public void testEquals_yes() {
  2. assertTrue(
  3. "multiset doesn't equal a multiset with the same elements",
  4. getMultiset().equals(HashMultiset.create(getSampleElements())));
  5. }

相关文章