@Override public E ceiling(E element) { int index = tailIndex(element, true); return (index == size()) ? null : elements.get(index); }
@Override public E higher(E element) { int index = tailIndex(element, false); return (index == size()) ? null : elements.get(index); }
@Override public ImmutableSortedMultiset<E> tailMultiset(E lowerBound, BoundType boundType) { return getSubMultiset( elementSet.tailIndex(lowerBound, checkNotNull(boundType) == CLOSED), length); }
@Override public E higher(E element) { int index = tailIndex(element, false); return (index == size()) ? null : elements.get(index); }
/** * This method returns a {@code ImmutableSortedMap}, consisting of the entries whose keys are * greater than (or equal to, if {@code inclusive}) {@code fromKey}. * * <p>The {@link SortedMap#tailMap} documentation states that a submap of a submap throws an * {@link IllegalArgumentException} if passed a {@code fromKey} less than an earlier {@code * fromKey}. However, this method doesn't throw an exception in that situation, but instead keeps * the original {@code fromKey}. * * @since 12.0 */ @Override public ImmutableSortedMap<K, V> tailMap(K fromKey, boolean inclusive) { return getSubMap(keySet.tailIndex(checkNotNull(fromKey), inclusive), size()); }
@Override public E ceiling(E element) { int index = tailIndex(element, true); return (index == size()) ? null : elements.get(index); }
@Override ImmutableSortedSet<E> tailSetImpl(E fromElement, boolean inclusive) { return getSubSet(tailIndex(fromElement, inclusive), size()); }
@Override public ImmutableSortedMultiset<E> tailMultiset(E lowerBound, BoundType boundType) { return getSubMultiset( elementSet.tailIndex(lowerBound, checkNotNull(boundType) == CLOSED), length); }
@Override public E higher(E element) { int index = tailIndex(element, false); return (index == size()) ? null : elements.get(index); }
/** * This method returns a {@code ImmutableSortedMap}, consisting of the entries whose keys are * greater than (or equal to, if {@code inclusive}) {@code fromKey}. * * <p>The {@link SortedMap#tailMap} documentation states that a submap of a submap throws an * {@link IllegalArgumentException} if passed a {@code fromKey} less than an earlier {@code * fromKey}. However, this method doesn't throw an exception in that situation, but instead keeps * the original {@code fromKey}. * * @since 12.0 */ @Override public ImmutableSortedMap<K, V> tailMap(K fromKey, boolean inclusive) { return getSubMap(keySet.tailIndex(checkNotNull(fromKey), inclusive), size()); }
@Override ImmutableSortedSet<E> tailSetImpl(E fromElement, boolean inclusive) { return getSubSet(tailIndex(fromElement, inclusive), size()); }
public ImmutableSortedMultiset<E> tailMultiset(E lowerBound, BoundType boundType) { return getSubMultiset( elementSet.tailIndex(lowerBound, checkNotNull(boundType) == CLOSED), length);
/** * A builder for creating immutable sorted map instances, especially {@code public static final} * maps ("constant maps"). Example: * * <pre>{@code * static final ImmutableSortedMap<Integer, String> INT_TO_WORD = * new ImmutableSortedMap.Builder<Integer, String>(Ordering.natural()) * .put(1, "one") * .put(2, "two") * .put(3, "three") * .build(); * }</pre> * * <p>For <i>small</i> immutable sorted maps, the {@code ImmutableSortedMap.of()} methods are even * more convenient. * * <p>Builder instances can be reused - it is safe to call {@link #build} multiple times to build * multiple maps in series. Each map is a superset of the maps created before it. * * @since 2.0 */ public static class Builder<K, V> extends ImmutableMap.Builder<K, V> { private transient Object[] keys; private transient Object[] values; private final Comparator<? super K> comparator; /** * Creates a new builder. The returned builder is equivalent to the builder generated by {@link * ImmutableSortedMap#orderedBy}. */
@Override public E higher(E element) { int index = tailIndex(element, false); return (index == size()) ? null : elements.get(index); }
@Override public ImmutableSortedMultiset<E> tailMultiset(E lowerBound, BoundType boundType) { return getSubMultiset( elementSet.tailIndex(lowerBound, checkNotNull(boundType) == CLOSED), length); }
@Override public E higher(E element) { int index = tailIndex(element, false); return (index == size()) ? null : elements.get(index); }
@Override public ImmutableSortedMultiset<E> tailMultiset(E lowerBound, BoundType boundType) { return getSubMultiset(elementSet.tailIndex(lowerBound, checkNotNull(boundType) == CLOSED), length); }
@Override public E ceiling(E element) { int index = tailIndex(element, true); return (index == size()) ? null : elements.get(index); }
@Override public ImmutableSortedMultiset<E> tailMultiset(E lowerBound, BoundType boundType) { return getSubMultiset(elementSet.tailIndex(lowerBound, checkNotNull(boundType) == CLOSED), length); }
@Override public E ceiling(E element) { int index = tailIndex(element, true); return (index == size()) ? null : elements.get(index); }