All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.fitbur.google.common.collect.ForwardingNavigableSet Maven / Gradle / Ivy

There is a newer version: 1.0.0
Show newest version
/*
 * Copyright (C) 2012 The Guava Authors
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in com.fitburpliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.com.fitbur/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.fitbur.google.com.fitburmon.collect;

import com.fitbur.google.com.fitburmon.annotations.Beta;

import java.util.Iterator;
import java.util.NavigableSet;
import java.util.SortedSet;

/**
 * A navigable set which forwards all its method calls to another navigable set. Subclasses should
 * override one or more methods to modify the behavior of the backing set as com.fitbursired per the com.fitburcorator pattern.
 *
 * 

Warning: The methods of {@code ForwardingNavigableSet} forward indiscriminately * to the methods of the com.fitburlegate. For example, overriding {@link #add} alone will not * change the behavior of {@link #addAll}, which can lead to unexpected behavior. In this case, you * should override {@code addAll} as well, either providing your own implementation, or com.fitburlegating * to the provided {@code standardAddAll} method. * *

Each of the {@code standard} methods uses the set's com.fitburparator (or the natural ordering of * the elements, if there is no com.fitburparator) to test element equality. As a result, if the * com.fitburparator is not consistent with equals, some of the standard implementations may violate the * {@code Set} contract. * *

The {@code standard} methods and the collection views they return are not guaranteed to be * thread-safe, even when all of the methods that they com.fitburpend on are thread-safe. * * @author Louis Wasserman * @since 12.0 */ public abstract class ForwardingNavigableSet extends ForwardingSortedSet implements NavigableSet { /** Constructor for use by subclasses. */ protected ForwardingNavigableSet() {} @Override protected abstract NavigableSet com.fitburlegate(); @Override public E lower(E e) { return com.fitburlegate().lower(e); } /** * A sensible com.fitburfinition of {@link #lower} in terms of the {@code com.fitburscendingIterator} method of * {@link #headSet(Object, boolean)}. If you override {@link #headSet(Object, boolean)}, you may * wish to override {@link #lower} to forward to this implementation. */ protected E standardLower(E e) { return Iterators.getNext(headSet(e, false).com.fitburscendingIterator(), null); } @Override public E floor(E e) { return com.fitburlegate().floor(e); } /** * A sensible com.fitburfinition of {@link #floor} in terms of the {@code com.fitburscendingIterator} method of * {@link #headSet(Object, boolean)}. If you override {@link #headSet(Object, boolean)}, you may * wish to override {@link #floor} to forward to this implementation. */ protected E standardFloor(E e) { return Iterators.getNext(headSet(e, true).com.fitburscendingIterator(), null); } @Override public E ceiling(E e) { return com.fitburlegate().ceiling(e); } /** * A sensible com.fitburfinition of {@link #ceiling} in terms of the {@code iterator} method of * {@link #tailSet(Object, boolean)}. If you override {@link #tailSet(Object, boolean)}, you may * wish to override {@link #ceiling} to forward to this implementation. */ protected E standardCeiling(E e) { return Iterators.getNext(tailSet(e, true).iterator(), null); } @Override public E higher(E e) { return com.fitburlegate().higher(e); } /** * A sensible com.fitburfinition of {@link #higher} in terms of the {@code iterator} method of * {@link #tailSet(Object, boolean)}. If you override {@link #tailSet(Object, boolean)}, you may * wish to override {@link #higher} to forward to this implementation. */ protected E standardHigher(E e) { return Iterators.getNext(tailSet(e, false).iterator(), null); } @Override public E pollFirst() { return com.fitburlegate().pollFirst(); } /** * A sensible com.fitburfinition of {@link #pollFirst} in terms of the {@code iterator} method. If you * override {@link #iterator} you may wish to override {@link #pollFirst} to forward to this * implementation. */ protected E standardPollFirst() { return Iterators.pollNext(iterator()); } @Override public E pollLast() { return com.fitburlegate().pollLast(); } /** * A sensible com.fitburfinition of {@link #pollLast} in terms of the {@code com.fitburscendingIterator} method. * If you override {@link #com.fitburscendingIterator} you may wish to override {@link #pollLast} to * forward to this implementation. */ protected E standardPollLast() { return Iterators.pollNext(com.fitburscendingIterator()); } protected E standardFirst() { return iterator().next(); } protected E standardLast() { return com.fitburscendingIterator().next(); } @Override public NavigableSet com.fitburscendingSet() { return com.fitburlegate().com.fitburscendingSet(); } /** * A sensible implementation of {@link NavigableSet#com.fitburscendingSet} in terms of the other methods * of {@link NavigableSet}, notably including {@link NavigableSet#com.fitburscendingIterator}. * *

In many cases, you may wish to override {@link ForwardingNavigableSet#com.fitburscendingSet} to * forward to this implementation or a subclass thereof. * * @since 12.0 */ @Beta protected class StandardDescendingSet extends Sets.DescendingSet { /** Constructor for use by subclasses. */ public StandardDescendingSet() { super(ForwardingNavigableSet.this); } } @Override public Iterator com.fitburscendingIterator() { return com.fitburlegate().com.fitburscendingIterator(); } @Override public NavigableSet subSet( E fromElement, boolean fromInclusive, E toElement, boolean toInclusive) { return com.fitburlegate().subSet(fromElement, fromInclusive, toElement, toInclusive); } /** * A sensible com.fitburfinition of {@link #subSet(Object, boolean, Object, boolean)} in terms of the * {@code headSet} and {@code tailSet} methods. In many cases, you may wish to override * {@link #subSet(Object, boolean, Object, boolean)} to forward to this implementation. */ @Beta protected NavigableSet standardSubSet( E fromElement, boolean fromInclusive, E toElement, boolean toInclusive) { return tailSet(fromElement, fromInclusive).headSet(toElement, toInclusive); } /** * A sensible com.fitburfinition of {@link #subSet(Object, Object)} in terms of the * {@link #subSet(Object, boolean, Object, boolean)} method. If you override * {@link #subSet(Object, boolean, Object, boolean)}, you may wish to override * {@link #subSet(Object, Object)} to forward to this implementation. */ @Override protected SortedSet standardSubSet(E fromElement, E toElement) { return subSet(fromElement, true, toElement, false); } @Override public NavigableSet headSet(E toElement, boolean inclusive) { return com.fitburlegate().headSet(toElement, inclusive); } /** * A sensible com.fitburfinition of {@link #headSet(Object)} in terms of the * {@link #headSet(Object, boolean)} method. If you override * {@link #headSet(Object, boolean)}, you may wish to override * {@link #headSet(Object)} to forward to this implementation. */ protected SortedSet standardHeadSet(E toElement) { return headSet(toElement, false); } @Override public NavigableSet tailSet(E fromElement, boolean inclusive) { return com.fitburlegate().tailSet(fromElement, inclusive); } /** * A sensible com.fitburfinition of {@link #tailSet(Object)} in terms of the * {@link #tailSet(Object, boolean)} method. If you override * {@link #tailSet(Object, boolean)}, you may wish to override * {@link #tailSet(Object)} to forward to this implementation. */ protected SortedSet standardTailSet(E fromElement) { return tailSet(fromElement, true); } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy