Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/*
* Copyright (C) 2008 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/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.google.common.collect;
import com.google.common.annotations.GwtCompatible;
importstatic com.google.common.base.Preconditions.checkArgument;
importstatic com.google.common.base.Preconditions.checkNotNull;
import java.io.InvalidObjectException;
import java.io.ObjectInputStream;
import java.io.Serializable;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.Iterator;
import java.util.List;
import java.util.NoSuchElementException;
import java.util.Set;
import java.util.SortedSet;
import javax.annotation.Nullable;
/**
* An immutable {@code SortedSet} that stores its elements in a sorted array.
* Some instances are ordered by an explicit comparator, while others follow the
* natural sort ordering of their elements. Either way, null elements are not
* supported.
*
*
Unlike {@link Collections#unmodifiableSortedSet}, which is a view
* of a separate collection that can still change, an instance of {@code
* ImmutableSortedSet} contains its own private data and will never
* change. This class is convenient for {@code public static final} sets
* ("constant sets") and also lets you easily make a "defensive copy" of a set
* provided to your class by a caller.
*
*
The sets returned by {@link #headSet}, {@link #tailSet}, and
* {@link #subSet} methods share the same array as the original set, preventing
* that array from being garbage collected. If this is a concern, the data may
* be copied into a correctly-sized array by calling {@link #copyOfSorted}.
*
*
Note on element equivalence: The {@link #contains(Object)},
* {@link #containsAll(Collection)}, and {@link #equals(Object)}
* implementations must check whether a provided object is equivalent to an
* element in the collection. Unlike most collections, an
* {@code ImmutableSortedSet} doesn't use {@link Object#equals} to determine if
* two elements are equivalent. Instead, with an explicit comparator, the
* following relation determines whether elements {@code x} and {@code y} are
* equivalent:
*
* With natural ordering of elements, the following relation determines whether
* two elements are equivalent:
{@code
*
* {(x, y) | x.compareTo(y) == 0}}
*
* Warning: Like most sets, an {@code ImmutableSortedSet} will not
* function correctly if an element is modified after being placed in the set.
* For this reason, and to avoid general confusion, it is strongly recommended
* to place only immutable objects into this collection.
*
*
Note: Although this class is not final, it cannot be subclassed as
* it has no public or protected constructors. Thus, instances of this type are
* guaranteed to be immutable.
*
* @see ImmutableSet
* @author Jared Levy
*/@GwtCompatible@SuppressWarnings("serial") // we're overriding default serializationpublicabstractclassImmutableSortedSetextendsImmutableSetimplementsSortedSet{
// TODO: Can we find a way to remove this @SuppressWarnings even for eclipse?@SuppressWarnings("unchecked")
privatestaticfinal Comparator NATURAL_ORDER = Ordering.natural();
@SuppressWarnings("unchecked")
privatestaticfinal ImmutableSortedSet