@Override public Set<UnhashableObject> create(UnhashableObject[] elements) { return ImmutableSortedSet.copyOf(elements); } }
@Override protected List<String> create(String[] elements) { Comparator<String> comparator = createExplicitComparator(elements); ImmutableSet<String> set = ImmutableSortedSet.copyOf(comparator, Arrays.asList(elements)); return set.asList(); } }
@Override public <E extends Comparable<E>> Set<E> create(Collection<E> contents) { return ImmutableSortedSet.copyOf(contents); } },
@Override protected SortedSet<String> create(String[] elements) { List<String> list = Lists.newArrayList(elements); list.add("\0"); list.add("zzz"); return ImmutableSortedSet.copyOf(list).subSet("\0\0", "zzy"); } }
private static <V> ImmutableSet<V> valueSet( @Nullable Comparator<? super V> valueComparator, Collection<? extends V> values) { return (valueComparator == null) ? ImmutableSet.copyOf(values) : ImmutableSortedSet.copyOf(valueComparator, values); }
@Override protected <E extends Comparable<? super E>> SortedSet<E> copyOf( Collection<? extends E> elements) { return ImmutableSortedSet.copyOf(elements); }
public void testCopyOfExplicit_ordering() { SortedSet<String> set = ImmutableSortedSet.copyOf( STRING_LENGTH, asList("in", "the", "quick", "jumped", "over", "a")); assertThat(set).containsExactly("a", "in", "the", "over", "quick", "jumped").inOrder(); }
public void testCopyOfExplicit_ordering_dupes() { SortedSet<String> set = ImmutableSortedSet.copyOf( STRING_LENGTH, asList("in", "the", "quick", "brown", "fox", "jumped", "over", "a", "lazy", "dog")); assertThat(set).containsExactly("a", "in", "the", "over", "quick", "jumped").inOrder(); }
public void testLegacyComparable_copyOf_iterator() { ImmutableSortedSet<LegacyComparable> set = ImmutableSortedSet.copyOf(LegacyComparable.VALUES_BACKWARD.iterator()); assertTrue(Iterables.elementsEqual(LegacyComparable.VALUES_FORWARD, set)); }
public void testCopyOfExplicit_iterator_comparator() { SortedSet<String> set = ImmutableSortedSet.copyOf( STRING_LENGTH, asIterator("in", "the", "quick", "jumped", "over", "a")); assertSame(STRING_LENGTH, set.comparator()); }
private void doHasAllFauxveridesTest(Class<?> descendant, Class<?> ancestor) { Set<MethodSignature> required = getAllRequiredToFauxveride(ancestor); Set<MethodSignature> found = getAllFauxveridden(descendant, ancestor); Set<MethodSignature> missing = ImmutableSortedSet.copyOf(difference(required, found)); if (!missing.isEmpty()) { fail( rootLocaleFormat( "%s should hide the public static methods declared in %s: %s", descendant.getSimpleName(), ancestor.getSimpleName(), missing)); } }
public void testLegacyComparable_copyOf_collection() { ImmutableSortedSet<LegacyComparable> set = ImmutableSortedSet.copyOf(LegacyComparable.VALUES_BACKWARD); assertTrue(Iterables.elementsEqual(LegacyComparable.VALUES_FORWARD, set)); }
public void testCopyOfExplicit_iterator_ordering_dupes() { SortedSet<String> set = ImmutableSortedSet.copyOf( STRING_LENGTH, asIterator("in", "the", "quick", "brown", "fox", "jumped", "over", "a", "lazy", "dog")); assertThat(set).containsExactly("a", "in", "the", "over", "quick", "jumped").inOrder(); }
public void testCopyOfExplicit_iterator_ordering() { SortedSet<String> set = ImmutableSortedSet.copyOf( STRING_LENGTH, asIterator("in", "the", "quick", "jumped", "over", "a")); assertThat(set).containsExactly("a", "in", "the", "over", "quick", "jumped").inOrder(); }
public void testSubSetExclusiveExclusive() { String[] strings = NUMBER_NAMES.toArray(new String[0]); ImmutableSortedSet<String> set = ImmutableSortedSet.copyOf(strings); Arrays.sort(strings); for (int i = 0; i < strings.length; i++) { for (int j = i; j < strings.length; j++) { assertThat(set.subSet(strings[i], false, strings[j], false)) .containsExactlyElementsIn(sortedNumberNames(Math.min(i + 1, j), j)) .inOrder(); } } }
public void testTailSetInclusive() { String[] strings = NUMBER_NAMES.toArray(new String[0]); ImmutableSortedSet<String> set = ImmutableSortedSet.copyOf(strings); Arrays.sort(strings); for (int i = 0; i < strings.length; i++) { assertThat(set.tailSet(strings[i], true)) .containsExactlyElementsIn(sortedNumberNames(i, strings.length)) .inOrder(); } }
public void testSubSetExclusiveInclusive() { String[] strings = NUMBER_NAMES.toArray(new String[0]); ImmutableSortedSet<String> set = ImmutableSortedSet.copyOf(strings); Arrays.sort(strings); for (int i = 0; i < strings.length; i++) { for (int j = i; j < strings.length; j++) { assertThat(set.subSet(strings[i], false, strings[j], true)) .containsExactlyElementsIn(sortedNumberNames(i + 1, j + 1)) .inOrder(); } } }
public void testSubSetInclusiveInclusive() { String[] strings = NUMBER_NAMES.toArray(new String[0]); ImmutableSortedSet<String> set = ImmutableSortedSet.copyOf(strings); Arrays.sort(strings); for (int i = 0; i < strings.length; i++) { for (int j = i; j < strings.length; j++) { assertThat(set.subSet(strings[i], true, strings[j], true)) .containsExactlyElementsIn(sortedNumberNames(i, j + 1)) .inOrder(); } } }
public void testHeadSetInclusive() { String[] strings = NUMBER_NAMES.toArray(new String[0]); ImmutableSortedSet<String> set = ImmutableSortedSet.copyOf(strings); Arrays.sort(strings); for (int i = 0; i < strings.length; i++) { assertThat(set.headSet(strings[i], true)) .containsExactlyElementsIn(sortedNumberNames(0, i + 1)) .inOrder(); } }
public void testTailSetExclusive() { String[] strings = NUMBER_NAMES.toArray(new String[0]); ImmutableSortedSet<String> set = ImmutableSortedSet.copyOf(strings); Arrays.sort(strings); for (int i = 0; i < strings.length; i++) { assertThat(set.tailSet(strings[i], false)) .containsExactlyElementsIn(sortedNumberNames(i + 1, strings.length)) .inOrder(); } }