CrackMe.apk
Download file
package com.google.common.collect;
import com.google.common.base.Function;
import com.google.common.base.Preconditions;
import com.google.common.base.Predicate;
import com.google.common.base.Predicates;
import com.google.common.math.IntMath;
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 java.util.Objects;
import javax.annotation.CheckForNull;
import org.apache.commons.io.FileUtils;
@ElementTypesAreNonnullByDefault
public final class Collections2 {
private Collections2() {
}
public static <E> Collection<E> filter(Collection<E> collection, Predicate<? super E> predicate) {
if (collection instanceof FilteredCollection) {
return ((FilteredCollection) collection).createCombined(predicate);
}
return new FilteredCollection((Collection) Preconditions.checkNotNull(collection), (Predicate) Preconditions.checkNotNull(predicate));
}
static boolean safeContains(Collection<?> collection, @CheckForNull Object obj) {
Preconditions.checkNotNull(collection);
try {
return collection.contains(obj);
} catch (ClassCastException | NullPointerException unused) {
return false;
}
}
static boolean safeRemove(Collection<?> collection, @CheckForNull Object obj) {
Preconditions.checkNotNull(collection);
try {
return collection.remove(obj);
} catch (ClassCastException | NullPointerException unused) {
return false;
}
}
static class FilteredCollection<E> extends AbstractCollection<E> {
final Predicate<? super E> predicate;
final Collection<E> unfiltered;
FilteredCollection(Collection<E> collection, Predicate<? super E> predicate2) {
this.unfiltered = collection;
this.predicate = predicate2;
}
/* access modifiers changed from: package-private */
public FilteredCollection<E> createCombined(Predicate<? super E> predicate2) {
return new FilteredCollection<>(this.unfiltered, Predicates.and(this.predicate, predicate2));
}
public boolean add(@ParametricNullness E e) {
Preconditions.checkArgument(this.predicate.apply(e));
return this.unfiltered.add(e);
}
public boolean addAll(Collection<? extends E> collection) {
for (Object apply : collection) {
Preconditions.checkArgument(this.predicate.apply(apply));
}
return this.unfiltered.addAll(collection);
}
public void clear() {
Iterables.removeIf(this.unfiltered, this.predicate);
}
public boolean contains(@CheckForNull Object obj) {
if (Collections2.safeContains(this.unfiltered, obj)) {
return this.predicate.apply(obj);
}
return false;
}
public boolean containsAll(Collection<?> collection) {
return Collections2.containsAllImpl(this, collection);
}
public boolean isEmpty() {
return !Iterables.any(this.unfiltered, this.predicate);
}
public Iterator<E> iterator() {
return Iterators.filter(this.unfiltered.iterator(), this.predicate);
}
public boolean remove(@CheckForNull Object obj) {
return contains(obj) && this.unfiltered.remove(obj);
}
public boolean removeAll(Collection<?> collection) {
Iterator<E> it = this.unfiltered.iterator();
boolean z = false;
while (it.hasNext()) {
E next = it.next();
if (this.predicate.apply(next) && collection.contains(next)) {
it.remove();
z = true;
}
}
return z;
}
public boolean retainAll(Collection<?> collection) {
Iterator<E> it = this.unfiltered.iterator();
boolean z = false;
while (it.hasNext()) {
E next = it.next();
if (this.predicate.apply(next) && !collection.contains(next)) {
it.remove();
z = true;
}
}
return z;
}
public int size() {
int i = 0;
for (E apply : this.unfiltered) {
if (this.predicate.apply(apply)) {
i++;
}
}
return i;
}
public Object[] toArray() {
return Lists.newArrayList(iterator()).toArray();
}
public <T> T[] toArray(T[] tArr) {
return Lists.newArrayList(iterator()).toArray(tArr);
}
}
public static <F, T> Collection<T> transform(Collection<F> collection, Function<? super F, T> function) {
return new TransformedCollection(collection, function);
}
static class TransformedCollection<F, T> extends AbstractCollection<T> {
final Collection<F> fromCollection;
final Function<? super F, ? extends T> function;
TransformedCollection(Collection<F> collection, Function<? super F, ? extends T> function2) {
this.fromCollection = (Collection) Preconditions.checkNotNull(collection);
this.function = (Function) Preconditions.checkNotNull(function2);
}
public void clear() {
this.fromCollection.clear();
}
public boolean isEmpty() {
return this.fromCollection.isEmpty();
}
public Iterator<T> iterator() {
return Iterators.transform(this.fromCollection.iterator(), this.function);
}
public int size() {
return this.fromCollection.size();
}
}
static boolean containsAllImpl(Collection<?> collection, Collection<?> collection2) {
for (Object contains : collection2) {
if (!collection.contains(contains)) {
return false;
}
}
return true;
}
static String toStringImpl(Collection<?> collection) {
StringBuilder newStringBuilderForCollection = newStringBuilderForCollection(collection.size());
newStringBuilderForCollection.append('[');
boolean z = true;
for (Object next : collection) {
if (!z) {
newStringBuilderForCollection.append(", ");
}
z = false;
if (next == collection) {
newStringBuilderForCollection.append("(this Collection)");
} else {
newStringBuilderForCollection.append(next);
}
}
newStringBuilderForCollection.append(']');
return newStringBuilderForCollection.toString();
}
static StringBuilder newStringBuilderForCollection(int i) {
CollectPreconditions.checkNonnegative(i, "size");
return new StringBuilder((int) Math.min(((long) i) * 8, FileUtils.ONE_GB));
}
public static <E extends Comparable<? super E>> Collection<List<E>> orderedPermutations(Iterable<E> iterable) {
return orderedPermutations(iterable, Ordering.natural());
}
public static <E> Collection<List<E>> orderedPermutations(Iterable<E> iterable, Comparator<? super E> comparator) {
return new OrderedPermutationCollection(iterable, comparator);
}
private static final class OrderedPermutationCollection<E> extends AbstractCollection<List<E>> {
final Comparator<? super E> comparator;
final ImmutableList<E> inputList;
final int size;
public boolean isEmpty() {
return false;
}
OrderedPermutationCollection(Iterable<E> iterable, Comparator<? super E> comparator2) {
ImmutableList<E> sortedCopyOf = ImmutableList.sortedCopyOf(comparator2, iterable);
this.inputList = sortedCopyOf;
this.comparator = comparator2;
this.size = calculateSize(sortedCopyOf, comparator2);
}
private static <E> int calculateSize(List<E> list, Comparator<? super E> comparator2) {
int i = 1;
int i2 = 1;
int i3 = 1;
while (i < list.size()) {
if (comparator2.compare(list.get(i - 1), list.get(i)) < 0) {
i2 = IntMath.saturatedMultiply(i2, IntMath.binomial(i, i3));
i3 = 0;
if (i2 == Integer.MAX_VALUE) {
return Integer.MAX_VALUE;
}
}
i++;
i3++;
}
return IntMath.saturatedMultiply(i2, IntMath.binomial(i, i3));
}
public int size() {
return this.size;
}
public Iterator<List<E>> iterator() {
return new OrderedPermutationIterator(this.inputList, this.comparator);
}
public boolean contains(@CheckForNull Object obj) {
if (!(obj instanceof List)) {
return false;
}
return Collections2.isPermutation(this.inputList, (List) obj);
}
public String toString() {
String valueOf = String.valueOf(this.inputList);
StringBuilder sb = new StringBuilder(String.valueOf(valueOf).length() + 30);
sb.append("orderedPermutationCollection(");
sb.append(valueOf);
sb.append(")");
return sb.toString();
}
}
private static final class OrderedPermutationIterator<E> extends AbstractIterator<List<E>> {
final Comparator<? super E> comparator;
@CheckForNull
List<E> nextPermutation;
OrderedPermutationIterator(List<E> list, Comparator<? super E> comparator2) {
this.nextPermutation = Lists.newArrayList(list);
this.comparator = comparator2;
}
/* access modifiers changed from: protected */
@CheckForNull
public List<E> computeNext() {
List<E> list = this.nextPermutation;
if (list == null) {
return (List) endOfData();
}
ImmutableList<E> copyOf = ImmutableList.copyOf(list);
calculateNextPermutation();
return copyOf;
}
/* access modifiers changed from: package-private */
public void calculateNextPermutation() {
int findNextJ = findNextJ();
if (findNextJ == -1) {
this.nextPermutation = null;
return;
}
Objects.requireNonNull(this.nextPermutation);
Collections.swap(this.nextPermutation, findNextJ, findNextL(findNextJ));
Collections.reverse(this.nextPermutation.subList(findNextJ + 1, this.nextPermutation.size()));
}
/* access modifiers changed from: package-private */
public int findNextJ() {
Objects.requireNonNull(this.nextPermutation);
for (int size = this.nextPermutation.size() - 2; size >= 0; size--) {
if (this.comparator.compare(this.nextPermutation.get(size), this.nextPermutation.get(size + 1)) < 0) {
return size;
}
}
return -1;
}
/* access modifiers changed from: package-private */
public int findNextL(int i) {
Objects.requireNonNull(this.nextPermutation);
E e = this.nextPermutation.get(i);
for (int size = this.nextPermutation.size() - 1; size > i; size--) {
if (this.comparator.compare(e, this.nextPermutation.get(size)) < 0) {
return size;
}
}
throw new AssertionError("this statement should be unreachable");
}
}
public static <E> Collection<List<E>> permutations(Collection<E> collection) {
return new PermutationCollection(ImmutableList.copyOf(collection));
}
private static final class PermutationCollection<E> extends AbstractCollection<List<E>> {
final ImmutableList<E> inputList;
public boolean isEmpty() {
return false;
}
PermutationCollection(ImmutableList<E> immutableList) {
this.inputList = immutableList;
}
public int size() {
return IntMath.factorial(this.inputList.size());
}
public Iterator<List<E>> iterator() {
return new PermutationIterator(this.inputList);
}
public boolean contains(@CheckForNull Object obj) {
if (!(obj instanceof List)) {
return false;
}
return Collections2.isPermutation(this.inputList, (List) obj);
}
public String toString() {
String valueOf = String.valueOf(this.inputList);
StringBuilder sb = new StringBuilder(String.valueOf(valueOf).length() + 14);
sb.append("permutations(");
sb.append(valueOf);
sb.append(")");
return sb.toString();
}
}
private static class PermutationIterator<E> extends AbstractIterator<List<E>> {
final int[] c;
int j = Integer.MAX_VALUE;
final List<E> list;
final int[] o;
PermutationIterator(List<E> list2) {
this.list = new ArrayList(list2);
int size = list2.size();
int[] iArr = new int[size];
this.c = iArr;
int[] iArr2 = new int[size];
this.o = iArr2;
Arrays.fill(iArr, 0);
Arrays.fill(iArr2, 1);
}
/* access modifiers changed from: protected */
@CheckForNull
public List<E> computeNext() {
if (this.j <= 0) {
return (List) endOfData();
}
ImmutableList<E> copyOf = ImmutableList.copyOf(this.list);
calculateNextPermutation();
return copyOf;
}
/* access modifiers changed from: package-private */
public void calculateNextPermutation() {
int size = this.list.size() - 1;
this.j = size;
if (size != -1) {
int i = 0;
while (true) {
int[] iArr = this.c;
int i2 = this.j;
int i3 = iArr[i2] + this.o[i2];
if (i3 < 0) {
switchDirection();
} else if (i3 != i2 + 1) {
Collections.swap(this.list, (i2 - iArr[i2]) + i, (i2 - i3) + i);
this.c[this.j] = i3;
return;
} else if (i2 != 0) {
i++;
switchDirection();
} else {
return;
}
}
}
}
/* access modifiers changed from: package-private */
public void switchDirection() {
int[] iArr = this.o;
int i = this.j;
iArr[i] = -iArr[i];
this.j = i - 1;
}
}
/* access modifiers changed from: private */
public static boolean isPermutation(List<?> list, List<?> list2) {
if (list.size() != list2.size()) {
return false;
}
ObjectCountHashMap<?> counts = counts(list);
ObjectCountHashMap<?> counts2 = counts(list2);
if (list.size() != list2.size()) {
return false;
}
for (int i = 0; i < list.size(); i++) {
if (counts.getValue(i) != counts2.get(counts.getKey(i))) {
return false;
}
}
return true;
}
private static <E> ObjectCountHashMap<E> counts(Collection<E> collection) {
ObjectCountHashMap<E> objectCountHashMap = new ObjectCountHashMap<>();
for (E next : collection) {
objectCountHashMap.put(next, objectCountHashMap.get(next) + 1);
}
return objectCountHashMap;
}
}
Download file