/** * {@inheritDoc} * * <p>This method returns a serializable {@code ImmutableSortedSet}. * * <p>The {@link SortedSet#tailSet} documentation states that a subset of a subset throws an * {@link IllegalArgumentException} if passed a {@code fromElement} smaller than an earlier {@code * fromElement}. However, this method doesn't throw an exception in that situation, but instead * keeps the original {@code fromElement}. */ @Override public ImmutableSortedSet<E> tailSet(E fromElement) { return tailSet(fromElement, true); }
@Override protected SortedSet<String> create(String[] elements) { List<String> list = Lists.newArrayList(elements); list.add("\0"); return ImmutableSortedSet.copyOf(list).tailSet("\0\0"); } }
/** * {@inheritDoc} * * <p>This method returns a serializable {@code ImmutableSortedSet}. * * <p>The {@link SortedSet#tailSet} documentation states that a subset of a subset throws an * {@link IllegalArgumentException} if passed a {@code fromElement} smaller than an earlier {@code * fromElement}. However, this method doesn't throw an exception in that situation, but instead * keeps the original {@code fromElement}. */ @Override public ImmutableSortedSet<E> tailSet(E fromElement) { return tailSet(fromElement, true); }
/** @since 12.0 */ @GwtIncompatible // NavigableSet @Override public E ceiling(E e) { return Iterables.getFirst(tailSet(e, true), null); }
/** @since 12.0 */ @GwtIncompatible // NavigableSet @Override public E higher(E e) { return Iterables.getFirst(tailSet(e, false), null); }
@Override ImmutableSortedSet<E> headSetImpl(E toElement, boolean inclusive) { return forward.tailSet(toElement, inclusive).descendingSet(); }
@Override ImmutableSortedSet<E> headSetImpl(E toElement, boolean inclusive) { return forward.tailSet(toElement, inclusive).descendingSet(); }
/** @since 12.0 */ @GwtIncompatible // NavigableSet @Override public E higher(E e) { return Iterables.getFirst(tailSet(e, false), null); }
/** @since 12.0 */ @GwtIncompatible // NavigableSet @Override public E ceiling(E e) { return Iterables.getFirst(tailSet(e, true), null); }
@Override ImmutableSortedSet<E> headSetImpl(E toElement, boolean inclusive) { return forward.tailSet(toElement, inclusive).descendingSet(); }
public void testAsSetTailSet() { ImmutableSortedSet<Integer> expectedSet = ImmutableSortedSet.of(2, 3, 4, 8, 9, 16, 17); ImmutableSortedSet<Integer> asSet = RANGE_SET_ONE.asSet(DiscreteDomain.integers()); for (int i = 0; i <= 20; i++) { assertEquals(asSet.tailSet(i, false), expectedSet.tailSet(i, false)); assertEquals(asSet.tailSet(i, true), expectedSet.tailSet(i, true)); } }
public void testTailSet() { ImmutableSortedSet<Integer> set = ContiguousSet.create(Range.closed(1, 3), integers()); assertThat(set.tailSet(Integer.MIN_VALUE)).containsExactly(1, 2, 3).inOrder(); assertThat(set.tailSet(1)).containsExactly(1, 2, 3).inOrder(); assertThat(set.tailSet(2)).containsExactly(2, 3).inOrder(); assertThat(set.tailSet(3)).containsExactly(3).inOrder(); assertThat(set.tailSet(Integer.MIN_VALUE, false)).containsExactly(1, 2, 3).inOrder(); assertThat(set.tailSet(1, false)).containsExactly(2, 3).inOrder(); assertThat(set.tailSet(2, false)).containsExactly(3).inOrder(); assertThat(set.tailSet(3, false)).isEmpty(); }
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 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(); } }
@Override protected SortedSet<String> create(String[] elements) { List<String> list = Lists.newArrayList(elements); list.add("\0"); return ImmutableSortedSet.copyOf(list).tailSet("\0\0"); } }
/** * @since 12.0 */ @GwtIncompatible("NavigableSet") @Override public E ceiling(E e) { return Iterables.getFirst(tailSet(e, true), null); }
/** * @since 12.0 */ @GwtIncompatible("NavigableSet") @Override public E ceiling(E e) { return Iterables.getFirst(tailSet(e, true), null); }
/** @since 12.0 */ @GwtIncompatible // NavigableSet @Override public E ceiling(E e) { return Iterables.getFirst(tailSet(e, true), null); }
/** * @since 12.0 */ @GwtIncompatible("NavigableSet") @Override public E ceiling(E e) { return Iterables.getFirst(tailSet(e, true), null); }
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(); } }