public static void assertEqualsIgnoreOrder(Iterable<?> actual, Iterable<?> expected, String message) { assertNotNull(actual, "actual is null"); assertNotNull(expected, "expected is null"); ImmutableMultiset<?> actualSet = ImmutableMultiset.copyOf(actual); ImmutableMultiset<?> expectedSet = ImmutableMultiset.copyOf(expected); if (!actualSet.equals(expectedSet)) { Multiset<?> unexpectedRows = Multisets.difference(actualSet, expectedSet); Multiset<?> missingRows = Multisets.difference(expectedSet, actualSet); int limit = 100; fail(format( "%snot equal\n" + "Actual rows (up to %s of %s extra rows shown, %s rows in total):\n %s\n" + "Expected rows (up to %s of %s missing rows shown, %s rows in total):\n %s\n", message == null ? "" : (message + "\n"), limit, unexpectedRows.size(), actualSet.size(), Joiner.on("\n ").join(Iterables.limit(unexpectedRows, limit)), limit, missingRows.size(), expectedSet.size(), Joiner.on("\n ").join(Iterables.limit(missingRows, limit)))); } }
/** * Get bag size * * @return bag size */ public final int size() { return elements.size(); }
public String optv(int i) { ImmutableMultiset<String> keys = _options.keys(); return (i < keys.size()) ? keys.asList().get(i) : null; }
/** * Returns {@code true} if the bindings contain one {@code @Inject} binding and one that isn't. */ private static boolean explicitBindingConfictsWithInject( ImmutableSet<BindingElement> duplicateBindings) { ImmutableMultiset<BindingKind> bindingKinds = Multimaps.index(duplicateBindings, BindingElement::bindingKind).keys(); return bindingKinds.count(INJECTION) == 1 && bindingKinds.size() == 2; }
public static void assertEqualsIgnoreOrder(Iterable<?> actual, Iterable<?> expected, String message) { assertNotNull(actual, "actual is null"); assertNotNull(expected, "expected is null"); ImmutableMultiset<?> actualSet = ImmutableMultiset.copyOf(actual); ImmutableMultiset<?> expectedSet = ImmutableMultiset.copyOf(expected); if (!actualSet.equals(expectedSet)) { Multiset<?> unexpectedRows = Multisets.difference(actualSet, expectedSet); Multiset<?> missingRows = Multisets.difference(expectedSet, actualSet); int limit = 100; fail(format( "%snot equal\n" + "Actual rows (up to %s of %s extra rows shown, %s rows in total):\n %s\n" + "Expected rows (up to %s of %s missing rows shown, %s rows in total):\n %s\n", message == null ? "" : (message + "\n"), limit, unexpectedRows.size(), actualSet.size(), Joiner.on("\n ").join(Iterables.limit(unexpectedRows, limit)), limit, missingRows.size(), expectedSet.size(), Joiner.on("\n ").join(Iterables.limit(missingRows, limit)))); } }
public static void assertEqualsIgnoreOrder(Iterable<?> actual, Iterable<?> expected, String message) { assertNotNull(actual, "actual is null"); assertNotNull(expected, "expected is null"); ImmutableMultiset<?> actualSet = ImmutableMultiset.copyOf(actual); ImmutableMultiset<?> expectedSet = ImmutableMultiset.copyOf(expected); if (!actualSet.equals(expectedSet)) { Multiset<?> unexpectedRows = Multisets.difference(actualSet, expectedSet); Multiset<?> missingRows = Multisets.difference(expectedSet, actualSet); int limit = 100; fail(format( "%snot equal\n" + "Actual rows (up to %s of %s extra rows shown, %s rows in total):\n %s\n" + "Expected rows (up to %s of %s missing rows shown, %s rows in total):\n %s\n", message == null ? "" : (message + "\n"), limit, unexpectedRows.size(), actualSet.size(), Joiner.on("\n ").join(Iterables.limit(unexpectedRows, limit)), limit, missingRows.size(), expectedSet.size(), Joiner.on("\n ").join(Iterables.limit(missingRows, limit)))); } }
private static Variable computeFrame( ImmutableMultiset<KItem> collectionPatterns, ImmutableMultiset<Term> collectionFunctions, ImmutableMultiset<Variable> collectionVariables) { if (collectionPatterns.isEmpty() && collectionFunctions.isEmpty() && collectionVariables.size() == 1) { return collectionVariables.iterator().next(); } else { return null; } }
@Override public boolean equals(@Nullable Object object) { if (object == this) { return true; } if (object instanceof Multiset) { Multiset<?> that = (Multiset<?>) object; if (this.size() != that.size()) { return false; } for (Entry<?> entry : that.entrySet()) { if (count(entry.getElement()) != entry.getCount()) { return false; } } return true; } return false; }
@Override public boolean equals(@Nullable Object object) { if (object == this) { return true; } if (object instanceof Multiset) { Multiset<?> that = (Multiset<?>) object; if (this.size() != that.size()) { return false; } for (Entry<?> entry : that.entrySet()) { if (count(entry.getElement()) != entry.getCount()) { return false; } } return true; } return false; }
@Override public boolean equals(@Nullable Object object) { if (object == this) { return true; } if (object instanceof Multiset) { Multiset<?> that = (Multiset<?>) object; if (this.size() != that.size()) { return false; } for (Entry<?> entry : that.entrySet()) { if (count(entry.getElement()) != entry.getCount()) { return false; } } return true; } return false; }
@Override public boolean equals(@Nullable Object object) { if (object == this) { return true; } if (object instanceof Multiset) { Multiset<?> that = (Multiset<?>) object; if (this.size() != that.size()) { return false; } for (Entry<?> entry : that.entrySet()) { if (count(entry.getElement()) != entry.getCount()) { return false; } } return true; } return false; }
@Override public boolean equals(@Nullable Object object) { if (object == this) { return true; } if (object instanceof Multiset) { Multiset<?> that = (Multiset<?>) object; if (this.size() != that.size()) { return false; } for (Entry<?> entry : that.entrySet()) { if (count(entry.getElement()) != entry.getCount()) { return false; } } return true; } return false; }
@Override public boolean equals(@Nullable Object object) { if (object == this) { return true; } if (object instanceof Multiset) { Multiset<?> that = (Multiset<?>) object; if (this.size() != that.size()) { return false; } for (Entry<?> entry : that.entrySet()) { if (count(entry.getElement()) != entry.getCount()) { return false; } } return true; } return false; }
private void testImmutableXXX() { assertEquals(5, ImmutableList.of(1, 2, 3, 4, 5).size()); assertEquals(5, ImmutableSet.of(1, 2, 3, 4, 5).size()); assertEquals(5, ImmutableSortedSet.of(1, 2, 3, 4, 5).size()); assertEquals(3, ImmutableMap.of(1, 2, 3, 4, 5, 6).size()); assertEquals(3, ImmutableSortedMap.of(1, 2, 3, 4, 5, 6).size()); assertEquals(9, ImmutableMultiset.of(1, 1, 2, 2, 3, 3, 4, 5, 6).size()); assertEquals(6, ImmutableMultiset.of(1, 1, 2, 2, 3, 3, 4, 5, 6).elementSet().size()); assertEquals(2, ImmutableMultiset.of(1, 1, 2, 2, 3, 3, 4, 5, 6).count(1)); } }
@Override public boolean equals(@Nullable Object other) { if (other == this) { return true; } if (other instanceof Multiset) { Multiset<?> that = (Multiset<?>) other; if (this.size() != that.size()) { return false; } for (Entry<?> entry : that.entrySet()) { if (count(entry.getElement()) != entry.getCount()) { return false; } } return true; } return false; }
public Term build() { // YilongL: Guava's ImmutableMap.copyOf(entries) is not smart enough // to avoid actually copying the entries, because entries is not an // ImmutableMap yet; using Apache's decorate method because it would // avoid creating nesting wrappers BuiltinMap builtinMap = new BuiltinMap( (UnmodifiableMap<Term, Term>) UnmodifiableMap.unmodifiableMap(entries), patternsBuilder.build(), functionsBuilder.build(), variablesBuilder.build(), global); return builtinMap.baseTerms().size() == 1 && builtinMap.collectionVariables().size() == 1 && builtinMap.concreteSize() == 0 ? builtinMap.baseTerms().iterator().next() : builtinMap; } }