Code cleanup and remove renderworldevent.
This commit is contained in:
parent
77ee59589f
commit
2e1287ba9d
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
File diff suppressed because it is too large
Load Diff
File diff suppressed because one or more lines are too long
204455
javascript/classes.js
204455
javascript/classes.js
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -16,15 +16,14 @@
|
||||||
|
|
||||||
package com.google.common.base;
|
package com.google.common.base;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
|
||||||
|
|
||||||
import java.io.Serializable;
|
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
|
||||||
|
|
||||||
import com.google.common.annotations.Beta;
|
import com.google.common.annotations.Beta;
|
||||||
import com.google.common.annotations.GwtCompatible;
|
import com.google.common.annotations.GwtCompatible;
|
||||||
|
|
||||||
|
import javax.annotation.Nullable;
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Utility class for converting between various ASCII case formats. Behavior is
|
* Utility class for converting between various ASCII case formats. Behavior is
|
||||||
* undefined for non-ASCII input.
|
* undefined for non-ASCII input.
|
||||||
|
@ -222,7 +221,7 @@ public enum CaseFormat {
|
||||||
|
|
||||||
private static String firstCharOnlyToUpper(String word) {
|
private static String firstCharOnlyToUpper(String word) {
|
||||||
return (word.isEmpty()) ? word
|
return (word.isEmpty()) ? word
|
||||||
: new StringBuilder(word.length()).append(Ascii.toUpperCase(word.charAt(0)))
|
: Ascii.toUpperCase(word.charAt(0)) +
|
||||||
.append(Ascii.toLowerCase(word.substring(1))).toString();
|
Ascii.toLowerCase(word.substring(1));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,18 +16,17 @@
|
||||||
|
|
||||||
package com.google.common.base;
|
package com.google.common.base;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkArgument;
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
|
||||||
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.BitSet;
|
|
||||||
|
|
||||||
import javax.annotation.CheckReturnValue;
|
|
||||||
|
|
||||||
import com.google.common.annotations.Beta;
|
import com.google.common.annotations.Beta;
|
||||||
import com.google.common.annotations.GwtCompatible;
|
import com.google.common.annotations.GwtCompatible;
|
||||||
import com.google.common.annotations.GwtIncompatible;
|
import com.google.common.annotations.GwtIncompatible;
|
||||||
|
|
||||||
|
import javax.annotation.CheckReturnValue;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.BitSet;
|
||||||
|
|
||||||
|
import static com.google.common.base.Preconditions.checkArgument;
|
||||||
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Determines a true or false value for any Java {@code char} value, just as
|
* Determines a true or false value for any Java {@code char} value, just as
|
||||||
* {@link Predicate} does for any {@link Object}. Also offers basic text
|
* {@link Predicate} does for any {@link Object}. Also offers basic text
|
||||||
|
@ -914,7 +913,7 @@ public abstract class CharMatcher implements Predicate<Character> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public final CharMatcher precomputed() {
|
public CharMatcher precomputed() {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -16,10 +16,10 @@
|
||||||
|
|
||||||
package com.google.common.base;
|
package com.google.common.base;
|
||||||
|
|
||||||
import java.nio.charset.Charset;
|
|
||||||
|
|
||||||
import com.google.common.annotations.GwtCompatible;
|
import com.google.common.annotations.GwtCompatible;
|
||||||
import com.google.common.annotations.GwtIncompatible;
|
|
||||||
|
import java.nio.charset.Charset;
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Contains constant definitions for the six standard {@link Charset} instances,
|
* Contains constant definitions for the six standard {@link Charset} instances,
|
||||||
|
@ -44,9 +44,8 @@ public final class Charsets {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* UTF-8: eight-bit UCS Transformation Format.
|
* UTF-8: eight-bit UCS Transformation Format.
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public static final Charset UTF_8 = Charset.forName("UTF-8");
|
public static final Charset UTF_8 = StandardCharsets.UTF_8;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Please do not add new Charset references to this class, unless those
|
* Please do not add new Charset references to this class, unless those
|
||||||
|
|
|
@ -57,7 +57,7 @@ public final class Objects {
|
||||||
*/
|
*/
|
||||||
@CheckReturnValue
|
@CheckReturnValue
|
||||||
public static boolean equal(@Nullable Object a, @Nullable Object b) {
|
public static boolean equal(@Nullable Object a, @Nullable Object b) {
|
||||||
return a == b || (a != null && a.equals(b));
|
return java.util.Objects.equals(a, b);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -213,7 +213,7 @@ public final class Objects {
|
||||||
*/
|
*/
|
||||||
public static final class ToStringHelper {
|
public static final class ToStringHelper {
|
||||||
private final String className;
|
private final String className;
|
||||||
private ValueHolder holderHead = new ValueHolder();
|
private final ValueHolder holderHead = new ValueHolder();
|
||||||
private ValueHolder holderTail = holderHead;
|
private ValueHolder holderTail = holderHead;
|
||||||
private boolean omitNullValues = false;
|
private boolean omitNullValues = false;
|
||||||
|
|
||||||
|
|
|
@ -100,7 +100,7 @@ public abstract class Optional<T> implements Serializable {
|
||||||
* {@link Optional#absent}.
|
* {@link Optional#absent}.
|
||||||
*/
|
*/
|
||||||
public static <T> Optional<T> fromNullable(@Nullable T nullableReference) {
|
public static <T> Optional<T> fromNullable(@Nullable T nullableReference) {
|
||||||
return (nullableReference == null) ? Optional.<T>absent() : new Present<T>(nullableReference);
|
return (nullableReference == null) ? Optional.absent() : new Present<T>(nullableReference);
|
||||||
}
|
}
|
||||||
|
|
||||||
Optional() {
|
Optional() {
|
||||||
|
|
|
@ -41,6 +41,6 @@ final class Platform {
|
||||||
|
|
||||||
static <T extends Enum<T>> Optional<T> getEnumIfPresent(Class<T> enumClass, String value) {
|
static <T extends Enum<T>> Optional<T> getEnumIfPresent(Class<T> enumClass, String value) {
|
||||||
WeakReference<? extends Enum<?>> ref = Enums.getEnumConstants(enumClass).get(value);
|
WeakReference<? extends Enum<?>> ref = Enums.getEnumConstants(enumClass).get(value);
|
||||||
return ref == null ? Optional.<T>absent() : Optional.of(enumClass.cast(ref.get()));
|
return ref == null ? Optional.absent() : Optional.of(enumClass.cast(ref.get()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -472,7 +472,7 @@ public final class Preconditions {
|
||||||
*/
|
*/
|
||||||
// Note that this is somewhat-improperly used from Verify.java as well.
|
// Note that this is somewhat-improperly used from Verify.java as well.
|
||||||
static String format(String template, @Nullable Object... args) {
|
static String format(String template, @Nullable Object... args) {
|
||||||
template = String.valueOf(template); // null -> "null"
|
template = template; // null -> "null"
|
||||||
|
|
||||||
// start substituting the arguments into the '%s' placeholders
|
// start substituting the arguments into the '%s' placeholders
|
||||||
StringBuilder builder = new StringBuilder(template.length() + 16 * args.length);
|
StringBuilder builder = new StringBuilder(template.length() + 16 * args.length);
|
||||||
|
@ -483,7 +483,7 @@ public final class Preconditions {
|
||||||
if (placeholderStart == -1) {
|
if (placeholderStart == -1) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
builder.append(template.substring(templateStart, placeholderStart));
|
builder.append(template, templateStart, placeholderStart);
|
||||||
builder.append(args[i++]);
|
builder.append(args[i++]);
|
||||||
templateStart = placeholderStart + 2;
|
templateStart = placeholderStart + 2;
|
||||||
}
|
}
|
||||||
|
|
|
@ -128,7 +128,7 @@ public final class Predicates {
|
||||||
* evaluation will be "short-circuited" as soon as a false predicate is found.
|
* evaluation will be "short-circuited" as soon as a false predicate is found.
|
||||||
*/
|
*/
|
||||||
public static <T> Predicate<T> and(Predicate<? super T> first, Predicate<? super T> second) {
|
public static <T> Predicate<T> and(Predicate<? super T> first, Predicate<? super T> second) {
|
||||||
return new AndPredicate<T>(Predicates.<T>asList(checkNotNull(first), checkNotNull(second)));
|
return new AndPredicate<T>(Predicates.asList(checkNotNull(first), checkNotNull(second)));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -164,7 +164,7 @@ public final class Predicates {
|
||||||
* found.
|
* found.
|
||||||
*/
|
*/
|
||||||
public static <T> Predicate<T> or(Predicate<? super T> first, Predicate<? super T> second) {
|
public static <T> Predicate<T> or(Predicate<? super T> first, Predicate<? super T> second) {
|
||||||
return new OrPredicate<T>(Predicates.<T>asList(checkNotNull(first), checkNotNull(second)));
|
return new OrPredicate<T>(Predicates.asList(checkNotNull(first), checkNotNull(second)));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -172,7 +172,7 @@ public final class Predicates {
|
||||||
* {@code equals()} the given target or both are null.
|
* {@code equals()} the given target or both are null.
|
||||||
*/
|
*/
|
||||||
public static <T> Predicate<T> equalTo(@Nullable T target) {
|
public static <T> Predicate<T> equalTo(@Nullable T target) {
|
||||||
return (target == null) ? Predicates.<T>isNull() : new IsEqualToPredicate<T>(target);
|
return (target == null) ? Predicates.isNull() : new IsEqualToPredicate<T>(target);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -693,7 +693,7 @@ public final class Predicates {
|
||||||
|
|
||||||
private static <T> List<Predicate<? super T>> asList(Predicate<? super T> first, Predicate<? super T> second) {
|
private static <T> List<Predicate<? super T>> asList(Predicate<? super T> first, Predicate<? super T> second) {
|
||||||
// TODO(kevinb): understand why we still get a warning despite @SafeVarargs!
|
// TODO(kevinb): understand why we still get a warning despite @SafeVarargs!
|
||||||
return Arrays.<Predicate<? super T>>asList(first, second);
|
return Arrays.asList(first, second);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static <T> List<T> defensiveCopy(T... array) {
|
private static <T> List<T> defensiveCopy(T... array) {
|
||||||
|
|
|
@ -115,7 +115,7 @@ public enum StandardSystemProperty {
|
||||||
|
|
||||||
private final String key;
|
private final String key;
|
||||||
|
|
||||||
private StandardSystemProperty(String key) {
|
StandardSystemProperty(String key) {
|
||||||
this.key = key;
|
this.key = key;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -65,7 +65,7 @@ public final class Throwables {
|
||||||
public static <X extends Throwable> void propagateIfInstanceOf(@Nullable Throwable throwable, Class<X> declaredType)
|
public static <X extends Throwable> void propagateIfInstanceOf(@Nullable Throwable throwable, Class<X> declaredType)
|
||||||
throws X {
|
throws X {
|
||||||
// Check for null is needed to avoid frequent JNI calls to isInstance().
|
// Check for null is needed to avoid frequent JNI calls to isInstance().
|
||||||
if (throwable != null && declaredType.isInstance(throwable)) {
|
if (declaredType.isInstance(throwable)) {
|
||||||
throw declaredType.cast(throwable);
|
throw declaredType.cast(throwable);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,7 +50,7 @@ abstract class AbstractRangeSet<C extends Comparable> implements RangeSet<C> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void clear() {
|
public void clear() {
|
||||||
remove(Range.<C>all());
|
remove(Range.all());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -16,20 +16,16 @@
|
||||||
|
|
||||||
package com.google.common.collect;
|
package com.google.common.collect;
|
||||||
|
|
||||||
import static com.google.common.collect.CollectPreconditions.checkNonnegative;
|
import com.google.common.annotations.GwtCompatible;
|
||||||
|
import com.google.common.annotations.GwtIncompatible;
|
||||||
|
import com.google.common.annotations.VisibleForTesting;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.ObjectInputStream;
|
import java.io.ObjectInputStream;
|
||||||
import java.io.ObjectOutputStream;
|
import java.io.ObjectOutputStream;
|
||||||
import java.util.ArrayList;
|
import java.util.*;
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import com.google.common.annotations.GwtCompatible;
|
import static com.google.common.collect.CollectPreconditions.checkNonnegative;
|
||||||
import com.google.common.annotations.GwtIncompatible;
|
|
||||||
import com.google.common.annotations.VisibleForTesting;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Implementation of {@code Multimap} that uses an {@code ArrayList} to store
|
* Implementation of {@code Multimap} that uses an {@code ArrayList} to store
|
||||||
|
@ -114,7 +110,7 @@ public final class ArrayListMultimap<K, V> extends AbstractListMultimap<K, V> {
|
||||||
}
|
}
|
||||||
|
|
||||||
private ArrayListMultimap(int expectedKeys, int expectedValuesPerKey) {
|
private ArrayListMultimap(int expectedKeys, int expectedValuesPerKey) {
|
||||||
super(Maps.<K, Collection<V>>newHashMapWithExpectedSize(expectedKeys));
|
super(Maps.newHashMapWithExpectedSize(expectedKeys));
|
||||||
checkNonnegative(expectedValuesPerKey, "expectedValuesPerKey");
|
checkNonnegative(expectedValuesPerKey, "expectedValuesPerKey");
|
||||||
this.expectedValuesPerKey = expectedValuesPerKey;
|
this.expectedValuesPerKey = expectedValuesPerKey;
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,26 +16,18 @@
|
||||||
|
|
||||||
package com.google.common.collect;
|
package com.google.common.collect;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkArgument;
|
|
||||||
import static com.google.common.base.Preconditions.checkElementIndex;
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
|
||||||
|
|
||||||
import java.io.Serializable;
|
|
||||||
import java.lang.reflect.Array;
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
|
||||||
|
|
||||||
import com.google.common.annotations.Beta;
|
import com.google.common.annotations.Beta;
|
||||||
import com.google.common.annotations.GwtCompatible;
|
import com.google.common.annotations.GwtCompatible;
|
||||||
import com.google.common.annotations.GwtIncompatible;
|
import com.google.common.annotations.GwtIncompatible;
|
||||||
import com.google.common.base.Objects;
|
import com.google.common.base.Objects;
|
||||||
|
|
||||||
|
import javax.annotation.Nullable;
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.lang.reflect.Array;
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
import static com.google.common.base.Preconditions.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fixed-size {@link Table} implementation backed by a two-dimensional array.
|
* Fixed-size {@link Table} implementation backed by a two-dimensional array.
|
||||||
*
|
*
|
||||||
|
@ -614,7 +606,7 @@ public final class ArrayTable<R, C, V> extends AbstractTable<R, C, V> implements
|
||||||
public Map<R, V> column(C columnKey) {
|
public Map<R, V> column(C columnKey) {
|
||||||
checkNotNull(columnKey);
|
checkNotNull(columnKey);
|
||||||
Integer columnIndex = columnKeyToIndex.get(columnKey);
|
Integer columnIndex = columnKeyToIndex.get(columnKey);
|
||||||
return (columnIndex == null) ? ImmutableMap.<R, V>of() : new Column(columnIndex);
|
return (columnIndex == null) ? ImmutableMap.of() : new Column(columnIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
private class Column extends ArrayMap<R, V> {
|
private class Column extends ArrayMap<R, V> {
|
||||||
|
@ -702,7 +694,7 @@ public final class ArrayTable<R, C, V> extends AbstractTable<R, C, V> implements
|
||||||
public Map<C, V> row(R rowKey) {
|
public Map<C, V> row(R rowKey) {
|
||||||
checkNotNull(rowKey);
|
checkNotNull(rowKey);
|
||||||
Integer rowIndex = rowKeyToIndex.get(rowKey);
|
Integer rowIndex = rowKeyToIndex.get(rowKey);
|
||||||
return (rowIndex == null) ? ImmutableMap.<C, V>of() : new Row(rowIndex);
|
return (rowIndex == null) ? ImmutableMap.of() : new Row(rowIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
private class Row extends ArrayMap<C, V> {
|
private class Row extends ArrayMap<C, V> {
|
||||||
|
|
|
@ -16,25 +16,6 @@
|
||||||
|
|
||||||
package com.google.common.collect;
|
package com.google.common.collect;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkArgument;
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
|
||||||
import static com.google.common.base.Predicates.and;
|
|
||||||
import static com.google.common.base.Predicates.in;
|
|
||||||
import static com.google.common.base.Predicates.not;
|
|
||||||
import static com.google.common.collect.CollectPreconditions.checkNonnegative;
|
|
||||||
import static com.google.common.math.LongMath.binomial;
|
|
||||||
|
|
||||||
import java.util.AbstractCollection;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
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 javax.annotation.Nullable;
|
|
||||||
|
|
||||||
import com.google.common.annotations.Beta;
|
import com.google.common.annotations.Beta;
|
||||||
import com.google.common.annotations.GwtCompatible;
|
import com.google.common.annotations.GwtCompatible;
|
||||||
import com.google.common.base.Function;
|
import com.google.common.base.Function;
|
||||||
|
@ -44,6 +25,15 @@ import com.google.common.base.Predicates;
|
||||||
import com.google.common.math.IntMath;
|
import com.google.common.math.IntMath;
|
||||||
import com.google.common.primitives.Ints;
|
import com.google.common.primitives.Ints;
|
||||||
|
|
||||||
|
import javax.annotation.Nullable;
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
import static com.google.common.base.Preconditions.checkArgument;
|
||||||
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
import static com.google.common.base.Predicates.*;
|
||||||
|
import static com.google.common.collect.CollectPreconditions.checkNonnegative;
|
||||||
|
import static com.google.common.math.LongMath.binomial;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides static methods for working with {@code Collection} instances.
|
* Provides static methods for working with {@code Collection} instances.
|
||||||
*
|
*
|
||||||
|
@ -298,7 +288,7 @@ public final class Collections2 {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An implementation of {@link Collection#toString()}.
|
* An implementation of {@link Collection.toString()}.
|
||||||
*/
|
*/
|
||||||
static String toStringImpl(final Collection<?> collection) {
|
static String toStringImpl(final Collection<?> collection) {
|
||||||
StringBuilder sb = newStringBuilderForCollection(collection.size()).append('[');
|
StringBuilder sb = newStringBuilderForCollection(collection.size()).append('[');
|
||||||
|
|
|
@ -16,18 +16,18 @@
|
||||||
|
|
||||||
package com.google.common.collect;
|
package com.google.common.collect;
|
||||||
|
|
||||||
|
import com.google.common.annotations.GwtCompatible;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
|
|
||||||
import com.google.common.annotations.GwtCompatible;
|
|
||||||
|
|
||||||
/** An ordering that tries several comparators in order. */
|
/** An ordering that tries several comparators in order. */
|
||||||
@GwtCompatible(serializable = true)
|
@GwtCompatible(serializable = true)
|
||||||
final class CompoundOrdering<T> extends Ordering<T> implements Serializable {
|
final class CompoundOrdering<T> extends Ordering<T> implements Serializable {
|
||||||
final ImmutableList<Comparator<? super T>> comparators;
|
final ImmutableList<Comparator<? super T>> comparators;
|
||||||
|
|
||||||
CompoundOrdering(Comparator<? super T> primary, Comparator<? super T> secondary) {
|
CompoundOrdering(Comparator<? super T> primary, Comparator<? super T> secondary) {
|
||||||
this.comparators = ImmutableList.<Comparator<? super T>>of(primary, secondary);
|
this.comparators = ImmutableList.of(primary, secondary);
|
||||||
}
|
}
|
||||||
|
|
||||||
CompoundOrdering(Iterable<? extends Comparator<? super T>> comparators) {
|
CompoundOrdering(Iterable<? extends Comparator<? super T>> comparators) {
|
||||||
|
|
|
@ -14,15 +14,14 @@
|
||||||
|
|
||||||
package com.google.common.collect;
|
package com.google.common.collect;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import com.google.common.annotations.GwtCompatible;
|
||||||
|
import com.google.common.primitives.Booleans;
|
||||||
|
|
||||||
|
import javax.annotation.Nullable;
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.NoSuchElementException;
|
import java.util.NoSuchElementException;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
import com.google.common.annotations.GwtCompatible;
|
|
||||||
import com.google.common.primitives.Booleans;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Implementation detail for the internal structure of {@link Range} instances.
|
* Implementation detail for the internal structure of {@link Range} instances.
|
||||||
|
@ -175,7 +174,7 @@ abstract class Cut<C extends Comparable> implements Comparable<Cut<C>>, Serializ
|
||||||
@Override
|
@Override
|
||||||
Cut<Comparable<?>> canonical(DiscreteDomain<Comparable<?>> domain) {
|
Cut<Comparable<?>> canonical(DiscreteDomain<Comparable<?>> domain) {
|
||||||
try {
|
try {
|
||||||
return Cut.<Comparable<?>>belowValue(domain.minValue());
|
return Cut.belowValue(domain.minValue());
|
||||||
} catch (NoSuchElementException e) {
|
} catch (NoSuchElementException e) {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
@ -313,7 +312,7 @@ abstract class Cut<C extends Comparable> implements Comparable<Cut<C>>, Serializ
|
||||||
case OPEN:
|
case OPEN:
|
||||||
@Nullable
|
@Nullable
|
||||||
C previous = domain.previous(endpoint);
|
C previous = domain.previous(endpoint);
|
||||||
return (previous == null) ? Cut.<C>belowAll() : new AboveValue<C>(previous);
|
return (previous == null) ? Cut.belowAll() : new AboveValue<C>(previous);
|
||||||
default:
|
default:
|
||||||
throw new AssertionError();
|
throw new AssertionError();
|
||||||
}
|
}
|
||||||
|
@ -325,7 +324,7 @@ abstract class Cut<C extends Comparable> implements Comparable<Cut<C>>, Serializ
|
||||||
case CLOSED:
|
case CLOSED:
|
||||||
@Nullable
|
@Nullable
|
||||||
C previous = domain.previous(endpoint);
|
C previous = domain.previous(endpoint);
|
||||||
return (previous == null) ? Cut.<C>aboveAll() : new AboveValue<C>(previous);
|
return (previous == null) ? Cut.aboveAll() : new AboveValue<C>(previous);
|
||||||
case OPEN:
|
case OPEN:
|
||||||
return this;
|
return this;
|
||||||
default:
|
default:
|
||||||
|
@ -398,7 +397,7 @@ abstract class Cut<C extends Comparable> implements Comparable<Cut<C>>, Serializ
|
||||||
case CLOSED:
|
case CLOSED:
|
||||||
@Nullable
|
@Nullable
|
||||||
C next = domain.next(endpoint);
|
C next = domain.next(endpoint);
|
||||||
return (next == null) ? Cut.<C>belowAll() : belowValue(next);
|
return (next == null) ? Cut.belowAll() : belowValue(next);
|
||||||
default:
|
default:
|
||||||
throw new AssertionError();
|
throw new AssertionError();
|
||||||
}
|
}
|
||||||
|
@ -410,7 +409,7 @@ abstract class Cut<C extends Comparable> implements Comparable<Cut<C>>, Serializ
|
||||||
case OPEN:
|
case OPEN:
|
||||||
@Nullable
|
@Nullable
|
||||||
C next = domain.next(endpoint);
|
C next = domain.next(endpoint);
|
||||||
return (next == null) ? Cut.<C>aboveAll() : belowValue(next);
|
return (next == null) ? Cut.aboveAll() : belowValue(next);
|
||||||
case CLOSED:
|
case CLOSED:
|
||||||
return this;
|
return this;
|
||||||
default:
|
default:
|
||||||
|
@ -441,7 +440,7 @@ abstract class Cut<C extends Comparable> implements Comparable<Cut<C>>, Serializ
|
||||||
@Override
|
@Override
|
||||||
Cut<C> canonical(DiscreteDomain<C> domain) {
|
Cut<C> canonical(DiscreteDomain<C> domain) {
|
||||||
C next = leastValueAbove(domain);
|
C next = leastValueAbove(domain);
|
||||||
return (next != null) ? belowValue(next) : Cut.<C>aboveAll();
|
return (next != null) ? belowValue(next) : Cut.aboveAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -16,13 +16,13 @@
|
||||||
|
|
||||||
package com.google.common.collect;
|
package com.google.common.collect;
|
||||||
|
|
||||||
|
import com.google.common.annotations.GwtCompatible;
|
||||||
|
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.NavigableSet;
|
import java.util.NavigableSet;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import com.google.common.annotations.GwtCompatible;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A skeleton implementation of a descending multiset. Only needs
|
* A skeleton implementation of a descending multiset. Only needs
|
||||||
* {@code forwardMultiset()} and {@code entryIterator()}.
|
* {@code forwardMultiset()} and {@code entryIterator()}.
|
||||||
|
@ -39,7 +39,7 @@ abstract class DescendingMultiset<E> extends ForwardingMultiset<E> implements So
|
||||||
public Comparator<? super E> comparator() {
|
public Comparator<? super E> comparator() {
|
||||||
Comparator<? super E> result = comparator;
|
Comparator<? super E> result = comparator;
|
||||||
if (result == null) {
|
if (result == null) {
|
||||||
return comparator = Ordering.from(forwardMultiset().comparator()).<E>reverse();
|
return comparator = Ordering.from(forwardMultiset().comparator()).reverse();
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,7 +28,7 @@ class EmptyImmutableListMultimap extends ImmutableListMultimap<Object, Object> {
|
||||||
static final EmptyImmutableListMultimap INSTANCE = new EmptyImmutableListMultimap();
|
static final EmptyImmutableListMultimap INSTANCE = new EmptyImmutableListMultimap();
|
||||||
|
|
||||||
private EmptyImmutableListMultimap() {
|
private EmptyImmutableListMultimap() {
|
||||||
super(ImmutableMap.<Object, ImmutableList<Object>>of(), 0);
|
super(ImmutableMap.of(), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
private Object readResolve() {
|
private Object readResolve() {
|
||||||
|
|
|
@ -16,12 +16,11 @@
|
||||||
|
|
||||||
package com.google.common.collect;
|
package com.google.common.collect;
|
||||||
|
|
||||||
import java.util.Collection;
|
import com.google.common.annotations.GwtCompatible;
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
import java.util.Collection;
|
||||||
import com.google.common.annotations.GwtCompatible;
|
import java.util.Set;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An empty immutable set.
|
* An empty immutable set.
|
||||||
|
@ -85,7 +84,7 @@ final class EmptyImmutableSet extends ImmutableSet<Object> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public final int hashCode() {
|
public int hashCode() {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -28,7 +28,7 @@ class EmptyImmutableSetMultimap extends ImmutableSetMultimap<Object, Object> {
|
||||||
static final EmptyImmutableSetMultimap INSTANCE = new EmptyImmutableSetMultimap();
|
static final EmptyImmutableSetMultimap INSTANCE = new EmptyImmutableSetMultimap();
|
||||||
|
|
||||||
private EmptyImmutableSetMultimap() {
|
private EmptyImmutableSetMultimap() {
|
||||||
super(ImmutableMap.<Object, ImmutableSet<Object>>of(), 0, null);
|
super(ImmutableMap.of(), 0, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
private Object readResolve() {
|
private Object readResolve() {
|
||||||
|
|
|
@ -76,7 +76,7 @@ public final class EnumHashBiMap<K extends Enum<K>, V> extends AbstractBiMap<K,
|
||||||
|
|
||||||
private EnumHashBiMap(Class<K> keyType) {
|
private EnumHashBiMap(Class<K> keyType) {
|
||||||
super(WellBehavedMap.wrap(new EnumMap<K, V>(keyType)),
|
super(WellBehavedMap.wrap(new EnumMap<K, V>(keyType)),
|
||||||
Maps.<V, K>newHashMapWithExpectedSize(keyType.getEnumConstants().length));
|
Maps.newHashMapWithExpectedSize(keyType.getEnumConstants().length));
|
||||||
this.keyType = keyType;
|
this.keyType = keyType;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -104,7 +104,7 @@ class FilteredEntryMultimap<K, V> extends AbstractMultimap<K, V> implements Filt
|
||||||
|
|
||||||
Collection<V> unmodifiableEmptyCollection() {
|
Collection<V> unmodifiableEmptyCollection() {
|
||||||
// These return false, rather than throwing a UOE, on remove calls.
|
// These return false, rather than throwing a UOE, on remove calls.
|
||||||
return (unfiltered instanceof SetMultimap) ? Collections.<V>emptySet() : Collections.<V>emptyList();
|
return (unfiltered instanceof SetMultimap) ? Collections.emptySet() : Collections.emptyList();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -215,12 +215,12 @@ class FilteredEntryMultimap<K, V> extends AbstractMultimap<K, V> implements Filt
|
||||||
return new Maps.KeySet<K, Collection<V>>(this) {
|
return new Maps.KeySet<K, Collection<V>>(this) {
|
||||||
@Override
|
@Override
|
||||||
public boolean removeAll(Collection<?> c) {
|
public boolean removeAll(Collection<?> c) {
|
||||||
return removeEntriesIf(Maps.<K>keyPredicateOnEntries(in(c)));
|
return removeEntriesIf(Maps.keyPredicateOnEntries(in(c)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean retainAll(Collection<?> c) {
|
public boolean retainAll(Collection<?> c) {
|
||||||
return removeEntriesIf(Maps.<K>keyPredicateOnEntries(not(in(c))));
|
return removeEntriesIf(Maps.keyPredicateOnEntries(not(in(c))));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -303,12 +303,12 @@ class FilteredEntryMultimap<K, V> extends AbstractMultimap<K, V> implements Filt
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean removeAll(Collection<?> c) {
|
public boolean removeAll(Collection<?> c) {
|
||||||
return removeEntriesIf(Maps.<Collection<V>>valuePredicateOnEntries(in(c)));
|
return removeEntriesIf(Maps.valuePredicateOnEntries(in(c)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean retainAll(Collection<?> c) {
|
public boolean retainAll(Collection<?> c) {
|
||||||
return removeEntriesIf(Maps.<Collection<V>>valuePredicateOnEntries(not(in(c))));
|
return removeEntriesIf(Maps.valuePredicateOnEntries(not(in(c))));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -75,16 +75,16 @@ final class FilteredMultimapValues<K, V> extends AbstractCollection<V> {
|
||||||
public boolean removeAll(Collection<?> c) {
|
public boolean removeAll(Collection<?> c) {
|
||||||
return Iterables.removeIf(multimap.unfiltered().entries(),
|
return Iterables.removeIf(multimap.unfiltered().entries(),
|
||||||
// explicit <Entry<K, V>> is required to build with JDK6
|
// explicit <Entry<K, V>> is required to build with JDK6
|
||||||
Predicates.<Entry<K, V>>and(multimap.entryPredicate(),
|
Predicates.and(multimap.entryPredicate(),
|
||||||
Maps.<V>valuePredicateOnEntries(Predicates.in(c))));
|
Maps.valuePredicateOnEntries(Predicates.in(c))));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean retainAll(Collection<?> c) {
|
public boolean retainAll(Collection<?> c) {
|
||||||
return Iterables.removeIf(multimap.unfiltered().entries(),
|
return Iterables.removeIf(multimap.unfiltered().entries(),
|
||||||
// explicit <Entry<K, V>> is required to build with JDK6
|
// explicit <Entry<K, V>> is required to build with JDK6
|
||||||
Predicates.<Entry<K, V>>and(multimap.entryPredicate(),
|
Predicates.and(multimap.entryPredicate(),
|
||||||
Maps.<V>valuePredicateOnEntries(Predicates.not(Predicates.in(c)))));
|
Maps.valuePredicateOnEntries(Predicates.not(Predicates.in(c)))));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -252,7 +252,7 @@ public abstract class FluentIterable<E> implements Iterable<E> {
|
||||||
*/
|
*/
|
||||||
public final Optional<E> first() {
|
public final Optional<E> first() {
|
||||||
Iterator<E> iterator = iterable.iterator();
|
Iterator<E> iterator = iterable.iterator();
|
||||||
return iterator.hasNext() ? Optional.of(iterator.next()) : Optional.<E>absent();
|
return iterator.hasNext() ? Optional.of(iterator.next()) : Optional.absent();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -251,10 +251,9 @@ final class GeneralRange<T> implements Serializable {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return new StringBuilder().append(comparator).append(":").append(lowerBoundType == CLOSED ? '[' : '(')
|
return comparator + ":" + (lowerBoundType == CLOSED ? '[' : '(') +
|
||||||
.append(hasLowerBound ? lowerEndpoint : "-\u221e").append(',')
|
(hasLowerBound ? lowerEndpoint : "-\u221e") + ',' +
|
||||||
.append(hasUpperBound ? upperEndpoint : "\u221e").append(upperBoundType == CLOSED ? ']' : ')')
|
(hasUpperBound ? upperEndpoint : "\u221e") + (upperBoundType == CLOSED ? ']' : ')');
|
||||||
.toString();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
T getLowerEndpoint() {
|
T getLowerEndpoint() {
|
||||||
|
|
|
@ -590,7 +590,7 @@ public final class HashBiMap<K, V> extends AbstractMap<K, V> implements BiMap<K,
|
||||||
}
|
}
|
||||||
|
|
||||||
class InverseEntry extends AbstractMapEntry<V, K> {
|
class InverseEntry extends AbstractMapEntry<V, K> {
|
||||||
BiEntry<K, V> delegate;
|
final BiEntry<K, V> delegate;
|
||||||
|
|
||||||
InverseEntry(BiEntry<K, V> entry) {
|
InverseEntry(BiEntry<K, V> entry) {
|
||||||
this.delegate = entry;
|
this.delegate = entry;
|
||||||
|
|
|
@ -93,13 +93,13 @@ public final class HashMultimap<K, V> extends AbstractSetMultimap<K, V> {
|
||||||
}
|
}
|
||||||
|
|
||||||
private HashMultimap(int expectedKeys, int expectedValuesPerKey) {
|
private HashMultimap(int expectedKeys, int expectedValuesPerKey) {
|
||||||
super(Maps.<K, Collection<V>>newHashMapWithExpectedSize(expectedKeys));
|
super(Maps.newHashMapWithExpectedSize(expectedKeys));
|
||||||
Preconditions.checkArgument(expectedValuesPerKey >= 0);
|
Preconditions.checkArgument(expectedValuesPerKey >= 0);
|
||||||
this.expectedValuesPerKey = expectedValuesPerKey;
|
this.expectedValuesPerKey = expectedValuesPerKey;
|
||||||
}
|
}
|
||||||
|
|
||||||
private HashMultimap(Multimap<? extends K, ? extends V> multimap) {
|
private HashMultimap(Multimap<? extends K, ? extends V> multimap) {
|
||||||
super(Maps.<K, Collection<V>>newHashMapWithExpectedSize(multimap.keySet().size()));
|
super(Maps.newHashMapWithExpectedSize(multimap.keySet().size()));
|
||||||
putAll(multimap);
|
putAll(multimap);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -113,7 +113,7 @@ public final class HashMultimap<K, V> extends AbstractSetMultimap<K, V> {
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
Set<V> createCollection() {
|
Set<V> createCollection() {
|
||||||
return Sets.<V>newHashSetWithExpectedSize(expectedValuesPerKey);
|
return Sets.newHashSetWithExpectedSize(expectedValuesPerKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -72,7 +72,7 @@ public final class HashMultiset<E> extends AbstractMapBasedMultiset<E> {
|
||||||
}
|
}
|
||||||
|
|
||||||
private HashMultiset(int distinctElements) {
|
private HashMultiset(int distinctElements) {
|
||||||
super(Maps.<E, Count>newHashMapWithExpectedSize(distinctElements));
|
super(Maps.newHashMapWithExpectedSize(distinctElements));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -89,7 +89,7 @@ public final class HashMultiset<E> extends AbstractMapBasedMultiset<E> {
|
||||||
private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException {
|
private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException {
|
||||||
stream.defaultReadObject();
|
stream.defaultReadObject();
|
||||||
int distinctElements = Serialization.readCount(stream);
|
int distinctElements = Serialization.readCount(stream);
|
||||||
setBackingMap(Maps.<E, Count>newHashMapWithExpectedSize(distinctElements));
|
setBackingMap(Maps.newHashMapWithExpectedSize(distinctElements));
|
||||||
Serialization.populateMultiset(this, stream, distinctElements);
|
Serialization.populateMultiset(this, stream, distinctElements);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -53,7 +53,7 @@ final class Hashing {
|
||||||
return smear((o == null) ? 0 : o.hashCode());
|
return smear((o == null) ? 0 : o.hashCode());
|
||||||
}
|
}
|
||||||
|
|
||||||
private static int MAX_TABLE_SIZE = Ints.MAX_POWER_OF_TWO;
|
private static final int MAX_TABLE_SIZE = Ints.MAX_POWER_OF_TWO;
|
||||||
|
|
||||||
static int closedTableSize(int expectedEntries, double loadFactor) {
|
static int closedTableSize(int expectedEntries, double loadFactor) {
|
||||||
// Get the recommended table size.
|
// Get the recommended table size.
|
||||||
|
|
|
@ -247,7 +247,7 @@ public abstract class ImmutableList<E> extends ImmutableCollection<E> implements
|
||||||
if (elements instanceof ImmutableCollection) {
|
if (elements instanceof ImmutableCollection) {
|
||||||
@SuppressWarnings("unchecked") // all supported methods are covariant
|
@SuppressWarnings("unchecked") // all supported methods are covariant
|
||||||
ImmutableList<E> list = ((ImmutableCollection<E>) elements).asList();
|
ImmutableList<E> list = ((ImmutableCollection<E>) elements).asList();
|
||||||
return list.isPartialView() ? ImmutableList.<E>asImmutableList(list.toArray()) : list;
|
return list.isPartialView() ? ImmutableList.asImmutableList(list.toArray()) : list;
|
||||||
}
|
}
|
||||||
return construct(elements.toArray());
|
return construct(elements.toArray());
|
||||||
}
|
}
|
||||||
|
|
|
@ -279,7 +279,7 @@ public class ImmutableListMultimap<K, V> extends ImmutableMultimap<K, V> impleme
|
||||||
public ImmutableList<V> get(@Nullable K key) {
|
public ImmutableList<V> get(@Nullable K key) {
|
||||||
// This cast is safe as its type is known in constructor.
|
// This cast is safe as its type is known in constructor.
|
||||||
ImmutableList<V> list = (ImmutableList<V>) map.get(key);
|
ImmutableList<V> list = (ImmutableList<V>) map.get(key);
|
||||||
return (list == null) ? ImmutableList.<V>of() : list;
|
return (list == null) ? ImmutableList.of() : list;
|
||||||
}
|
}
|
||||||
|
|
||||||
private transient ImmutableListMultimap<V, K> inverse;
|
private transient ImmutableListMultimap<V, K> inverse;
|
||||||
|
|
|
@ -263,7 +263,7 @@ public abstract class ImmutableMultimap<K, V> extends AbstractMultimap<K, V> imp
|
||||||
if (keyComparator != null) {
|
if (keyComparator != null) {
|
||||||
Multimap<K, V> sortedCopy = new BuilderMultimap<K, V>();
|
Multimap<K, V> sortedCopy = new BuilderMultimap<K, V>();
|
||||||
List<Map.Entry<K, Collection<V>>> entries = Lists.newArrayList(builderMultimap.asMap().entrySet());
|
List<Map.Entry<K, Collection<V>>> entries = Lists.newArrayList(builderMultimap.asMap().entrySet());
|
||||||
Collections.sort(entries, Ordering.from(keyComparator).<K>onKeys());
|
Collections.sort(entries, Ordering.from(keyComparator).onKeys());
|
||||||
for (Map.Entry<K, Collection<V>> entry : entries) {
|
for (Map.Entry<K, Collection<V>> entry : entries) {
|
||||||
sortedCopy.putAll(entry.getKey(), entry.getValue());
|
sortedCopy.putAll(entry.getKey(), entry.getValue());
|
||||||
}
|
}
|
||||||
|
|
|
@ -53,7 +53,7 @@ import com.google.common.primitives.Ints;
|
||||||
public abstract class ImmutableMultiset<E> extends ImmutableCollection<E> implements Multiset<E> {
|
public abstract class ImmutableMultiset<E> extends ImmutableCollection<E> implements Multiset<E> {
|
||||||
|
|
||||||
private static final ImmutableMultiset<Object> EMPTY = new RegularImmutableMultiset<Object>(
|
private static final ImmutableMultiset<Object> EMPTY = new RegularImmutableMultiset<Object>(
|
||||||
ImmutableMap.<Object, Integer>of(), 0);
|
ImmutableMap.of(), 0);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the empty immutable multiset.
|
* Returns the empty immutable multiset.
|
||||||
|
@ -342,7 +342,7 @@ public abstract class ImmutableMultiset<E> extends ImmutableCollection<E> implem
|
||||||
}
|
}
|
||||||
|
|
||||||
private final ImmutableSet<Entry<E>> createEntrySet() {
|
private final ImmutableSet<Entry<E>> createEntrySet() {
|
||||||
return isEmpty() ? ImmutableSet.<Entry<E>>of() : new EntrySet();
|
return isEmpty() ? ImmutableSet.of() : new EntrySet();
|
||||||
}
|
}
|
||||||
|
|
||||||
abstract Entry<E> getEntry(int index);
|
abstract Entry<E> getEntry(int index);
|
||||||
|
@ -487,7 +487,7 @@ public abstract class ImmutableMultiset<E> extends ImmutableCollection<E> implem
|
||||||
* generated by {@link ImmutableMultiset#builder}.
|
* generated by {@link ImmutableMultiset#builder}.
|
||||||
*/
|
*/
|
||||||
public Builder() {
|
public Builder() {
|
||||||
this(LinkedHashMultiset.<E>create());
|
this(LinkedHashMultiset.create());
|
||||||
}
|
}
|
||||||
|
|
||||||
Builder(Multiset<E> contents) {
|
Builder(Multiset<E> contents) {
|
||||||
|
|
|
@ -45,7 +45,7 @@ import com.google.common.collect.SortedLists.KeyPresentBehavior;
|
||||||
public class ImmutableRangeMap<K extends Comparable<?>, V> implements RangeMap<K, V> {
|
public class ImmutableRangeMap<K extends Comparable<?>, V> implements RangeMap<K, V> {
|
||||||
|
|
||||||
private static final ImmutableRangeMap<Comparable<?>, Object> EMPTY = new ImmutableRangeMap<Comparable<?>, Object>(
|
private static final ImmutableRangeMap<Comparable<?>, Object> EMPTY = new ImmutableRangeMap<Comparable<?>, Object>(
|
||||||
ImmutableList.<Range<Comparable<?>>>of(), ImmutableList.of());
|
ImmutableList.of(), ImmutableList.of());
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns an empty immutable range map.
|
* Returns an empty immutable range map.
|
||||||
|
@ -162,7 +162,7 @@ public class ImmutableRangeMap<K extends Comparable<?>, V> implements RangeMap<K
|
||||||
@Override
|
@Override
|
||||||
@Nullable
|
@Nullable
|
||||||
public V get(K key) {
|
public V get(K key) {
|
||||||
int index = SortedLists.binarySearch(ranges, Range.<K>lowerBoundFn(), Cut.belowValue(key),
|
int index = SortedLists.binarySearch(ranges, Range.lowerBoundFn(), Cut.belowValue(key),
|
||||||
KeyPresentBehavior.ANY_PRESENT, KeyAbsentBehavior.NEXT_LOWER);
|
KeyPresentBehavior.ANY_PRESENT, KeyAbsentBehavior.NEXT_LOWER);
|
||||||
if (index == -1) {
|
if (index == -1) {
|
||||||
return null;
|
return null;
|
||||||
|
@ -175,7 +175,7 @@ public class ImmutableRangeMap<K extends Comparable<?>, V> implements RangeMap<K
|
||||||
@Override
|
@Override
|
||||||
@Nullable
|
@Nullable
|
||||||
public Map.Entry<Range<K>, V> getEntry(K key) {
|
public Map.Entry<Range<K>, V> getEntry(K key) {
|
||||||
int index = SortedLists.binarySearch(ranges, Range.<K>lowerBoundFn(), Cut.belowValue(key),
|
int index = SortedLists.binarySearch(ranges, Range.lowerBoundFn(), Cut.belowValue(key),
|
||||||
KeyPresentBehavior.ANY_PRESENT, KeyAbsentBehavior.NEXT_LOWER);
|
KeyPresentBehavior.ANY_PRESENT, KeyAbsentBehavior.NEXT_LOWER);
|
||||||
if (index == -1) {
|
if (index == -1) {
|
||||||
return null;
|
return null;
|
||||||
|
@ -232,9 +232,9 @@ public class ImmutableRangeMap<K extends Comparable<?>, V> implements RangeMap<K
|
||||||
} else if (ranges.isEmpty() || range.encloses(span())) {
|
} else if (ranges.isEmpty() || range.encloses(span())) {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
int lowerIndex = SortedLists.binarySearch(ranges, Range.<K>upperBoundFn(), range.lowerBound,
|
int lowerIndex = SortedLists.binarySearch(ranges, Range.upperBoundFn(), range.lowerBound,
|
||||||
KeyPresentBehavior.FIRST_AFTER, KeyAbsentBehavior.NEXT_HIGHER);
|
KeyPresentBehavior.FIRST_AFTER, KeyAbsentBehavior.NEXT_HIGHER);
|
||||||
int upperIndex = SortedLists.binarySearch(ranges, Range.<K>lowerBoundFn(), range.upperBound,
|
int upperIndex = SortedLists.binarySearch(ranges, Range.lowerBoundFn(), range.upperBound,
|
||||||
KeyPresentBehavior.ANY_PRESENT, KeyAbsentBehavior.NEXT_HIGHER);
|
KeyPresentBehavior.ANY_PRESENT, KeyAbsentBehavior.NEXT_HIGHER);
|
||||||
if (lowerIndex >= upperIndex) {
|
if (lowerIndex >= upperIndex) {
|
||||||
return ImmutableRangeMap.of();
|
return ImmutableRangeMap.of();
|
||||||
|
|
|
@ -43,10 +43,10 @@ import com.google.common.primitives.Ints;
|
||||||
public final class ImmutableRangeSet<C extends Comparable> extends AbstractRangeSet<C> implements Serializable {
|
public final class ImmutableRangeSet<C extends Comparable> extends AbstractRangeSet<C> implements Serializable {
|
||||||
|
|
||||||
private static final ImmutableRangeSet<Comparable<?>> EMPTY = new ImmutableRangeSet<Comparable<?>>(
|
private static final ImmutableRangeSet<Comparable<?>> EMPTY = new ImmutableRangeSet<Comparable<?>>(
|
||||||
ImmutableList.<Range<Comparable<?>>>of());
|
ImmutableList.of());
|
||||||
|
|
||||||
private static final ImmutableRangeSet<Comparable<?>> ALL = new ImmutableRangeSet<Comparable<?>>(
|
private static final ImmutableRangeSet<Comparable<?>> ALL = new ImmutableRangeSet<Comparable<?>>(
|
||||||
ImmutableList.of(Range.<Comparable<?>>all()));
|
ImmutableList.of(Range.all()));
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns an empty immutable range set.
|
* Returns an empty immutable range set.
|
||||||
|
@ -88,7 +88,7 @@ public final class ImmutableRangeSet<C extends Comparable> extends AbstractRange
|
||||||
checkNotNull(rangeSet);
|
checkNotNull(rangeSet);
|
||||||
if (rangeSet.isEmpty()) {
|
if (rangeSet.isEmpty()) {
|
||||||
return of();
|
return of();
|
||||||
} else if (rangeSet.encloses(Range.<C>all())) {
|
} else if (rangeSet.encloses(Range.all())) {
|
||||||
return all();
|
return all();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -114,14 +114,14 @@ public final class ImmutableRangeSet<C extends Comparable> extends AbstractRange
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean encloses(Range<C> otherRange) {
|
public boolean encloses(Range<C> otherRange) {
|
||||||
int index = SortedLists.binarySearch(ranges, Range.<C>lowerBoundFn(), otherRange.lowerBound, Ordering.natural(),
|
int index = SortedLists.binarySearch(ranges, Range.lowerBoundFn(), otherRange.lowerBound, Ordering.natural(),
|
||||||
ANY_PRESENT, NEXT_LOWER);
|
ANY_PRESENT, NEXT_LOWER);
|
||||||
return index != -1 && ranges.get(index).encloses(otherRange);
|
return index != -1 && ranges.get(index).encloses(otherRange);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Range<C> rangeContaining(C value) {
|
public Range<C> rangeContaining(C value) {
|
||||||
int index = SortedLists.binarySearch(ranges, Range.<C>lowerBoundFn(), Cut.belowValue(value), Ordering.natural(),
|
int index = SortedLists.binarySearch(ranges, Range.lowerBoundFn(), Cut.belowValue(value), Ordering.natural(),
|
||||||
ANY_PRESENT, NEXT_LOWER);
|
ANY_PRESENT, NEXT_LOWER);
|
||||||
if (index != -1) {
|
if (index != -1) {
|
||||||
Range<C> range = ranges.get(index);
|
Range<C> range = ranges.get(index);
|
||||||
|
@ -207,14 +207,14 @@ public final class ImmutableRangeSet<C extends Comparable> extends AbstractRange
|
||||||
|
|
||||||
Cut<C> lowerBound;
|
Cut<C> lowerBound;
|
||||||
if (positiveBoundedBelow) {
|
if (positiveBoundedBelow) {
|
||||||
lowerBound = (index == 0) ? Cut.<C>belowAll() : ranges.get(index - 1).upperBound;
|
lowerBound = (index == 0) ? Cut.belowAll() : ranges.get(index - 1).upperBound;
|
||||||
} else {
|
} else {
|
||||||
lowerBound = ranges.get(index).upperBound;
|
lowerBound = ranges.get(index).upperBound;
|
||||||
}
|
}
|
||||||
|
|
||||||
Cut<C> upperBound;
|
Cut<C> upperBound;
|
||||||
if (positiveBoundedAbove && index == size - 1) {
|
if (positiveBoundedAbove && index == size - 1) {
|
||||||
upperBound = Cut.<C>aboveAll();
|
upperBound = Cut.aboveAll();
|
||||||
} else {
|
} else {
|
||||||
upperBound = ranges.get(index + (positiveBoundedBelow ? 0 : 1)).lowerBound;
|
upperBound = ranges.get(index + (positiveBoundedBelow ? 0 : 1)).lowerBound;
|
||||||
}
|
}
|
||||||
|
@ -257,7 +257,7 @@ public final class ImmutableRangeSet<C extends Comparable> extends AbstractRange
|
||||||
|
|
||||||
final int fromIndex;
|
final int fromIndex;
|
||||||
if (range.hasLowerBound()) {
|
if (range.hasLowerBound()) {
|
||||||
fromIndex = SortedLists.binarySearch(ranges, Range.<C>upperBoundFn(), range.lowerBound,
|
fromIndex = SortedLists.binarySearch(ranges, Range.upperBoundFn(), range.lowerBound,
|
||||||
KeyPresentBehavior.FIRST_AFTER, KeyAbsentBehavior.NEXT_HIGHER);
|
KeyPresentBehavior.FIRST_AFTER, KeyAbsentBehavior.NEXT_HIGHER);
|
||||||
} else {
|
} else {
|
||||||
fromIndex = 0;
|
fromIndex = 0;
|
||||||
|
@ -265,7 +265,7 @@ public final class ImmutableRangeSet<C extends Comparable> extends AbstractRange
|
||||||
|
|
||||||
int toIndex;
|
int toIndex;
|
||||||
if (range.hasUpperBound()) {
|
if (range.hasUpperBound()) {
|
||||||
toIndex = SortedLists.binarySearch(ranges, Range.<C>lowerBoundFn(), range.upperBound,
|
toIndex = SortedLists.binarySearch(ranges, Range.lowerBoundFn(), range.upperBound,
|
||||||
KeyPresentBehavior.FIRST_PRESENT, KeyAbsentBehavior.NEXT_HIGHER);
|
KeyPresentBehavior.FIRST_PRESENT, KeyAbsentBehavior.NEXT_HIGHER);
|
||||||
} else {
|
} else {
|
||||||
toIndex = ranges.size();
|
toIndex = ranges.size();
|
||||||
|
|
|
@ -271,7 +271,7 @@ public class ImmutableSetMultimap<K, V> extends ImmutableMultimap<K, V> implemen
|
||||||
if (keyComparator != null) {
|
if (keyComparator != null) {
|
||||||
Multimap<K, V> sortedCopy = new BuilderMultimap<K, V>();
|
Multimap<K, V> sortedCopy = new BuilderMultimap<K, V>();
|
||||||
List<Map.Entry<K, Collection<V>>> entries = Lists.newArrayList(builderMultimap.asMap().entrySet());
|
List<Map.Entry<K, Collection<V>>> entries = Lists.newArrayList(builderMultimap.asMap().entrySet());
|
||||||
Collections.sort(entries, Ordering.from(keyComparator).<K>onKeys());
|
Collections.sort(entries, Ordering.from(keyComparator).onKeys());
|
||||||
for (Map.Entry<K, Collection<V>> entry : entries) {
|
for (Map.Entry<K, Collection<V>> entry : entries) {
|
||||||
sortedCopy.putAll(entry.getKey(), entry.getValue());
|
sortedCopy.putAll(entry.getKey(), entry.getValue());
|
||||||
}
|
}
|
||||||
|
@ -459,7 +459,7 @@ public class ImmutableSetMultimap<K, V> extends ImmutableMultimap<K, V> implemen
|
||||||
}
|
}
|
||||||
|
|
||||||
private static <V> ImmutableSet<V> emptySet(@Nullable Comparator<? super V> valueComparator) {
|
private static <V> ImmutableSet<V> emptySet(@Nullable Comparator<? super V> valueComparator) {
|
||||||
return (valueComparator == null) ? ImmutableSet.<V>of() : ImmutableSortedSet.<V>emptySet(valueComparator);
|
return (valueComparator == null) ? ImmutableSet.of() : ImmutableSortedSet.emptySet(valueComparator);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -196,7 +196,7 @@ public abstract class ImmutableSortedMap<K, V> extends ImmutableSortedMapFauxver
|
||||||
// Hack around K not being a subtype of Comparable.
|
// Hack around K not being a subtype of Comparable.
|
||||||
// Unsafe, see ImmutableSortedSetFauxverideShim.
|
// Unsafe, see ImmutableSortedSetFauxverideShim.
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
Ordering<K> naturalOrder = (Ordering<K>) Ordering.<Comparable>natural();
|
Ordering<K> naturalOrder = (Ordering<K>) Ordering.natural();
|
||||||
return copyOfInternal(map, naturalOrder);
|
return copyOfInternal(map, naturalOrder);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -283,7 +283,7 @@ public abstract class ImmutableSortedMap<K, V> extends ImmutableSortedMapFauxver
|
||||||
}
|
}
|
||||||
|
|
||||||
private static <K, V> void sortEntries(final Comparator<? super K> comparator, int size, Entry<K, V>[] entries) {
|
private static <K, V> void sortEntries(final Comparator<? super K> comparator, int size, Entry<K, V>[] entries) {
|
||||||
Arrays.sort(entries, 0, size, Ordering.from(comparator).<K>onKeys());
|
Arrays.sort(entries, 0, size, Ordering.from(comparator).onKeys());
|
||||||
}
|
}
|
||||||
|
|
||||||
private static <K, V> void validateEntries(int size, Entry<K, V>[] entries, Comparator<? super K> comparator) {
|
private static <K, V> void validateEntries(int size, Entry<K, V>[] entries, Comparator<? super K> comparator) {
|
||||||
|
|
|
@ -221,7 +221,7 @@ public abstract class ImmutableSortedMultiset<E> extends ImmutableSortedMultiset
|
||||||
// Hack around E not being a subtype of Comparable.
|
// Hack around E not being a subtype of Comparable.
|
||||||
// Unsafe, see ImmutableSortedMultisetFauxverideShim.
|
// Unsafe, see ImmutableSortedMultisetFauxverideShim.
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
Ordering<E> naturalOrder = (Ordering<E>) Ordering.<Comparable>natural();
|
Ordering<E> naturalOrder = (Ordering<E>) Ordering.natural();
|
||||||
return copyOf(naturalOrder, elements);
|
return copyOf(naturalOrder, elements);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -240,7 +240,7 @@ public abstract class ImmutableSortedMultiset<E> extends ImmutableSortedMultiset
|
||||||
// Hack around E not being a subtype of Comparable.
|
// Hack around E not being a subtype of Comparable.
|
||||||
// Unsafe, see ImmutableSortedMultisetFauxverideShim.
|
// Unsafe, see ImmutableSortedMultisetFauxverideShim.
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
Ordering<E> naturalOrder = (Ordering<E>) Ordering.<Comparable>natural();
|
Ordering<E> naturalOrder = (Ordering<E>) Ordering.natural();
|
||||||
return copyOf(naturalOrder, elements);
|
return copyOf(naturalOrder, elements);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -480,7 +480,7 @@ public abstract class ImmutableSortedMultiset<E> extends ImmutableSortedMultiset
|
||||||
* generated by {@link ImmutableSortedMultiset#orderedBy(Comparator)}.
|
* generated by {@link ImmutableSortedMultiset#orderedBy(Comparator)}.
|
||||||
*/
|
*/
|
||||||
public Builder(Comparator<? super E> comparator) {
|
public Builder(Comparator<? super E> comparator) {
|
||||||
super(TreeMultiset.<E>create(checkNotNull(comparator)));
|
super(TreeMultiset.create(checkNotNull(comparator)));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -257,7 +257,7 @@ public abstract class ImmutableSortedSet<E> extends ImmutableSortedSetFauxveride
|
||||||
// Hack around E not being a subtype of Comparable.
|
// Hack around E not being a subtype of Comparable.
|
||||||
// Unsafe, see ImmutableSortedSetFauxverideShim.
|
// Unsafe, see ImmutableSortedSetFauxverideShim.
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
Ordering<E> naturalOrder = (Ordering<E>) Ordering.<Comparable>natural();
|
Ordering<E> naturalOrder = (Ordering<E>) Ordering.natural();
|
||||||
return copyOf(naturalOrder, elements);
|
return copyOf(naturalOrder, elements);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -297,7 +297,7 @@ public abstract class ImmutableSortedSet<E> extends ImmutableSortedSetFauxveride
|
||||||
// Hack around E not being a subtype of Comparable.
|
// Hack around E not being a subtype of Comparable.
|
||||||
// Unsafe, see ImmutableSortedSetFauxverideShim.
|
// Unsafe, see ImmutableSortedSetFauxverideShim.
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
Ordering<E> naturalOrder = (Ordering<E>) Ordering.<Comparable>natural();
|
Ordering<E> naturalOrder = (Ordering<E>) Ordering.natural();
|
||||||
return copyOf(naturalOrder, elements);
|
return copyOf(naturalOrder, elements);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -317,7 +317,7 @@ public abstract class ImmutableSortedSet<E> extends ImmutableSortedSetFauxveride
|
||||||
// Hack around E not being a subtype of Comparable.
|
// Hack around E not being a subtype of Comparable.
|
||||||
// Unsafe, see ImmutableSortedSetFauxverideShim.
|
// Unsafe, see ImmutableSortedSetFauxverideShim.
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
Ordering<E> naturalOrder = (Ordering<E>) Ordering.<Comparable>natural();
|
Ordering<E> naturalOrder = (Ordering<E>) Ordering.natural();
|
||||||
return copyOf(naturalOrder, elements);
|
return copyOf(naturalOrder, elements);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -442,7 +442,7 @@ public abstract class ImmutableSortedSet<E> extends ImmutableSortedSetFauxveride
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Arrays.fill(contents, uniques, n, null);
|
Arrays.fill(contents, uniques, n, null);
|
||||||
return new RegularImmutableSortedSet<E>(ImmutableList.<E>asImmutableList(contents, uniques), comparator);
|
return new RegularImmutableSortedSet<E>(ImmutableList.asImmutableList(contents, uniques), comparator);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -49,7 +49,7 @@ import com.google.common.base.Objects;
|
||||||
// TODO(gak): make serializable
|
// TODO(gak): make serializable
|
||||||
public abstract class ImmutableTable<R, C, V> extends AbstractTable<R, C, V> {
|
public abstract class ImmutableTable<R, C, V> extends AbstractTable<R, C, V> {
|
||||||
private static final ImmutableTable<Object, Object, Object> EMPTY = new SparseImmutableTable<Object, Object, Object>(
|
private static final ImmutableTable<Object, Object, Object> EMPTY = new SparseImmutableTable<Object, Object, Object>(
|
||||||
ImmutableList.<Cell<Object, Object, Object>>of(), ImmutableSet.of(), ImmutableSet.of());
|
ImmutableList.of(), ImmutableSet.of(), ImmutableSet.of());
|
||||||
|
|
||||||
/** Returns an empty immutable table. */
|
/** Returns an empty immutable table. */
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
|
@ -90,7 +90,7 @@ public abstract class ImmutableTable<R, C, V> extends AbstractTable<R, C, V> {
|
||||||
return of();
|
return of();
|
||||||
case 1:
|
case 1:
|
||||||
Cell<? extends R, ? extends C, ? extends V> onlyCell = Iterables.getOnlyElement(table.cellSet());
|
Cell<? extends R, ? extends C, ? extends V> onlyCell = Iterables.getOnlyElement(table.cellSet());
|
||||||
return ImmutableTable.<R, C, V>of(onlyCell.getRowKey(), onlyCell.getColumnKey(), onlyCell.getValue());
|
return ImmutableTable.of(onlyCell.getRowKey(), onlyCell.getColumnKey(), onlyCell.getValue());
|
||||||
default:
|
default:
|
||||||
ImmutableSet.Builder<Cell<R, C, V>> cellSetBuilder = ImmutableSet.builder();
|
ImmutableSet.Builder<Cell<R, C, V>> cellSetBuilder = ImmutableSet.builder();
|
||||||
for (Cell<? extends R, ? extends C, ? extends V> cell : table.cellSet()) {
|
for (Cell<? extends R, ? extends C, ? extends V> cell : table.cellSet()) {
|
||||||
|
@ -98,7 +98,7 @@ public abstract class ImmutableTable<R, C, V> extends AbstractTable<R, C, V> {
|
||||||
* Must cast to be able to create a Cell<R, C, V> rather than a Cell<? extends
|
* Must cast to be able to create a Cell<R, C, V> rather than a Cell<? extends
|
||||||
* R, ? extends C, ? extends V>
|
* R, ? extends C, ? extends V>
|
||||||
*/
|
*/
|
||||||
cellSetBuilder.add(cellOf((R) cell.getRowKey(), (C) cell.getColumnKey(), (V) cell.getValue()));
|
cellSetBuilder.add(cellOf(cell.getRowKey(), cell.getColumnKey(), cell.getValue()));
|
||||||
}
|
}
|
||||||
return RegularImmutableTable.forCells(cellSetBuilder.build());
|
return RegularImmutableTable.forCells(cellSetBuilder.build());
|
||||||
}
|
}
|
||||||
|
@ -276,7 +276,7 @@ public abstract class ImmutableTable<R, C, V> extends AbstractTable<R, C, V> {
|
||||||
@Override
|
@Override
|
||||||
public ImmutableMap<R, V> column(C columnKey) {
|
public ImmutableMap<R, V> column(C columnKey) {
|
||||||
checkNotNull(columnKey);
|
checkNotNull(columnKey);
|
||||||
return Objects.firstNonNull((ImmutableMap<R, V>) columnMap().get(columnKey), ImmutableMap.<R, V>of());
|
return Objects.firstNonNull((ImmutableMap<R, V>) columnMap().get(columnKey), ImmutableMap.of());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -302,7 +302,7 @@ public abstract class ImmutableTable<R, C, V> extends AbstractTable<R, C, V> {
|
||||||
@Override
|
@Override
|
||||||
public ImmutableMap<C, V> row(R rowKey) {
|
public ImmutableMap<C, V> row(R rowKey) {
|
||||||
checkNotNull(rowKey);
|
checkNotNull(rowKey);
|
||||||
return Objects.firstNonNull((ImmutableMap<C, V>) rowMap().get(rowKey), ImmutableMap.<C, V>of());
|
return Objects.firstNonNull((ImmutableMap<C, V>) rowMap().get(rowKey), ImmutableMap.of());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -389,7 +389,7 @@ public final class Iterables {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return iterable.toString() + " (cycled)";
|
return iterable + " (cycled)";
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -750,7 +750,7 @@ public final class Iterators {
|
||||||
*/
|
*/
|
||||||
public static <T> Optional<T> tryFind(Iterator<T> iterator, Predicate<? super T> predicate) {
|
public static <T> Optional<T> tryFind(Iterator<T> iterator, Predicate<? super T> predicate) {
|
||||||
UnmodifiableIterator<T> filteredIterator = filter(iterator, predicate);
|
UnmodifiableIterator<T> filteredIterator = filter(iterator, predicate);
|
||||||
return filteredIterator.hasNext() ? Optional.of(filteredIterator.next()) : Optional.<T>absent();
|
return filteredIterator.hasNext() ? Optional.of(filteredIterator.next()) : Optional.absent();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -434,7 +434,7 @@ public class LinkedListMultimap<K, V> extends AbstractMultimap<K, V> implements
|
||||||
|
|
||||||
/** An {@code Iterator} over distinct keys in key head order. */
|
/** An {@code Iterator} over distinct keys in key head order. */
|
||||||
private class DistinctKeyIterator implements Iterator<K> {
|
private class DistinctKeyIterator implements Iterator<K> {
|
||||||
final Set<K> seenKeys = Sets.<K>newHashSetWithExpectedSize(keySet().size());
|
final Set<K> seenKeys = Sets.newHashSetWithExpectedSize(keySet().size());
|
||||||
Node<K, V> next = head;
|
Node<K, V> next = head;
|
||||||
Node<K, V> current;
|
Node<K, V> current;
|
||||||
int expectedModCount = modCount;
|
int expectedModCount = modCount;
|
||||||
|
|
|
@ -97,7 +97,7 @@ public final class Maps {
|
||||||
public Object apply(Entry<?, ?> entry) {
|
public Object apply(Entry<?, ?> entry) {
|
||||||
return entry.getValue();
|
return entry.getValue();
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
|
@ -111,11 +111,11 @@ public final class Maps {
|
||||||
}
|
}
|
||||||
|
|
||||||
static <K, V> Iterator<K> keyIterator(Iterator<Entry<K, V>> entryIterator) {
|
static <K, V> Iterator<K> keyIterator(Iterator<Entry<K, V>> entryIterator) {
|
||||||
return Iterators.transform(entryIterator, Maps.<K>keyFunction());
|
return Iterators.transform(entryIterator, Maps.keyFunction());
|
||||||
}
|
}
|
||||||
|
|
||||||
static <K, V> Iterator<V> valueIterator(Iterator<Entry<K, V>> entryIterator) {
|
static <K, V> Iterator<V> valueIterator(Iterator<Entry<K, V>> entryIterator) {
|
||||||
return Iterators.transform(entryIterator, Maps.<V>valueFunction());
|
return Iterators.transform(entryIterator, Maps.valueFunction());
|
||||||
}
|
}
|
||||||
|
|
||||||
static <K, V> UnmodifiableIterator<V> valueIterator(final UnmodifiableIterator<Entry<K, V>> entryIterator) {
|
static <K, V> UnmodifiableIterator<V> valueIterator(final UnmodifiableIterator<Entry<K, V>> entryIterator) {
|
||||||
|
@ -1973,7 +1973,7 @@ public final class Maps {
|
||||||
@Override
|
@Override
|
||||||
public Iterator<Entry<K, V2>> iterator() {
|
public Iterator<Entry<K, V2>> iterator() {
|
||||||
return Iterators.transform(fromMap.entrySet().iterator(),
|
return Iterators.transform(fromMap.entrySet().iterator(),
|
||||||
Maps.<K, V1, V2>asEntryToEntryFunction(transformer));
|
Maps.asEntryToEntryFunction(transformer));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -2147,11 +2147,11 @@ public final class Maps {
|
||||||
}
|
}
|
||||||
|
|
||||||
static <K> Predicate<Entry<K, ?>> keyPredicateOnEntries(Predicate<? super K> keyPredicate) {
|
static <K> Predicate<Entry<K, ?>> keyPredicateOnEntries(Predicate<? super K> keyPredicate) {
|
||||||
return compose(keyPredicate, Maps.<K>keyFunction());
|
return compose(keyPredicate, Maps.keyFunction());
|
||||||
}
|
}
|
||||||
|
|
||||||
static <V> Predicate<Entry<?, V>> valuePredicateOnEntries(Predicate<? super V> valuePredicate) {
|
static <V> Predicate<Entry<?, V>> valuePredicateOnEntries(Predicate<? super V> valuePredicate) {
|
||||||
return compose(valuePredicate, Maps.<V>valueFunction());
|
return compose(valuePredicate, Maps.valueFunction());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -2239,7 +2239,7 @@ public final class Maps {
|
||||||
final Predicate<? super K> keyPredicate) {
|
final Predicate<? super K> keyPredicate) {
|
||||||
// TODO(user): Return a subclass of Maps.FilteredKeyMap for slightly better
|
// TODO(user): Return a subclass of Maps.FilteredKeyMap for slightly better
|
||||||
// performance.
|
// performance.
|
||||||
return filterEntries(unfiltered, Maps.<K>keyPredicateOnEntries(keyPredicate));
|
return filterEntries(unfiltered, Maps.keyPredicateOnEntries(keyPredicate));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -2282,7 +2282,7 @@ public final class Maps {
|
||||||
final Predicate<? super K> keyPredicate) {
|
final Predicate<? super K> keyPredicate) {
|
||||||
// TODO(user): Return a subclass of Maps.FilteredKeyMap for slightly better
|
// TODO(user): Return a subclass of Maps.FilteredKeyMap for slightly better
|
||||||
// performance.
|
// performance.
|
||||||
return filterEntries(unfiltered, Maps.<K>keyPredicateOnEntries(keyPredicate));
|
return filterEntries(unfiltered, Maps.keyPredicateOnEntries(keyPredicate));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -2321,7 +2321,7 @@ public final class Maps {
|
||||||
*/
|
*/
|
||||||
public static <K, V> BiMap<K, V> filterKeys(BiMap<K, V> unfiltered, final Predicate<? super K> keyPredicate) {
|
public static <K, V> BiMap<K, V> filterKeys(BiMap<K, V> unfiltered, final Predicate<? super K> keyPredicate) {
|
||||||
checkNotNull(keyPredicate);
|
checkNotNull(keyPredicate);
|
||||||
return filterEntries(unfiltered, Maps.<K>keyPredicateOnEntries(keyPredicate));
|
return filterEntries(unfiltered, Maps.keyPredicateOnEntries(keyPredicate));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -2364,7 +2364,7 @@ public final class Maps {
|
||||||
} else if (unfiltered instanceof BiMap) {
|
} else if (unfiltered instanceof BiMap) {
|
||||||
return filterValues((BiMap<K, V>) unfiltered, valuePredicate);
|
return filterValues((BiMap<K, V>) unfiltered, valuePredicate);
|
||||||
}
|
}
|
||||||
return filterEntries(unfiltered, Maps.<V>valuePredicateOnEntries(valuePredicate));
|
return filterEntries(unfiltered, Maps.valuePredicateOnEntries(valuePredicate));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -2405,7 +2405,7 @@ public final class Maps {
|
||||||
*/
|
*/
|
||||||
public static <K, V> SortedMap<K, V> filterValues(SortedMap<K, V> unfiltered,
|
public static <K, V> SortedMap<K, V> filterValues(SortedMap<K, V> unfiltered,
|
||||||
final Predicate<? super V> valuePredicate) {
|
final Predicate<? super V> valuePredicate) {
|
||||||
return filterEntries(unfiltered, Maps.<V>valuePredicateOnEntries(valuePredicate));
|
return filterEntries(unfiltered, Maps.valuePredicateOnEntries(valuePredicate));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -2447,7 +2447,7 @@ public final class Maps {
|
||||||
@GwtIncompatible("NavigableMap")
|
@GwtIncompatible("NavigableMap")
|
||||||
public static <K, V> NavigableMap<K, V> filterValues(NavigableMap<K, V> unfiltered,
|
public static <K, V> NavigableMap<K, V> filterValues(NavigableMap<K, V> unfiltered,
|
||||||
final Predicate<? super V> valuePredicate) {
|
final Predicate<? super V> valuePredicate) {
|
||||||
return filterEntries(unfiltered, Maps.<V>valuePredicateOnEntries(valuePredicate));
|
return filterEntries(unfiltered, Maps.valuePredicateOnEntries(valuePredicate));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -2487,7 +2487,7 @@ public final class Maps {
|
||||||
* @since 14.0
|
* @since 14.0
|
||||||
*/
|
*/
|
||||||
public static <K, V> BiMap<K, V> filterValues(BiMap<K, V> unfiltered, final Predicate<? super V> valuePredicate) {
|
public static <K, V> BiMap<K, V> filterValues(BiMap<K, V> unfiltered, final Predicate<? super V> valuePredicate) {
|
||||||
return filterEntries(unfiltered, Maps.<V>valuePredicateOnEntries(valuePredicate));
|
return filterEntries(unfiltered, Maps.valuePredicateOnEntries(valuePredicate));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -2681,7 +2681,7 @@ public final class Maps {
|
||||||
*/
|
*/
|
||||||
private static <K, V> Map<K, V> filterFiltered(AbstractFilteredMap<K, V> map,
|
private static <K, V> Map<K, V> filterFiltered(AbstractFilteredMap<K, V> map,
|
||||||
Predicate<? super Entry<K, V>> entryPredicate) {
|
Predicate<? super Entry<K, V>> entryPredicate) {
|
||||||
return new FilteredEntryMap<K, V>(map.unfiltered, Predicates.<Entry<K, V>>and(map.predicate, entryPredicate));
|
return new FilteredEntryMap<K, V>(map.unfiltered, Predicates.and(map.predicate, entryPredicate));
|
||||||
}
|
}
|
||||||
|
|
||||||
private abstract static class AbstractFilteredMap<K, V> extends ImprovedAbstractMap<K, V> {
|
private abstract static class AbstractFilteredMap<K, V> extends ImprovedAbstractMap<K, V> {
|
||||||
|
@ -2755,12 +2755,12 @@ public final class Maps {
|
||||||
@Override
|
@Override
|
||||||
public boolean remove(Object o) {
|
public boolean remove(Object o) {
|
||||||
return Iterables.removeFirstMatching(unfiltered.entrySet(),
|
return Iterables.removeFirstMatching(unfiltered.entrySet(),
|
||||||
Predicates.<Entry<K, V>>and(predicate, Maps.<V>valuePredicateOnEntries(equalTo(o)))) != null;
|
Predicates.and(predicate, Maps.valuePredicateOnEntries(equalTo(o)))) != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean removeIf(Predicate<? super V> valuePredicate) {
|
private boolean removeIf(Predicate<? super V> valuePredicate) {
|
||||||
return Iterables.removeIf(unfiltered.entrySet(),
|
return Iterables.removeIf(unfiltered.entrySet(),
|
||||||
Predicates.<Entry<K, V>>and(predicate, Maps.<V>valuePredicateOnEntries(valuePredicate)));
|
Predicates.and(predicate, Maps.valuePredicateOnEntries(valuePredicate)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -2879,7 +2879,7 @@ public final class Maps {
|
||||||
|
|
||||||
private boolean removeIf(Predicate<? super K> keyPredicate) {
|
private boolean removeIf(Predicate<? super K> keyPredicate) {
|
||||||
return Iterables.removeIf(unfiltered.entrySet(),
|
return Iterables.removeIf(unfiltered.entrySet(),
|
||||||
Predicates.<Entry<K, V>>and(predicate, Maps.<K>keyPredicateOnEntries(keyPredicate)));
|
Predicates.and(predicate, Maps.keyPredicateOnEntries(keyPredicate)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -3047,13 +3047,13 @@ public final class Maps {
|
||||||
@Override
|
@Override
|
||||||
public boolean removeAll(Collection<?> c) {
|
public boolean removeAll(Collection<?> c) {
|
||||||
return Iterators.removeIf(unfiltered.entrySet().iterator(),
|
return Iterators.removeIf(unfiltered.entrySet().iterator(),
|
||||||
Predicates.<Entry<K, V>>and(entryPredicate, Maps.<K>keyPredicateOnEntries(in(c))));
|
Predicates.and(entryPredicate, Maps.keyPredicateOnEntries(in(c))));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean retainAll(Collection<?> c) {
|
public boolean retainAll(Collection<?> c) {
|
||||||
return Iterators.removeIf(unfiltered.entrySet().iterator(),
|
return Iterators.removeIf(unfiltered.entrySet().iterator(),
|
||||||
Predicates.<Entry<K, V>>and(entryPredicate, Maps.<K>keyPredicateOnEntries(not(in(c)))));
|
Predicates.and(entryPredicate, Maps.keyPredicateOnEntries(not(in(c)))));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -108,7 +108,7 @@ public final class MinMaxPriorityQueue<E> extends AbstractQueue<E> {
|
||||||
* and initially containing the given elements.
|
* and initially containing the given elements.
|
||||||
*/
|
*/
|
||||||
public static <E extends Comparable<E>> MinMaxPriorityQueue<E> create(Iterable<? extends E> initialContents) {
|
public static <E extends Comparable<E>> MinMaxPriorityQueue<E> create(Iterable<? extends E> initialContents) {
|
||||||
return new Builder<E>(Ordering.<E>natural()).create(initialContents);
|
return new Builder<E>(Ordering.natural()).create(initialContents);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -196,7 +196,7 @@ public final class MinMaxPriorityQueue<E> extends AbstractQueue<E> {
|
||||||
* and having no initial contents.
|
* and having no initial contents.
|
||||||
*/
|
*/
|
||||||
public <T extends B> MinMaxPriorityQueue<T> create() {
|
public <T extends B> MinMaxPriorityQueue<T> create() {
|
||||||
return create(Collections.<T>emptySet());
|
return create(Collections.emptySet());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -715,10 +715,7 @@ public final class MinMaxPriorityQueue<E> extends AbstractQueue<E> {
|
||||||
if ((i > 0) && (compareElements(i, getParentIndex(i)) > 0)) {
|
if ((i > 0) && (compareElements(i, getParentIndex(i)) > 0)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if ((i > 2) && (compareElements(getGrandparentIndex(i), i) > 0)) {
|
return (i <= 2) || (compareElements(getGrandparentIndex(i), i) <= 0);
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// These would be static if inner classes could have static members.
|
// These would be static if inner classes could have static members.
|
||||||
|
|
|
@ -324,7 +324,7 @@ public abstract class MultimapBuilder<K0, V0> {
|
||||||
return new ListMultimapBuilder<K0, Object>() {
|
return new ListMultimapBuilder<K0, Object>() {
|
||||||
@Override
|
@Override
|
||||||
public <K extends K0, V> ListMultimap<K, V> build() {
|
public <K extends K0, V> ListMultimap<K, V> build() {
|
||||||
return Multimaps.newListMultimap(MultimapBuilderWithKeys.this.<K, V>createMap(),
|
return Multimaps.newListMultimap(MultimapBuilderWithKeys.this.createMap(),
|
||||||
new ArrayListSupplier<V>(expectedValuesPerKey));
|
new ArrayListSupplier<V>(expectedValuesPerKey));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -337,8 +337,8 @@ public abstract class MultimapBuilder<K0, V0> {
|
||||||
return new ListMultimapBuilder<K0, Object>() {
|
return new ListMultimapBuilder<K0, Object>() {
|
||||||
@Override
|
@Override
|
||||||
public <K extends K0, V> ListMultimap<K, V> build() {
|
public <K extends K0, V> ListMultimap<K, V> build() {
|
||||||
return Multimaps.newListMultimap(MultimapBuilderWithKeys.this.<K, V>createMap(),
|
return Multimaps.newListMultimap(MultimapBuilderWithKeys.this.createMap(),
|
||||||
LinkedListSupplier.<V>instance());
|
LinkedListSupplier.instance());
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -361,7 +361,7 @@ public abstract class MultimapBuilder<K0, V0> {
|
||||||
return new SetMultimapBuilder<K0, Object>() {
|
return new SetMultimapBuilder<K0, Object>() {
|
||||||
@Override
|
@Override
|
||||||
public <K extends K0, V> SetMultimap<K, V> build() {
|
public <K extends K0, V> SetMultimap<K, V> build() {
|
||||||
return Multimaps.newSetMultimap(MultimapBuilderWithKeys.this.<K, V>createMap(),
|
return Multimaps.newSetMultimap(MultimapBuilderWithKeys.this.createMap(),
|
||||||
new HashSetSupplier<V>(expectedValuesPerKey));
|
new HashSetSupplier<V>(expectedValuesPerKey));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -385,7 +385,7 @@ public abstract class MultimapBuilder<K0, V0> {
|
||||||
return new SetMultimapBuilder<K0, Object>() {
|
return new SetMultimapBuilder<K0, Object>() {
|
||||||
@Override
|
@Override
|
||||||
public <K extends K0, V> SetMultimap<K, V> build() {
|
public <K extends K0, V> SetMultimap<K, V> build() {
|
||||||
return Multimaps.newSetMultimap(MultimapBuilderWithKeys.this.<K, V>createMap(),
|
return Multimaps.newSetMultimap(MultimapBuilderWithKeys.this.createMap(),
|
||||||
new LinkedHashSetSupplier<V>(expectedValuesPerKey));
|
new LinkedHashSetSupplier<V>(expectedValuesPerKey));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -412,7 +412,7 @@ public abstract class MultimapBuilder<K0, V0> {
|
||||||
return new SortedSetMultimapBuilder<K0, V0>() {
|
return new SortedSetMultimapBuilder<K0, V0>() {
|
||||||
@Override
|
@Override
|
||||||
public <K extends K0, V extends V0> SortedSetMultimap<K, V> build() {
|
public <K extends K0, V extends V0> SortedSetMultimap<K, V> build() {
|
||||||
return Multimaps.newSortedSetMultimap(MultimapBuilderWithKeys.this.<K, V>createMap(),
|
return Multimaps.newSortedSetMultimap(MultimapBuilderWithKeys.this.createMap(),
|
||||||
new TreeSetSupplier<V>(comparator));
|
new TreeSetSupplier<V>(comparator));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -430,7 +430,7 @@ public abstract class MultimapBuilder<K0, V0> {
|
||||||
// (their subclasses are inaccessible)
|
// (their subclasses are inaccessible)
|
||||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||||
Supplier<Set<V>> factory = (Supplier) new EnumSetSupplier<V0>(valueClass);
|
Supplier<Set<V>> factory = (Supplier) new EnumSetSupplier<V0>(valueClass);
|
||||||
return Multimaps.newSetMultimap(MultimapBuilderWithKeys.this.<K, V>createMap(), factory);
|
return Multimaps.newSetMultimap(MultimapBuilderWithKeys.this.createMap(), factory);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -1277,7 +1277,7 @@ public final class Multimaps {
|
||||||
@Override
|
@Override
|
||||||
Iterator<Entry<K, V2>> entryIterator() {
|
Iterator<Entry<K, V2>> entryIterator() {
|
||||||
return Iterators.transform(fromMultimap.entries().iterator(),
|
return Iterators.transform(fromMultimap.entries().iterator(),
|
||||||
Maps.<K, V1, V2>asEntryToEntryFunction(transformer));
|
Maps.asEntryToEntryFunction(transformer));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -1339,7 +1339,7 @@ public final class Multimaps {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
Collection<V2> createValues() {
|
Collection<V2> createValues() {
|
||||||
return Collections2.transform(fromMultimap.entries(), Maps.<K, V1, V2>asEntryToValueFunction(transformer));
|
return Collections2.transform(fromMultimap.entries(), Maps.asEntryToValueFunction(transformer));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1917,7 +1917,7 @@ public final class Multimaps {
|
||||||
return new FilteredKeyMultimap<K, V>(prev.unfiltered, Predicates.and(prev.keyPredicate, keyPredicate));
|
return new FilteredKeyMultimap<K, V>(prev.unfiltered, Predicates.and(prev.keyPredicate, keyPredicate));
|
||||||
} else if (unfiltered instanceof FilteredMultimap) {
|
} else if (unfiltered instanceof FilteredMultimap) {
|
||||||
FilteredMultimap<K, V> prev = (FilteredMultimap<K, V>) unfiltered;
|
FilteredMultimap<K, V> prev = (FilteredMultimap<K, V>) unfiltered;
|
||||||
return filterFiltered(prev, Maps.<K>keyPredicateOnEntries(keyPredicate));
|
return filterFiltered(prev, Maps.keyPredicateOnEntries(keyPredicate));
|
||||||
} else {
|
} else {
|
||||||
return new FilteredKeyMultimap<K, V>(unfiltered, keyPredicate);
|
return new FilteredKeyMultimap<K, V>(unfiltered, keyPredicate);
|
||||||
}
|
}
|
||||||
|
@ -1965,7 +1965,7 @@ public final class Multimaps {
|
||||||
return new FilteredKeySetMultimap<K, V>(prev.unfiltered(), Predicates.and(prev.keyPredicate, keyPredicate));
|
return new FilteredKeySetMultimap<K, V>(prev.unfiltered(), Predicates.and(prev.keyPredicate, keyPredicate));
|
||||||
} else if (unfiltered instanceof FilteredSetMultimap) {
|
} else if (unfiltered instanceof FilteredSetMultimap) {
|
||||||
FilteredSetMultimap<K, V> prev = (FilteredSetMultimap<K, V>) unfiltered;
|
FilteredSetMultimap<K, V> prev = (FilteredSetMultimap<K, V>) unfiltered;
|
||||||
return filterFiltered(prev, Maps.<K>keyPredicateOnEntries(keyPredicate));
|
return filterFiltered(prev, Maps.keyPredicateOnEntries(keyPredicate));
|
||||||
} else {
|
} else {
|
||||||
return new FilteredKeySetMultimap<K, V>(unfiltered, keyPredicate);
|
return new FilteredKeySetMultimap<K, V>(unfiltered, keyPredicate);
|
||||||
}
|
}
|
||||||
|
@ -2054,7 +2054,7 @@ public final class Multimaps {
|
||||||
*/
|
*/
|
||||||
public static <K, V> Multimap<K, V> filterValues(Multimap<K, V> unfiltered,
|
public static <K, V> Multimap<K, V> filterValues(Multimap<K, V> unfiltered,
|
||||||
final Predicate<? super V> valuePredicate) {
|
final Predicate<? super V> valuePredicate) {
|
||||||
return filterEntries(unfiltered, Maps.<V>valuePredicateOnEntries(valuePredicate));
|
return filterEntries(unfiltered, Maps.valuePredicateOnEntries(valuePredicate));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -2094,7 +2094,7 @@ public final class Multimaps {
|
||||||
*/
|
*/
|
||||||
public static <K, V> SetMultimap<K, V> filterValues(SetMultimap<K, V> unfiltered,
|
public static <K, V> SetMultimap<K, V> filterValues(SetMultimap<K, V> unfiltered,
|
||||||
final Predicate<? super V> valuePredicate) {
|
final Predicate<? super V> valuePredicate) {
|
||||||
return filterEntries(unfiltered, Maps.<V>valuePredicateOnEntries(valuePredicate));
|
return filterEntries(unfiltered, Maps.valuePredicateOnEntries(valuePredicate));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -110,7 +110,7 @@ public final class Multisets {
|
||||||
transient Set<E> elementSet;
|
transient Set<E> elementSet;
|
||||||
|
|
||||||
Set<E> createElementSet() {
|
Set<E> createElementSet() {
|
||||||
return Collections.<E>unmodifiableSet(delegate.elementSet());
|
return Collections.unmodifiableSet(delegate.elementSet());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -290,7 +290,7 @@ public final class Multisets {
|
||||||
// Support clear(), removeAll(), and retainAll() when filtering a filtered
|
// Support clear(), removeAll(), and retainAll() when filtering a filtered
|
||||||
// collection.
|
// collection.
|
||||||
FilteredMultiset<E> filtered = (FilteredMultiset<E>) unfiltered;
|
FilteredMultiset<E> filtered = (FilteredMultiset<E>) unfiltered;
|
||||||
Predicate<E> combinedPredicate = Predicates.<E>and(filtered.predicate, predicate);
|
Predicate<E> combinedPredicate = Predicates.and(filtered.predicate, predicate);
|
||||||
return new FilteredMultiset<E>(filtered.unfiltered, combinedPredicate);
|
return new FilteredMultiset<E>(filtered.unfiltered, combinedPredicate);
|
||||||
}
|
}
|
||||||
return new FilteredMultiset<E>(unfiltered, predicate);
|
return new FilteredMultiset<E>(unfiltered, predicate);
|
||||||
|
|
|
@ -314,7 +314,7 @@ public abstract class Ordering<T> implements Comparator<T> {
|
||||||
}
|
}
|
||||||
|
|
||||||
<T2 extends T> Ordering<Map.Entry<T2, ?>> onKeys() {
|
<T2 extends T> Ordering<Map.Entry<T2, ?>> onKeys() {
|
||||||
return onResultOf(Maps.<T2>keyFunction());
|
return onResultOf(Maps.keyFunction());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -268,7 +268,7 @@ public final class Range<C extends Comparable> implements Predicate<C>, Serializ
|
||||||
* @since 14.0
|
* @since 14.0
|
||||||
*/
|
*/
|
||||||
public static <C extends Comparable<?>> Range<C> lessThan(C endpoint) {
|
public static <C extends Comparable<?>> Range<C> lessThan(C endpoint) {
|
||||||
return create(Cut.<C>belowAll(), Cut.belowValue(endpoint));
|
return create(Cut.belowAll(), Cut.belowValue(endpoint));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -278,7 +278,7 @@ public final class Range<C extends Comparable> implements Predicate<C>, Serializ
|
||||||
* @since 14.0
|
* @since 14.0
|
||||||
*/
|
*/
|
||||||
public static <C extends Comparable<?>> Range<C> atMost(C endpoint) {
|
public static <C extends Comparable<?>> Range<C> atMost(C endpoint) {
|
||||||
return create(Cut.<C>belowAll(), Cut.aboveValue(endpoint));
|
return create(Cut.belowAll(), Cut.aboveValue(endpoint));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -305,7 +305,7 @@ public final class Range<C extends Comparable> implements Predicate<C>, Serializ
|
||||||
* @since 14.0
|
* @since 14.0
|
||||||
*/
|
*/
|
||||||
public static <C extends Comparable<?>> Range<C> greaterThan(C endpoint) {
|
public static <C extends Comparable<?>> Range<C> greaterThan(C endpoint) {
|
||||||
return create(Cut.aboveValue(endpoint), Cut.<C>aboveAll());
|
return create(Cut.aboveValue(endpoint), Cut.aboveAll());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -315,7 +315,7 @@ public final class Range<C extends Comparable> implements Predicate<C>, Serializ
|
||||||
* @since 14.0
|
* @since 14.0
|
||||||
*/
|
*/
|
||||||
public static <C extends Comparable<?>> Range<C> atLeast(C endpoint) {
|
public static <C extends Comparable<?>> Range<C> atLeast(C endpoint) {
|
||||||
return create(Cut.belowValue(endpoint), Cut.<C>aboveAll());
|
return create(Cut.belowValue(endpoint), Cut.aboveAll());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -37,7 +37,7 @@ class RegularImmutableAsList<E> extends ImmutableAsList<E> {
|
||||||
}
|
}
|
||||||
|
|
||||||
RegularImmutableAsList(ImmutableCollection<E> delegate, Object[] array) {
|
RegularImmutableAsList(ImmutableCollection<E> delegate, Object[] array) {
|
||||||
this(delegate, ImmutableList.<E>asImmutableList(array));
|
this(delegate, ImmutableList.asImmutableList(array));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -39,7 +39,7 @@ abstract class RegularImmutableTable<R, C, V> extends ImmutableTable<R, C, V> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
final ImmutableSet<Cell<R, C, V>> createCellSet() {
|
final ImmutableSet<Cell<R, C, V>> createCellSet() {
|
||||||
return isEmpty() ? ImmutableSet.<Cell<R, C, V>>of() : new CellSet();
|
return isEmpty() ? ImmutableSet.of() : new CellSet();
|
||||||
}
|
}
|
||||||
|
|
||||||
private final class CellSet extends ImmutableSet<Cell<R, C, V>> {
|
private final class CellSet extends ImmutableSet<Cell<R, C, V>> {
|
||||||
|
@ -88,7 +88,7 @@ abstract class RegularImmutableTable<R, C, V> extends ImmutableTable<R, C, V> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
final ImmutableCollection<V> createValues() {
|
final ImmutableCollection<V> createValues() {
|
||||||
return isEmpty() ? ImmutableList.<V>of() : new Values();
|
return isEmpty() ? ImmutableList.of() : new Values();
|
||||||
}
|
}
|
||||||
|
|
||||||
private final class Values extends ImmutableList<V> {
|
private final class Values extends ImmutableList<V> {
|
||||||
|
|
|
@ -365,7 +365,7 @@ public final class Sets {
|
||||||
* @since 8.0
|
* @since 8.0
|
||||||
*/
|
*/
|
||||||
public static <E> Set<E> newIdentityHashSet() {
|
public static <E> Set<E> newIdentityHashSet() {
|
||||||
return Sets.newSetFromMap(Maps.<E, Boolean>newIdentityHashMap());
|
return Sets.newSetFromMap(Maps.newIdentityHashMap());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -732,7 +732,7 @@ public final class Sets {
|
||||||
// Support clear(), removeAll(), and retainAll() when filtering a filtered
|
// Support clear(), removeAll(), and retainAll() when filtering a filtered
|
||||||
// collection.
|
// collection.
|
||||||
FilteredSet<E> filtered = (FilteredSet<E>) unfiltered;
|
FilteredSet<E> filtered = (FilteredSet<E>) unfiltered;
|
||||||
Predicate<E> combinedPredicate = Predicates.<E>and(filtered.predicate, predicate);
|
Predicate<E> combinedPredicate = Predicates.and(filtered.predicate, predicate);
|
||||||
return new FilteredSet<E>((Set<E>) filtered.unfiltered, combinedPredicate);
|
return new FilteredSet<E>((Set<E>) filtered.unfiltered, combinedPredicate);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -796,7 +796,7 @@ public final class Sets {
|
||||||
// Support clear(), removeAll(), and retainAll() when filtering a filtered
|
// Support clear(), removeAll(), and retainAll() when filtering a filtered
|
||||||
// collection.
|
// collection.
|
||||||
FilteredSet<E> filtered = (FilteredSet<E>) unfiltered;
|
FilteredSet<E> filtered = (FilteredSet<E>) unfiltered;
|
||||||
Predicate<E> combinedPredicate = Predicates.<E>and(filtered.predicate, predicate);
|
Predicate<E> combinedPredicate = Predicates.and(filtered.predicate, predicate);
|
||||||
return new FilteredSortedSet<E>((SortedSet<E>) filtered.unfiltered, combinedPredicate);
|
return new FilteredSortedSet<E>((SortedSet<E>) filtered.unfiltered, combinedPredicate);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -886,7 +886,7 @@ public final class Sets {
|
||||||
// Support clear(), removeAll(), and retainAll() when filtering a filtered
|
// Support clear(), removeAll(), and retainAll() when filtering a filtered
|
||||||
// collection.
|
// collection.
|
||||||
FilteredSet<E> filtered = (FilteredSet<E>) unfiltered;
|
FilteredSet<E> filtered = (FilteredSet<E>) unfiltered;
|
||||||
Predicate<E> combinedPredicate = Predicates.<E>and(filtered.predicate, predicate);
|
Predicate<E> combinedPredicate = Predicates.and(filtered.predicate, predicate);
|
||||||
return new FilteredNavigableSet<E>((NavigableSet<E>) filtered.unfiltered, combinedPredicate);
|
return new FilteredNavigableSet<E>((NavigableSet<E>) filtered.unfiltered, combinedPredicate);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -69,7 +69,7 @@ final class SingletonImmutableList<E> extends ImmutableList<E> {
|
||||||
@Override
|
@Override
|
||||||
public ImmutableList<E> subList(int fromIndex, int toIndex) {
|
public ImmutableList<E> subList(int fromIndex, int toIndex) {
|
||||||
Preconditions.checkPositionIndexes(fromIndex, toIndex, 1);
|
Preconditions.checkPositionIndexes(fromIndex, toIndex, 1);
|
||||||
return (fromIndex == toIndex) ? ImmutableList.<E>of() : this;
|
return (fromIndex == toIndex) ? ImmutableList.of() : this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -104,8 +104,7 @@ final class SingletonImmutableList<E> extends ImmutableList<E> {
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
String elementToString = element.toString();
|
String elementToString = element.toString();
|
||||||
return new StringBuilder(elementToString.length() + 2).append('[').append(elementToString).append(']')
|
return '[' + elementToString + ']';
|
||||||
.toString();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -97,7 +97,7 @@ final class SingletonImmutableSet<E> extends ImmutableSet<E> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public final int hashCode() {
|
public int hashCode() {
|
||||||
// Racy single-check.
|
// Racy single-check.
|
||||||
int code = cachedHashCode;
|
int code = cachedHashCode;
|
||||||
if (code == 0) {
|
if (code == 0) {
|
||||||
|
@ -114,7 +114,6 @@ final class SingletonImmutableSet<E> extends ImmutableSet<E> {
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
String elementToString = element.toString();
|
String elementToString = element.toString();
|
||||||
return new StringBuilder(elementToString.length() + 2).append('[').append(elementToString).append(']')
|
return '[' + elementToString + ']';
|
||||||
.toString();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,17 +46,17 @@ class SingletonImmutableTable<R, C, V> extends ImmutableTable<R, C, V> {
|
||||||
@Override
|
@Override
|
||||||
public ImmutableMap<R, V> column(C columnKey) {
|
public ImmutableMap<R, V> column(C columnKey) {
|
||||||
checkNotNull(columnKey);
|
checkNotNull(columnKey);
|
||||||
return containsColumn(columnKey) ? ImmutableMap.of(singleRowKey, singleValue) : ImmutableMap.<R, V>of();
|
return containsColumn(columnKey) ? ImmutableMap.of(singleRowKey, singleValue) : ImmutableMap.of();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ImmutableMap<C, Map<R, V>> columnMap() {
|
public ImmutableMap<C, Map<R, V>> columnMap() {
|
||||||
return ImmutableMap.of(singleColumnKey, (Map<R, V>) ImmutableMap.of(singleRowKey, singleValue));
|
return ImmutableMap.of(singleColumnKey, ImmutableMap.of(singleRowKey, singleValue));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ImmutableMap<R, Map<C, V>> rowMap() {
|
public ImmutableMap<R, Map<C, V>> rowMap() {
|
||||||
return ImmutableMap.of(singleRowKey, (Map<C, V>) ImmutableMap.of(singleColumnKey, singleValue));
|
return ImmutableMap.of(singleRowKey, ImmutableMap.of(singleColumnKey, singleValue));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -569,7 +569,7 @@ class StandardTable<R, C, V> extends AbstractTable<R, C, V> implements Serializa
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean retainAll(final Collection<?> c) {
|
public boolean retainAll(final Collection<?> c) {
|
||||||
return removeFromColumnIf(Maps.<R>keyPredicateOnEntries(not(in(c))));
|
return removeFromColumnIf(Maps.keyPredicateOnEntries(not(in(c))));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -585,17 +585,17 @@ class StandardTable<R, C, V> extends AbstractTable<R, C, V> implements Serializa
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean remove(Object obj) {
|
public boolean remove(Object obj) {
|
||||||
return obj != null && removeFromColumnIf(Maps.<V>valuePredicateOnEntries(equalTo(obj)));
|
return obj != null && removeFromColumnIf(Maps.valuePredicateOnEntries(equalTo(obj)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean removeAll(final Collection<?> c) {
|
public boolean removeAll(final Collection<?> c) {
|
||||||
return removeFromColumnIf(Maps.<V>valuePredicateOnEntries(in(c)));
|
return removeFromColumnIf(Maps.valuePredicateOnEntries(in(c)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean retainAll(final Collection<?> c) {
|
public boolean retainAll(final Collection<?> c) {
|
||||||
return removeFromColumnIf(Maps.<V>valuePredicateOnEntries(not(in(c))));
|
return removeFromColumnIf(Maps.valuePredicateOnEntries(not(in(c))));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -499,7 +499,7 @@ public final class TreeRangeMap<K extends Comparable, V> implements RangeMap<K,
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean retainAll(Collection<?> c) {
|
public boolean retainAll(Collection<?> c) {
|
||||||
return removeEntryIf(compose(not(in(c)), Maps.<Range<K>>keyFunction()));
|
return removeEntryIf(compose(not(in(c)), Maps.keyFunction()));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -562,12 +562,12 @@ public final class TreeRangeMap<K extends Comparable, V> implements RangeMap<K,
|
||||||
return new Maps.Values<Range<K>, V>(this) {
|
return new Maps.Values<Range<K>, V>(this) {
|
||||||
@Override
|
@Override
|
||||||
public boolean removeAll(Collection<?> c) {
|
public boolean removeAll(Collection<?> c) {
|
||||||
return removeEntryIf(compose(in(c), Maps.<V>valueFunction()));
|
return removeEntryIf(compose(in(c), Maps.valueFunction()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean retainAll(Collection<?> c) {
|
public boolean retainAll(Collection<?> c) {
|
||||||
return removeEntryIf(compose(not(in(c)), Maps.<V>valueFunction()));
|
return removeEntryIf(compose(not(in(c)), Maps.valueFunction()));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -278,7 +278,7 @@ public class TreeRangeSet<C extends Comparable<?>> extends AbstractRangeSet<C> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Comparator<? super Cut<C>> comparator() {
|
public Comparator<? super Cut<C>> comparator() {
|
||||||
return Ordering.<Cut<C>>natural();
|
return Ordering.natural();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -395,7 +395,7 @@ public class TreeRangeSet<C extends Comparable<?>> extends AbstractRangeSet<C> {
|
||||||
private final Range<Cut<C>> complementLowerBoundWindow;
|
private final Range<Cut<C>> complementLowerBoundWindow;
|
||||||
|
|
||||||
ComplementRangesByLowerBound(NavigableMap<Cut<C>, Range<C>> positiveRangesByLowerBound) {
|
ComplementRangesByLowerBound(NavigableMap<Cut<C>, Range<C>> positiveRangesByLowerBound) {
|
||||||
this(positiveRangesByLowerBound, Range.<Cut<C>>all());
|
this(positiveRangesByLowerBound, Range.all());
|
||||||
}
|
}
|
||||||
|
|
||||||
private ComplementRangesByLowerBound(NavigableMap<Cut<C>, Range<C>> positiveRangesByLowerBound,
|
private ComplementRangesByLowerBound(NavigableMap<Cut<C>, Range<C>> positiveRangesByLowerBound,
|
||||||
|
@ -433,7 +433,7 @@ public class TreeRangeSet<C extends Comparable<?>> extends AbstractRangeSet<C> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Comparator<? super Cut<C>> comparator() {
|
public Comparator<? super Cut<C>> comparator() {
|
||||||
return Ordering.<Cut<C>>natural();
|
return Ordering.natural();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -456,7 +456,7 @@ public class TreeRangeSet<C extends Comparable<?>> extends AbstractRangeSet<C> {
|
||||||
}
|
}
|
||||||
final PeekingIterator<Range<C>> positiveItr = Iterators.peekingIterator(positiveRanges.iterator());
|
final PeekingIterator<Range<C>> positiveItr = Iterators.peekingIterator(positiveRanges.iterator());
|
||||||
final Cut<C> firstComplementRangeLowerBound;
|
final Cut<C> firstComplementRangeLowerBound;
|
||||||
if (complementLowerBoundWindow.contains(Cut.<C>belowAll())
|
if (complementLowerBoundWindow.contains(Cut.belowAll())
|
||||||
&& (!positiveItr.hasNext() || positiveItr.peek().lowerBound != Cut.<C>belowAll())) {
|
&& (!positiveItr.hasNext() || positiveItr.peek().lowerBound != Cut.<C>belowAll())) {
|
||||||
firstComplementRangeLowerBound = Cut.belowAll();
|
firstComplementRangeLowerBound = Cut.belowAll();
|
||||||
} else if (positiveItr.hasNext()) {
|
} else if (positiveItr.hasNext()) {
|
||||||
|
@ -479,7 +479,7 @@ public class TreeRangeSet<C extends Comparable<?>> extends AbstractRangeSet<C> {
|
||||||
negativeRange = Range.create(nextComplementRangeLowerBound, positiveRange.lowerBound);
|
negativeRange = Range.create(nextComplementRangeLowerBound, positiveRange.lowerBound);
|
||||||
nextComplementRangeLowerBound = positiveRange.upperBound;
|
nextComplementRangeLowerBound = positiveRange.upperBound;
|
||||||
} else {
|
} else {
|
||||||
negativeRange = Range.create(nextComplementRangeLowerBound, Cut.<C>aboveAll());
|
negativeRange = Range.create(nextComplementRangeLowerBound, Cut.aboveAll());
|
||||||
nextComplementRangeLowerBound = Cut.aboveAll();
|
nextComplementRangeLowerBound = Cut.aboveAll();
|
||||||
}
|
}
|
||||||
return Maps.immutableEntry(negativeRange.lowerBound, negativeRange);
|
return Maps.immutableEntry(negativeRange.lowerBound, negativeRange);
|
||||||
|
@ -500,7 +500,7 @@ public class TreeRangeSet<C extends Comparable<?>> extends AbstractRangeSet<C> {
|
||||||
*/
|
*/
|
||||||
Cut<C> startingPoint = complementLowerBoundWindow.hasUpperBound()
|
Cut<C> startingPoint = complementLowerBoundWindow.hasUpperBound()
|
||||||
? complementLowerBoundWindow.upperEndpoint()
|
? complementLowerBoundWindow.upperEndpoint()
|
||||||
: Cut.<C>aboveAll();
|
: Cut.aboveAll();
|
||||||
boolean inclusive = complementLowerBoundWindow.hasUpperBound()
|
boolean inclusive = complementLowerBoundWindow.hasUpperBound()
|
||||||
&& complementLowerBoundWindow.upperBoundType() == BoundType.CLOSED;
|
&& complementLowerBoundWindow.upperBoundType() == BoundType.CLOSED;
|
||||||
final PeekingIterator<Range<C>> positiveItr = Iterators.peekingIterator(
|
final PeekingIterator<Range<C>> positiveItr = Iterators.peekingIterator(
|
||||||
|
@ -509,13 +509,13 @@ public class TreeRangeSet<C extends Comparable<?>> extends AbstractRangeSet<C> {
|
||||||
if (positiveItr.hasNext()) {
|
if (positiveItr.hasNext()) {
|
||||||
cut = (positiveItr.peek().upperBound == Cut.<C>aboveAll()) ? positiveItr.next().lowerBound
|
cut = (positiveItr.peek().upperBound == Cut.<C>aboveAll()) ? positiveItr.next().lowerBound
|
||||||
: positiveRangesByLowerBound.higherKey(positiveItr.peek().upperBound);
|
: positiveRangesByLowerBound.higherKey(positiveItr.peek().upperBound);
|
||||||
} else if (!complementLowerBoundWindow.contains(Cut.<C>belowAll())
|
} else if (!complementLowerBoundWindow.contains(Cut.belowAll())
|
||||||
|| positiveRangesByLowerBound.containsKey(Cut.belowAll())) {
|
|| positiveRangesByLowerBound.containsKey(Cut.belowAll())) {
|
||||||
return Iterators.emptyIterator();
|
return Iterators.emptyIterator();
|
||||||
} else {
|
} else {
|
||||||
cut = positiveRangesByLowerBound.higherKey(Cut.<C>belowAll());
|
cut = positiveRangesByLowerBound.higherKey(Cut.belowAll());
|
||||||
}
|
}
|
||||||
final Cut<C> firstComplementRangeUpperBound = Objects.firstNonNull(cut, Cut.<C>aboveAll());
|
final Cut<C> firstComplementRangeUpperBound = Objects.firstNonNull(cut, Cut.aboveAll());
|
||||||
return new AbstractIterator<Entry<Cut<C>, Range<C>>>() {
|
return new AbstractIterator<Entry<Cut<C>, Range<C>>>() {
|
||||||
Cut<C> nextComplementRangeUpperBound = firstComplementRangeUpperBound;
|
Cut<C> nextComplementRangeUpperBound = firstComplementRangeUpperBound;
|
||||||
|
|
||||||
|
@ -530,10 +530,10 @@ public class TreeRangeSet<C extends Comparable<?>> extends AbstractRangeSet<C> {
|
||||||
if (complementLowerBoundWindow.lowerBound.isLessThan(negativeRange.lowerBound)) {
|
if (complementLowerBoundWindow.lowerBound.isLessThan(negativeRange.lowerBound)) {
|
||||||
return Maps.immutableEntry(negativeRange.lowerBound, negativeRange);
|
return Maps.immutableEntry(negativeRange.lowerBound, negativeRange);
|
||||||
}
|
}
|
||||||
} else if (complementLowerBoundWindow.lowerBound.isLessThan(Cut.<C>belowAll())) {
|
} else if (complementLowerBoundWindow.lowerBound.isLessThan(Cut.belowAll())) {
|
||||||
Range<C> negativeRange = Range.create(Cut.<C>belowAll(), nextComplementRangeUpperBound);
|
Range<C> negativeRange = Range.create(Cut.belowAll(), nextComplementRangeUpperBound);
|
||||||
nextComplementRangeUpperBound = Cut.belowAll();
|
nextComplementRangeUpperBound = Cut.belowAll();
|
||||||
return Maps.immutableEntry(Cut.<C>belowAll(), negativeRange);
|
return Maps.immutableEntry(Cut.belowAll(), negativeRange);
|
||||||
}
|
}
|
||||||
return endOfData();
|
return endOfData();
|
||||||
}
|
}
|
||||||
|
@ -649,7 +649,7 @@ public class TreeRangeSet<C extends Comparable<?>> extends AbstractRangeSet<C> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Comparator<? super Cut<C>> comparator() {
|
public Comparator<? super Cut<C>> comparator() {
|
||||||
return Ordering.<Cut<C>>natural();
|
return Ordering.natural();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -768,7 +768,7 @@ public class TreeRangeSet<C extends Comparable<?>> extends AbstractRangeSet<C> {
|
||||||
private final Range<C> restriction;
|
private final Range<C> restriction;
|
||||||
|
|
||||||
SubRangeSet(Range<C> restriction) {
|
SubRangeSet(Range<C> restriction) {
|
||||||
super(new SubRangeSetRangesByLowerBound<C>(Range.<Cut<C>>all(), restriction,
|
super(new SubRangeSetRangesByLowerBound<C>(Range.all(), restriction,
|
||||||
TreeRangeSet.this.rangesByLowerBound));
|
TreeRangeSet.this.rangesByLowerBound));
|
||||||
this.restriction = restriction;
|
this.restriction = restriction;
|
||||||
}
|
}
|
||||||
|
|
|
@ -263,16 +263,12 @@ public final class Escapers {
|
||||||
char[] output = new char[hiCount + loCount];
|
char[] output = new char[hiCount + loCount];
|
||||||
if (hiChars != null) {
|
if (hiChars != null) {
|
||||||
// TODO: Is this faster than System.arraycopy() for small arrays?
|
// TODO: Is this faster than System.arraycopy() for small arrays?
|
||||||
for (int n = 0; n < hiChars.length; ++n) {
|
System.arraycopy(hiChars, 0, output, 0, hiChars.length);
|
||||||
output[n] = hiChars[n];
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
output[0] = surrogateChars[0];
|
output[0] = surrogateChars[0];
|
||||||
}
|
}
|
||||||
if (loChars != null) {
|
if (loChars != null) {
|
||||||
for (int n = 0; n < loChars.length; ++n) {
|
System.arraycopy(loChars, 0, output, hiCount + 0, loChars.length);
|
||||||
output[hiCount + n] = loChars[n];
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
output[hiCount] = surrogateChars[1];
|
output[hiCount] = surrogateChars[1];
|
||||||
}
|
}
|
||||||
|
|
|
@ -133,7 +133,7 @@ final class Murmur3_128HashFunction extends AbstractStreamingHashFunction implem
|
||||||
case 10:
|
case 10:
|
||||||
k2 ^= (long) toInt(bb.get(9)) << 8; // fall through
|
k2 ^= (long) toInt(bb.get(9)) << 8; // fall through
|
||||||
case 9:
|
case 9:
|
||||||
k2 ^= (long) toInt(bb.get(8)); // fall through
|
k2 ^= toInt(bb.get(8)); // fall through
|
||||||
case 8:
|
case 8:
|
||||||
k1 ^= bb.getLong();
|
k1 ^= bb.getLong();
|
||||||
break;
|
break;
|
||||||
|
@ -150,7 +150,7 @@ final class Murmur3_128HashFunction extends AbstractStreamingHashFunction implem
|
||||||
case 2:
|
case 2:
|
||||||
k1 ^= (long) toInt(bb.get(1)) << 8; // fall through
|
k1 ^= (long) toInt(bb.get(1)) << 8; // fall through
|
||||||
case 1:
|
case 1:
|
||||||
k1 ^= (long) toInt(bb.get(0));
|
k1 ^= toInt(bb.get(0));
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
throw new AssertionError("Should never get here.");
|
throw new AssertionError("Should never get here.");
|
||||||
|
|
|
@ -16,14 +16,13 @@
|
||||||
|
|
||||||
package com.google.common.io;
|
package com.google.common.io;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
import java.io.Closeable;
|
import java.io.Closeable;
|
||||||
import java.io.Flushable;
|
import java.io.Flushable;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.Writer;
|
import java.io.Writer;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Writer that places all output on an {@link Appendable} target. If the target
|
* Writer that places all output on an {@link Appendable} target. If the target
|
||||||
|
@ -52,7 +51,7 @@ class AppendableWriter extends Writer {
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void write(char cbuf[], int off, int len) throws IOException {
|
public void write(char[] cbuf, int off, int len) throws IOException {
|
||||||
checkNotClosed();
|
checkNotClosed();
|
||||||
// It turns out that creating a new String is usually as fast, or faster
|
// It turns out that creating a new String is usually as fast, or faster
|
||||||
// than wrapping cbuf in a light-weight CharSequence.
|
// than wrapping cbuf in a light-weight CharSequence.
|
||||||
|
|
|
@ -35,10 +35,10 @@ import java.io.IOException;
|
||||||
*/
|
*/
|
||||||
public interface ByteArrayDataInput extends DataInput {
|
public interface ByteArrayDataInput extends DataInput {
|
||||||
@Override
|
@Override
|
||||||
void readFully(byte b[]);
|
void readFully(byte[] b);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
void readFully(byte b[], int off, int len);
|
void readFully(byte[] b, int off, int len);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
int skipBytes(int n);
|
int skipBytes(int n);
|
||||||
|
|
|
@ -31,10 +31,10 @@ public interface ByteArrayDataOutput extends DataOutput {
|
||||||
void write(int b);
|
void write(int b);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
void write(byte b[]);
|
void write(byte[] b);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
void write(byte b[], int off, int len);
|
void write(byte[] b, int off, int len);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
void writeBoolean(boolean v);
|
void writeBoolean(boolean v);
|
||||||
|
|
|
@ -16,16 +16,11 @@
|
||||||
|
|
||||||
package com.google.common.io;
|
package com.google.common.io;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import java.io.*;
|
||||||
|
|
||||||
import java.io.BufferedOutputStream;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.InputStream;
|
|
||||||
import java.io.OutputStream;
|
|
||||||
import java.io.OutputStreamWriter;
|
|
||||||
import java.io.Writer;
|
|
||||||
import java.nio.charset.Charset;
|
import java.nio.charset.Charset;
|
||||||
|
|
||||||
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A destination to which bytes can be written, such as a file. Unlike an
|
* A destination to which bytes can be written, such as a file. Unlike an
|
||||||
* {@link OutputStream}, a {@code ByteSink} is not an open, stateful stream that
|
* {@link OutputStream}, a {@code ByteSink} is not an open, stateful stream that
|
||||||
|
@ -174,7 +169,7 @@ public abstract class ByteSink implements OutputSupplier<OutputStream> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return ByteSink.this.toString() + ".asCharSink(" + charset + ")";
|
return ByteSink.this + ".asCharSink(" + charset + ")";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,19 +16,6 @@
|
||||||
|
|
||||||
package com.google.common.io;
|
package com.google.common.io;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkArgument;
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
|
||||||
|
|
||||||
import java.io.BufferedInputStream;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.InputStream;
|
|
||||||
import java.io.InputStreamReader;
|
|
||||||
import java.io.OutputStream;
|
|
||||||
import java.io.Reader;
|
|
||||||
import java.nio.charset.Charset;
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Iterator;
|
|
||||||
|
|
||||||
import com.google.common.annotations.Beta;
|
import com.google.common.annotations.Beta;
|
||||||
import com.google.common.base.Ascii;
|
import com.google.common.base.Ascii;
|
||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
|
@ -36,9 +23,16 @@ import com.google.common.hash.Funnels;
|
||||||
import com.google.common.hash.HashCode;
|
import com.google.common.hash.HashCode;
|
||||||
import com.google.common.hash.HashFunction;
|
import com.google.common.hash.HashFunction;
|
||||||
import com.google.common.hash.Hasher;
|
import com.google.common.hash.Hasher;
|
||||||
|
|
||||||
import net.lax1dude.eaglercraft.v1_8.EaglerInputStream;
|
import net.lax1dude.eaglercraft.v1_8.EaglerInputStream;
|
||||||
|
|
||||||
|
import java.io.*;
|
||||||
|
import java.nio.charset.Charset;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Iterator;
|
||||||
|
|
||||||
|
import static com.google.common.base.Preconditions.checkArgument;
|
||||||
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A readable source of bytes, such as a file. Unlike an {@link InputStream}, a
|
* A readable source of bytes, such as a file. Unlike an {@link InputStream}, a
|
||||||
* {@code ByteSource} is not an open, stateful stream for input that can be read
|
* {@code ByteSource} is not an open, stateful stream for input that can be read
|
||||||
|
@ -464,7 +458,7 @@ public abstract class ByteSource implements InputSupplier<InputStream> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return ByteSource.this.toString() + ".asCharSource(" + charset + ")";
|
return ByteSource.this + ".asCharSource(" + charset + ")";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -525,7 +519,7 @@ public abstract class ByteSource implements InputSupplier<InputStream> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return ByteSource.this.toString() + ".slice(" + offset + ", " + length + ")";
|
return ByteSource.this + ".slice(" + offset + ", " + length + ")";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -16,33 +16,21 @@
|
||||||
|
|
||||||
package com.google.common.io;
|
package com.google.common.io;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkArgument;
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
|
||||||
import static com.google.common.base.Preconditions.checkPositionIndex;
|
|
||||||
|
|
||||||
import java.io.ByteArrayOutputStream;
|
|
||||||
import java.io.DataInput;
|
|
||||||
import java.io.DataInputStream;
|
|
||||||
import java.io.DataOutput;
|
|
||||||
import java.io.DataOutputStream;
|
|
||||||
import java.io.EOFException;
|
|
||||||
import java.io.FilterInputStream;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.InputStream;
|
|
||||||
import java.io.OutputStream;
|
|
||||||
import java.nio.ByteBuffer;
|
|
||||||
import java.nio.channels.ReadableByteChannel;
|
|
||||||
import java.nio.channels.WritableByteChannel;
|
|
||||||
import java.util.Arrays;
|
|
||||||
|
|
||||||
import com.google.common.annotations.Beta;
|
import com.google.common.annotations.Beta;
|
||||||
import com.google.common.base.Function;
|
import com.google.common.base.Function;
|
||||||
import com.google.common.collect.Iterables;
|
import com.google.common.collect.Iterables;
|
||||||
import com.google.common.hash.HashCode;
|
import com.google.common.hash.HashCode;
|
||||||
import com.google.common.hash.HashFunction;
|
import com.google.common.hash.HashFunction;
|
||||||
|
|
||||||
import net.lax1dude.eaglercraft.v1_8.EaglerInputStream;
|
import net.lax1dude.eaglercraft.v1_8.EaglerInputStream;
|
||||||
|
|
||||||
|
import java.io.*;
|
||||||
|
import java.nio.ByteBuffer;
|
||||||
|
import java.nio.channels.ReadableByteChannel;
|
||||||
|
import java.nio.channels.WritableByteChannel;
|
||||||
|
import java.util.Arrays;
|
||||||
|
|
||||||
|
import static com.google.common.base.Preconditions.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides utility methods for working with byte arrays and I/O streams.
|
* Provides utility methods for working with byte arrays and I/O streams.
|
||||||
*
|
*
|
||||||
|
@ -320,7 +308,7 @@ public final class ByteStreams {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void readFully(byte b[]) {
|
public void readFully(byte[] b) {
|
||||||
try {
|
try {
|
||||||
input.readFully(b);
|
input.readFully(b);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
|
@ -329,7 +317,7 @@ public final class ByteStreams {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void readFully(byte b[], int off, int len) {
|
public void readFully(byte[] b, int off, int len) {
|
||||||
try {
|
try {
|
||||||
input.readFully(b, off, len);
|
input.readFully(b, off, len);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
|
|
|
@ -16,8 +16,14 @@
|
||||||
|
|
||||||
package com.google.common.io;
|
package com.google.common.io;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import com.google.common.annotations.Beta;
|
||||||
|
import com.google.common.base.Ascii;
|
||||||
|
import com.google.common.base.Splitter;
|
||||||
|
import com.google.common.collect.AbstractIterator;
|
||||||
|
import com.google.common.collect.ImmutableList;
|
||||||
|
import com.google.common.collect.Lists;
|
||||||
|
|
||||||
|
import javax.annotation.Nullable;
|
||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.Reader;
|
import java.io.Reader;
|
||||||
|
@ -27,14 +33,7 @@ import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
import com.google.common.annotations.Beta;
|
|
||||||
import com.google.common.base.Ascii;
|
|
||||||
import com.google.common.base.Splitter;
|
|
||||||
import com.google.common.collect.AbstractIterator;
|
|
||||||
import com.google.common.collect.ImmutableList;
|
|
||||||
import com.google.common.collect.Lists;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A readable source of characters, such as a text file. Unlike a
|
* A readable source of characters, such as a text file. Unlike a
|
||||||
|
@ -403,7 +402,7 @@ public abstract class CharSource implements InputSupplier<Reader> {
|
||||||
@Override
|
@Override
|
||||||
public Iterator<String> iterator() {
|
public Iterator<String> iterator() {
|
||||||
return new AbstractIterator<String>() {
|
return new AbstractIterator<String>() {
|
||||||
Iterator<String> lines = LINE_SPLITTER.split(seq).iterator();
|
final Iterator<String> lines = LINE_SPLITTER.split(seq).iterator();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected String computeNext() {
|
protected String computeNext() {
|
||||||
|
|
|
@ -33,7 +33,7 @@ import javax.annotation.Nullable;
|
||||||
*/
|
*/
|
||||||
final class MultiInputStream extends InputStream {
|
final class MultiInputStream extends InputStream {
|
||||||
|
|
||||||
private Iterator<? extends ByteSource> it;
|
private final Iterator<? extends ByteSource> it;
|
||||||
private InputStream in;
|
private InputStream in;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -50,7 +50,7 @@ class MultiReader extends Reader {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int read(@Nullable char cbuf[], int off, int len) throws IOException {
|
public int read(@Nullable char[] cbuf, int off, int len) throws IOException {
|
||||||
if (current == null) {
|
if (current == null) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -537,10 +537,10 @@ public final class IntMath {
|
||||||
return (n < factorials.length) ? factorials[n] : Integer.MAX_VALUE;
|
return (n < factorials.length) ? factorials[n] : Integer.MAX_VALUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final int[] factorials = { 1, 1, 1 * 2, 1 * 2 * 3, 1 * 2 * 3 * 4, 1 * 2 * 3 * 4 * 5,
|
private static final int[] factorials = {1, 1, 2, 2 * 3, 2 * 3 * 4, 2 * 3 * 4 * 5,
|
||||||
1 * 2 * 3 * 4 * 5 * 6, 1 * 2 * 3 * 4 * 5 * 6 * 7, 1 * 2 * 3 * 4 * 5 * 6 * 7 * 8,
|
2 * 3 * 4 * 5 * 6, 2 * 3 * 4 * 5 * 6 * 7, 2 * 3 * 4 * 5 * 6 * 7 * 8,
|
||||||
1 * 2 * 3 * 4 * 5 * 6 * 7 * 8 * 9, 1 * 2 * 3 * 4 * 5 * 6 * 7 * 8 * 9 * 10,
|
2 * 3 * 4 * 5 * 6 * 7 * 8 * 9, 2 * 3 * 4 * 5 * 6 * 7 * 8 * 9 * 10,
|
||||||
1 * 2 * 3 * 4 * 5 * 6 * 7 * 8 * 9 * 10 * 11, 1 * 2 * 3 * 4 * 5 * 6 * 7 * 8 * 9 * 10 * 11 * 12 };
|
2 * 3 * 4 * 5 * 6 * 7 * 8 * 9 * 10 * 11, 2 * 3 * 4 * 5 * 6 * 7 * 8 * 9 * 10 * 11 * 12};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns {@code n} choose {@code k}, also known as the binomial coefficient of
|
* Returns {@code n} choose {@code k}, also known as the binomial coefficient of
|
||||||
|
|
|
@ -615,18 +615,18 @@ public final class LongMath {
|
||||||
return (n < factorials.length) ? factorials[n] : Long.MAX_VALUE;
|
return (n < factorials.length) ? factorials[n] : Long.MAX_VALUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static final long[] factorials = { 1L, 1L, 1L * 2, 1L * 2 * 3, 1L * 2 * 3 * 4, 1L * 2 * 3 * 4 * 5,
|
static final long[] factorials = {1L, 1L, (long) 2, (long) 2 * 3, (long) 2 * 3 * 4, (long) 2 * 3 * 4 * 5,
|
||||||
1L * 2 * 3 * 4 * 5 * 6, 1L * 2 * 3 * 4 * 5 * 6 * 7, 1L * 2 * 3 * 4 * 5 * 6 * 7 * 8,
|
(long) 2 * 3 * 4 * 5 * 6, (long) 2 * 3 * 4 * 5 * 6 * 7, (long) 2 * 3 * 4 * 5 * 6 * 7 * 8,
|
||||||
1L * 2 * 3 * 4 * 5 * 6 * 7 * 8 * 9, 1L * 2 * 3 * 4 * 5 * 6 * 7 * 8 * 9 * 10,
|
(long) 2 * 3 * 4 * 5 * 6 * 7 * 8 * 9, (long) 2 * 3 * 4 * 5 * 6 * 7 * 8 * 9 * 10,
|
||||||
1L * 2 * 3 * 4 * 5 * 6 * 7 * 8 * 9 * 10 * 11, 1L * 2 * 3 * 4 * 5 * 6 * 7 * 8 * 9 * 10 * 11 * 12,
|
(long) 2 * 3 * 4 * 5 * 6 * 7 * 8 * 9 * 10 * 11, (long) 2 * 3 * 4 * 5 * 6 * 7 * 8 * 9 * 10 * 11 * 12,
|
||||||
1L * 2 * 3 * 4 * 5 * 6 * 7 * 8 * 9 * 10 * 11 * 12 * 13,
|
(long) 2 * 3 * 4 * 5 * 6 * 7 * 8 * 9 * 10 * 11 * 12 * 13,
|
||||||
1L * 2 * 3 * 4 * 5 * 6 * 7 * 8 * 9 * 10 * 11 * 12 * 13 * 14,
|
(long) 2 * 3 * 4 * 5 * 6 * 7 * 8 * 9 * 10 * 11 * 12 * 13 * 14,
|
||||||
1L * 2 * 3 * 4 * 5 * 6 * 7 * 8 * 9 * 10 * 11 * 12 * 13 * 14 * 15,
|
(long) 2 * 3 * 4 * 5 * 6 * 7 * 8 * 9 * 10 * 11 * 12 * 13 * 14 * 15,
|
||||||
1L * 2 * 3 * 4 * 5 * 6 * 7 * 8 * 9 * 10 * 11 * 12 * 13 * 14 * 15 * 16,
|
(long) 2 * 3 * 4 * 5 * 6 * 7 * 8 * 9 * 10 * 11 * 12 * 13 * 14 * 15 * 16,
|
||||||
1L * 2 * 3 * 4 * 5 * 6 * 7 * 8 * 9 * 10 * 11 * 12 * 13 * 14 * 15 * 16 * 17,
|
(long) 2 * 3 * 4 * 5 * 6 * 7 * 8 * 9 * 10 * 11 * 12 * 13 * 14 * 15 * 16 * 17,
|
||||||
1L * 2 * 3 * 4 * 5 * 6 * 7 * 8 * 9 * 10 * 11 * 12 * 13 * 14 * 15 * 16 * 17 * 18,
|
(long) 2 * 3 * 4 * 5 * 6 * 7 * 8 * 9 * 10 * 11 * 12 * 13 * 14 * 15 * 16 * 17 * 18,
|
||||||
1L * 2 * 3 * 4 * 5 * 6 * 7 * 8 * 9 * 10 * 11 * 12 * 13 * 14 * 15 * 16 * 17 * 18 * 19,
|
(long) 2 * 3 * 4 * 5 * 6 * 7 * 8 * 9 * 10 * 11 * 12 * 13 * 14 * 15 * 16 * 17 * 18 * 19,
|
||||||
1L * 2 * 3 * 4 * 5 * 6 * 7 * 8 * 9 * 10 * 11 * 12 * 13 * 14 * 15 * 16 * 17 * 18 * 19 * 20 };
|
(long) 2 * 3 * 4 * 5 * 6 * 7 * 8 * 9 * 10 * 11 * 12 * 13 * 14 * 15 * 16 * 17 * 18 * 19 * 20};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns {@code n} choose {@code k}, also known as the binomial coefficient of
|
* Returns {@code n} choose {@code k}, also known as the binomial coefficient of
|
||||||
|
|
|
@ -35,7 +35,7 @@ enum PublicSuffixType {
|
||||||
/** The character used for a leaf node in the trie encoding */
|
/** The character used for a leaf node in the trie encoding */
|
||||||
private final char leafNodeCode;
|
private final char leafNodeCode;
|
||||||
|
|
||||||
private PublicSuffixType(char innerNodeCode, char leafNodeCode) {
|
PublicSuffixType(char innerNodeCode, char leafNodeCode) {
|
||||||
this.innerNodeCode = innerNodeCode;
|
this.innerNodeCode = innerNodeCode;
|
||||||
this.leafNodeCode = leafNodeCode;
|
this.leafNodeCode = leafNodeCode;
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,7 +40,7 @@ class TrieParser {
|
||||||
int encodedLen = encoded.length();
|
int encodedLen = encoded.length();
|
||||||
int idx = 0;
|
int idx = 0;
|
||||||
while (idx < encodedLen) {
|
while (idx < encodedLen) {
|
||||||
idx += doParseTrieToBuilder(Lists.<CharSequence>newLinkedList(), encoded.subSequence(idx, encodedLen),
|
idx += doParseTrieToBuilder(Lists.newLinkedList(), encoded.subSequence(idx, encodedLen),
|
||||||
builder);
|
builder);
|
||||||
}
|
}
|
||||||
return builder.build();
|
return builder.build();
|
||||||
|
|
|
@ -1,13 +0,0 @@
|
||||||
package dev.resent.event.impl;
|
|
||||||
|
|
||||||
import net.minecraft.network.play.server.S19PacketEntityStatus;
|
|
||||||
|
|
||||||
public class EntityStatusEvent extends Event{
|
|
||||||
|
|
||||||
public byte status;
|
|
||||||
|
|
||||||
public EntityStatusEvent(S19PacketEntityStatus event){
|
|
||||||
this.status = event.logicOpcode;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,13 +0,0 @@
|
||||||
package dev.resent.event.impl;
|
|
||||||
|
|
||||||
public class RenderWorldEvent extends Event{
|
|
||||||
private final float partialTicks;
|
|
||||||
|
|
||||||
public RenderWorldEvent(float partialTicks) {
|
|
||||||
this.partialTicks = partialTicks;
|
|
||||||
}
|
|
||||||
|
|
||||||
public float getPartialTicks() {
|
|
||||||
return partialTicks;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -63,7 +63,7 @@ public class ModManager {
|
||||||
public static AutoGG autoGG;
|
public static AutoGG autoGG;
|
||||||
public static AutoRespawn autoRespawn;
|
public static AutoRespawn autoRespawn;
|
||||||
public static Freelook freelook;
|
public static Freelook freelook;
|
||||||
public static ComboCounter comboCounter;
|
public static ComboCounter comboCounter = new ComboCounter();
|
||||||
public static Hitboxes hitboxes = new Hitboxes();
|
public static Hitboxes hitboxes = new Hitboxes();
|
||||||
public static Health health;
|
public static Health health;
|
||||||
//public static ChunkBorders chunkBorders;
|
//public static ChunkBorders chunkBorders;
|
||||||
|
@ -100,7 +100,7 @@ public class ModManager {
|
||||||
register(cps = new CPS());
|
register(cps = new CPS());
|
||||||
register(potionHud = new PotionHUD());
|
register(potionHud = new PotionHUD());
|
||||||
register(reachDisplay = new ReachDisplay());
|
register(reachDisplay = new ReachDisplay());
|
||||||
register(comboCounter = new ComboCounter());
|
register(comboCounter);
|
||||||
register(coordinate = new Info());
|
register(coordinate = new Info());
|
||||||
register(fps = new FPS());
|
register(fps = new FPS());
|
||||||
register(health = new Health());
|
register(health = new Health());
|
||||||
|
|
|
@ -1,14 +1,14 @@
|
||||||
package dev.resent.module.impl.hud;
|
package dev.resent.module.impl.hud;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import dev.resent.module.base.Category;
|
import dev.resent.module.base.Category;
|
||||||
import dev.resent.module.base.RenderModule;
|
import dev.resent.module.base.RenderModule;
|
||||||
import dev.resent.setting.BooleanSetting;
|
import dev.resent.setting.BooleanSetting;
|
||||||
import dev.resent.util.misc.FuncUtils;
|
import dev.resent.util.misc.FuncUtils;
|
||||||
import net.lax1dude.eaglercraft.v1_8.Mouse;
|
import net.lax1dude.eaglercraft.v1_8.Mouse;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public class CPS extends RenderModule {
|
public class CPS extends RenderModule {
|
||||||
|
|
||||||
public CPS() {
|
public CPS() {
|
||||||
|
@ -16,7 +16,7 @@ public class CPS extends RenderModule {
|
||||||
addSetting(tshadow);
|
addSetting(tshadow);
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<Long> clicks = new ArrayList<>();
|
private final List<Long> clicks = new ArrayList<>();
|
||||||
private boolean wasPressed;
|
private boolean wasPressed;
|
||||||
private long lastPressed;
|
private long lastPressed;
|
||||||
|
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
package dev.resent.module.impl.hud;
|
package dev.resent.module.impl.hud;
|
||||||
|
|
||||||
import dev.resent.Resent;
|
import dev.resent.Resent;
|
||||||
import dev.resent.event.impl.EntityStatusEvent;
|
|
||||||
import dev.resent.event.impl.EventAttack;
|
import dev.resent.event.impl.EventAttack;
|
||||||
import dev.resent.module.base.Category;
|
import dev.resent.module.base.Category;
|
||||||
import dev.resent.module.base.RenderModule;
|
import dev.resent.module.base.RenderModule;
|
||||||
import dev.resent.setting.BooleanSetting;
|
import dev.resent.setting.BooleanSetting;
|
||||||
|
import net.minecraft.network.play.server.S19PacketEntityStatus;
|
||||||
|
|
||||||
public class ComboCounter extends RenderModule {
|
public class ComboCounter extends RenderModule {
|
||||||
|
|
||||||
|
@ -17,27 +17,33 @@ public class ComboCounter extends RenderModule {
|
||||||
public ComboCounter() {
|
public ComboCounter() {
|
||||||
super("ComboCounter", Category.HUD, 4, 4, true);
|
super("ComboCounter", Category.HUD, 4, 4, true);
|
||||||
addSetting(tshadow);
|
addSetting(tshadow);
|
||||||
Resent.INSTANCE.events().subscribe(EntityStatusEvent.class, event -> {
|
|
||||||
if(this.isEnabled() && attacked && event.status == 2){
|
|
||||||
combo++;
|
|
||||||
attacked = false;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
Resent.INSTANCE.events().subscribe(EventAttack.class, event -> {
|
Resent.INSTANCE.events().subscribe(EventAttack.class, event -> {
|
||||||
if(this.isEnabled()){
|
if (this.isEnabled()) {
|
||||||
attacked = true;
|
attacked = true;
|
||||||
lastAttack = System.nanoTime();
|
lastAttack = System.nanoTime();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getWidth(){ return mc.fontRendererObj.getStringWidth("[0 Combo]") + 4; }
|
public void onEntityHit(S19PacketEntityStatus event) {
|
||||||
public int getHeight(){ return mc.fontRendererObj.FONT_HEIGHT + 4; }
|
if (this.isEnabled() && attacked && event.logicOpcode == 2) {
|
||||||
|
combo++;
|
||||||
|
attacked = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getWidth() {
|
||||||
|
return mc.fontRendererObj.getStringWidth("[0 Combo]") + 4;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getHeight() {
|
||||||
|
return mc.fontRendererObj.FONT_HEIGHT + 4;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void draw() {
|
public void draw() {
|
||||||
if(mc.thePlayer.hurtTime > 3 || System.nanoTime() - lastAttack >= 3.0E9 && this.enabled){
|
if (mc.thePlayer.hurtTime > 3 || System.nanoTime() - lastAttack >= 3.0E9 && this.enabled) {
|
||||||
combo = 0;
|
combo = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -17,8 +17,13 @@ public class Info extends RenderModule{
|
||||||
public BooleanSetting direction = new BooleanSetting("Direction", "", true);
|
public BooleanSetting direction = new BooleanSetting("Direction", "", true);
|
||||||
public static int yes = 6;
|
public static int yes = 6;
|
||||||
|
|
||||||
public int getWidth(){ return mc.fontRendererObj.getStringWidth("X: -99999999 + "); }
|
public int getWidth() {
|
||||||
public int getHeight() { return mc.fontRendererObj.FONT_HEIGHT * yes; };
|
return mc.fontRendererObj.getStringWidth("X: -99999999 + ");
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getHeight() {
|
||||||
|
return mc.fontRendererObj.FONT_HEIGHT * yes;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void draw() {
|
public void draw() {
|
||||||
|
|
|
@ -18,7 +18,7 @@ import net.minecraft.client.gui.Gui;
|
||||||
public class KeyStrokes extends RenderModule{
|
public class KeyStrokes extends RenderModule{
|
||||||
|
|
||||||
public static KeyStrokes INSTANCE = new KeyStrokes();
|
public static KeyStrokes INSTANCE = new KeyStrokes();
|
||||||
private Minecraft mc = Minecraft.getMinecraft();
|
private final Minecraft mc = Minecraft.getMinecraft();
|
||||||
|
|
||||||
public KeyStrokes(){
|
public KeyStrokes(){
|
||||||
super("Keystrokes", Category.HUD, 25, 4, true);
|
super("Keystrokes", Category.HUD, 25, 4, true);
|
||||||
|
@ -40,7 +40,7 @@ public class KeyStrokes extends RenderModule{
|
||||||
public List<Long> clicks = new ArrayList<>();
|
public List<Long> clicks = new ArrayList<>();
|
||||||
public boolean wasPressed;
|
public boolean wasPressed;
|
||||||
public long lastPressed;
|
public long lastPressed;
|
||||||
private List<Long> clicks2 = new ArrayList<>();
|
private final List<Long> clicks2 = new ArrayList<>();
|
||||||
public boolean wasPressed2;
|
public boolean wasPressed2;
|
||||||
public long lastPressed2;
|
public long lastPressed2;
|
||||||
|
|
||||||
|
|
|
@ -169,11 +169,11 @@ public class Color {
|
||||||
rangeError = true;
|
rangeError = true;
|
||||||
badComponentString = badComponentString + " Green";
|
badComponentString = badComponentString + " Green";
|
||||||
}
|
}
|
||||||
if ( b < 0 || b > 255) {
|
if (b < 0 || b > 255) {
|
||||||
rangeError = true;
|
rangeError = true;
|
||||||
badComponentString = badComponentString + " Blue";
|
badComponentString = badComponentString + " Blue";
|
||||||
}
|
}
|
||||||
if ( rangeError == true ) {
|
if (rangeError) {
|
||||||
throw new IllegalArgumentException("Color parameter outside of expected range:"
|
throw new IllegalArgumentException("Color parameter outside of expected range:"
|
||||||
+ badComponentString);
|
+ badComponentString);
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,7 @@ package dev.resent.util.render;
|
||||||
|
|
||||||
public class RainbowUtil {
|
public class RainbowUtil {
|
||||||
public static int getRainbow(float seconds,float saturation, float brightness) {
|
public static int getRainbow(float seconds,float saturation, float brightness) {
|
||||||
float hue = (System.currentTimeMillis()) % (int)(seconds*1000) / (float)(seconds*1000);
|
float hue = (System.currentTimeMillis()) % (int) (seconds * 1000) / (seconds * 1000);
|
||||||
int color = Color.HSBtoRGB(hue, saturation, brightness);
|
int color = Color.HSBtoRGB(hue, saturation, brightness);
|
||||||
return color;
|
return color;
|
||||||
}
|
}
|
||||||
|
|
|
@ -71,5 +71,5 @@ public @interface ManagedBean {
|
||||||
* java:module/<bean-name>
|
* java:module/<bean-name>
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public String value() default "";
|
String value() default "";
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,7 +25,7 @@ public @interface MatchesPattern {
|
||||||
|
|
||||||
int flags() default 0;
|
int flags() default 0;
|
||||||
|
|
||||||
static class Checker implements TypeQualifierValidator<MatchesPattern> {
|
class Checker implements TypeQualifierValidator<MatchesPattern> {
|
||||||
public When forConstantValue(MatchesPattern annotation, Object value) {
|
public When forConstantValue(MatchesPattern annotation, Object value) {
|
||||||
Pattern p = Pattern.compile(annotation.value(), annotation.flags());
|
Pattern p = Pattern.compile(annotation.value(), annotation.flags());
|
||||||
if (p.matcher(((String) value)).matches())
|
if (p.matcher(((String) value)).matches())
|
||||||
|
|
|
@ -24,7 +24,7 @@ import javax.annotation.meta.When;
|
||||||
public @interface RegEx {
|
public @interface RegEx {
|
||||||
When when() default When.ALWAYS;
|
When when() default When.ALWAYS;
|
||||||
|
|
||||||
static class Checker implements TypeQualifierValidator<RegEx> {
|
class Checker implements TypeQualifierValidator<RegEx> {
|
||||||
|
|
||||||
public When forConstantValue(RegEx annotation, Object value) {
|
public When forConstantValue(RegEx annotation, Object value) {
|
||||||
if (!(value instanceof String))
|
if (!(value instanceof String))
|
||||||
|
|
|
@ -14,5 +14,6 @@ public interface TypeQualifierValidator<A extends Annotation> {
|
||||||
* @return a value indicating whether or not the value is an member of the
|
* @return a value indicating whether or not the value is an member of the
|
||||||
* values denoted by the type qualifier
|
* values denoted by the type qualifier
|
||||||
*/
|
*/
|
||||||
public @Nonnull When forConstantValue(@Nonnull A annotation, Object value);
|
@Nonnull
|
||||||
|
When forConstantValue(@Nonnull A annotation, Object value);
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,6 +18,6 @@ public enum When {
|
||||||
/** S intersection T is non empty and S - T is nonempty */
|
/** S intersection T is non empty and S - T is nonempty */
|
||||||
MAYBE,
|
MAYBE,
|
||||||
/** S intersection T is empty */
|
/** S intersection T is empty */
|
||||||
NEVER;
|
NEVER
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -122,9 +122,7 @@ public interface EventBus<E> {
|
||||||
static <E> Accepts<E> nonCancelledWhenNotAcceptingCancelled() {
|
static <E> Accepts<E> nonCancelledWhenNotAcceptingCancelled() {
|
||||||
return (type, event, subscriber) -> {
|
return (type, event, subscriber) -> {
|
||||||
if (!subscriber.acceptsCancelled()) {
|
if (!subscriber.acceptsCancelled()) {
|
||||||
if (event instanceof Cancellable && ((Cancellable) event).isCancelled()) {
|
return !(event instanceof Cancellable) || !((Cancellable) event).isCancelled();
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user