Returns a view of the portion of set whose elements are contained by range. This method delegates to the appropriate methods of NavigableSet (namely NavigableSet#subSet(Object, boolean, Object, boolean) subSet(), {@link NavigableSet#tailSet(Object, boolean) tailSe
(
NavigableSet<K> set, Range<K> range)
| 1756 | * @since 20.0 |
| 1757 | */ |
| 1758 | @Beta |
| 1759 | @GwtIncompatible // NavigableSet |
| 1760 | public static <K extends Comparable<? super K>> NavigableSet<K> subSet( |
| 1761 | NavigableSet<K> set, Range<K> range) { |
| 1762 | if (set.comparator() != null |
| 1763 | && set.comparator() != Ordering.natural() |
| 1764 | && range.hasLowerBound() |
| 1765 | && range.hasUpperBound()) { |
| 1766 | checkArgument( |
| 1767 | set.comparator().compare(range.lowerEndpoint(), range.upperEndpoint()) <= 0, |
| 1768 | "set is using a custom comparator which is inconsistent with the natural ordering."); |
| 1769 | } |
| 1770 | if (range.hasLowerBound() && range.hasUpperBound()) { |
| 1771 | return set.subSet( |
| 1772 | range.lowerEndpoint(), |
| 1773 | range.lowerBoundType() == BoundType.CLOSED, |
| 1774 | range.upperEndpoint(), |
| 1775 | range.upperBoundType() == BoundType.CLOSED); |
| 1776 | } else if (range.hasLowerBound()) { |
| 1777 | return set.tailSet(range.lowerEndpoint(), range.lowerBoundType() == BoundType.CLOSED); |
| 1778 | } else if (range.hasUpperBound()) { |
| 1779 | return set.headSet(range.upperEndpoint(), range.upperBoundType() == BoundType.CLOSED); |
| 1780 | } |
| 1781 | return checkNotNull(set); |
| 1782 | } |
| 1783 | } |
no test coverage detected