/** * Returns a sub-view, backed by this one, whose keys start with the given prefix. Ownership of * the prefix instance is transferred, and so it must not be modified after calling this method. * * <p>The returned view will throw a {@link ViewConstraintException} on an attempt to insert a key * outside its range. * * @param trim amount of prefix length to trim from all keys in the view * @throws UnsupportedOperationException if view is unordered * @throws NullPointerException if prefix is null * @throws IllegalArgumentException if trim is longer than prefix */ public default View viewPrefix(byte[] prefix, int trim) { Ordering ordering = getOrdering(); if (ordering == Ordering.ASCENDING) { return BoundedView.viewPrefix(this, prefix, trim); } else if (ordering == Ordering.DESCENDING) { return BoundedView.viewPrefix(viewReverse(), prefix, trim).viewReverse(); } else { throw new UnsupportedOperationException("Unsupported ordering: " + ordering); } }
/** * Returns a sub-view, backed by this one, whose keys are less than the given key. Ownership of * the key instance is transferred, and so it must not be modified after calling this method. * * <p>The returned view will throw a {@link ViewConstraintException} on an attempt to insert a key * outside its range. * * @throws UnsupportedOperationException if view is unordered * @throws NullPointerException if key is null */ public default View viewLt(byte[] key) { Ordering ordering = getOrdering(); if (ordering == Ordering.ASCENDING) { return BoundedView.viewLt(this, key); } else if (ordering == Ordering.DESCENDING) { return BoundedView.viewLt(viewReverse(), key).viewReverse(); } else { throw new UnsupportedOperationException("Unsupported ordering: " + ordering); } }