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

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

本文整理了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

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

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

@Override
public boolean equals(Object o) {
 if (o == this) {
  return true;
 }
 synchronized (mutex) {
  return delegate().equals(o);
 }
}

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

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

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

@Override
public boolean equals(Object o) {
 if (o == this) {
  return true;
 }
 synchronized (mutex) {
  return delegate().equals(o);
 }
}

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

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

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

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

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

@Override
public boolean equals(Object o) {
 if (o == this) {
  return true;
 }
 synchronized (mutex) {
  return delegate().equals(o);
 }
}

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

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

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

public void sanityCheck()
  {
    Multiset<PlanFragmentId> exchangeIds = fragment.getRemoteSourceNodes().stream()
        .map(RemoteSourceNode::getSourceFragmentIds)
        .flatMap(List::stream)
        .collect(toImmutableMultiset());

    Multiset<PlanFragmentId> childrenIds = children.stream()
        .map(SubPlan::getFragment)
        .map(PlanFragment::getId)
        .collect(toImmutableMultiset());

    Preconditions.checkState(exchangeIds.equals(childrenIds), "Subplan exchange ids don't match child fragment ids (%s vs %s)", exchangeIds, childrenIds);

    for (SubPlan child : children) {
      child.sanityCheck();
    }
  }
}

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

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

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

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

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

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

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

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

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

public void testToMultisetCountFunction() {
 BiPredicate<Multiset<String>, Multiset<String>> equivalence =
   (ms1, ms2) ->
     ms1.equals(ms2)
       && ImmutableList.copyOf(ms1.entrySet())
         .equals(ImmutableList.copyOf(ms2.entrySet()));
 CollectorTester.of(
     Multisets.<Multiset.Entry<String>, String, Multiset<String>>toMultiset(
       Multiset.Entry::getElement, Multiset.Entry::getCount, LinkedHashMultiset::create),
     equivalence)
   .expectCollects(ImmutableMultiset.<String>of())
   .expectCollects(
     ImmutableMultiset.of("a", "a", "b", "c", "c", "c"),
     Multisets.immutableEntry("a", 1),
     Multisets.immutableEntry("b", 1),
     Multisets.immutableEntry("a", 1),
     Multisets.immutableEntry("c", 3));
}

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

/**
 * Returns {@code true} if the second list is a permutation of the first.
 */
private static boolean isPermutation(List<?> first,
  List<?> second) {
 if (first.size() != second.size()) {
  return false;
 }
 Multiset<?> firstSet = HashMultiset.create(first);
 Multiset<?> secondSet = HashMultiset.create(second);
 return firstSet.equals(secondSet);
}

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

@Override public boolean equals(Object o) {
 if (o == this) {
  return true;
 }
 synchronized (mutex) {
  return delegate().equals(o);
 }
}

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

@Override public boolean equals(Object o) {
 if (o == this) {
  return true;
 }
 synchronized (mutex) {
  return delegate().equals(o);
 }
}

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

@Override
public boolean equals(Object o) {
 if (o == this) {
  return true;
 }
 synchronized (mutex) {
  return delegate().equals(o);
 }
}

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

@Override
public boolean equals(Object o) {
  if (o == this) {
    return true;
  }
  synchronized (mutex) {
    return delegate().equals(o);
  }
}

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

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

相关文章