176 lines
		
	
	
		
			5.6 KiB
		
	
	
	
		
			Java
		
	
	
	
	
	
			
		
		
	
	
			176 lines
		
	
	
		
			5.6 KiB
		
	
	
	
		
			Java
		
	
	
	
	
	
| package com.google.common.collect;
 | |
| 
 | |
| import com.google.common.base.Preconditions;
 | |
| import java.io.Serializable;
 | |
| import java.util.AbstractSet;
 | |
| import java.util.Collection;
 | |
| import java.util.Collections;
 | |
| import java.util.HashSet;
 | |
| import java.util.Iterator;
 | |
| import java.util.LinkedHashSet;
 | |
| import java.util.NavigableSet;
 | |
| import java.util.Set;
 | |
| import java.util.SortedSet;
 | |
| 
 | |
| /* loaded from: classes.dex */
 | |
| public final class Sets {
 | |
| 
 | |
|     static abstract class ImprovedAbstractSet<E> extends AbstractSet<E> {
 | |
|         ImprovedAbstractSet() {
 | |
|         }
 | |
| 
 | |
|         @Override // java.util.AbstractSet, java.util.AbstractCollection, java.util.Collection, java.util.Set
 | |
|         public boolean removeAll(Collection<?> collection) {
 | |
|             return Sets.a((Set<?>) this, collection);
 | |
|         }
 | |
| 
 | |
|         @Override // java.util.AbstractCollection, java.util.Collection, java.util.Set
 | |
|         public boolean retainAll(Collection<?> collection) {
 | |
|             Preconditions.a(collection);
 | |
|             return super.retainAll(collection);
 | |
|         }
 | |
|     }
 | |
| 
 | |
|     public static <E> HashSet<E> a() {
 | |
|         return new HashSet<>();
 | |
|     }
 | |
| 
 | |
|     public static <E> LinkedHashSet<E> b(int i) {
 | |
|         return new LinkedHashSet<>(Maps.a(i));
 | |
|     }
 | |
| 
 | |
|     public static <E> HashSet<E> a(int i) {
 | |
|         return new HashSet<>(Maps.a(i));
 | |
|     }
 | |
| 
 | |
|     static final class UnmodifiableNavigableSet<E> extends ForwardingSortedSet<E> implements NavigableSet<E>, Serializable {
 | |
|         private final NavigableSet<E> a;
 | |
|         private transient UnmodifiableNavigableSet<E> b;
 | |
| 
 | |
|         UnmodifiableNavigableSet(NavigableSet<E> navigableSet) {
 | |
|             Preconditions.a(navigableSet);
 | |
|             this.a = navigableSet;
 | |
|         }
 | |
| 
 | |
|         @Override // java.util.NavigableSet
 | |
|         public E ceiling(E e) {
 | |
|             return this.a.ceiling(e);
 | |
|         }
 | |
| 
 | |
|         @Override // java.util.NavigableSet
 | |
|         public Iterator<E> descendingIterator() {
 | |
|             return Iterators.j(this.a.descendingIterator());
 | |
|         }
 | |
| 
 | |
|         @Override // java.util.NavigableSet
 | |
|         public NavigableSet<E> descendingSet() {
 | |
|             UnmodifiableNavigableSet<E> unmodifiableNavigableSet = this.b;
 | |
|             if (unmodifiableNavigableSet != null) {
 | |
|                 return unmodifiableNavigableSet;
 | |
|             }
 | |
|             UnmodifiableNavigableSet<E> unmodifiableNavigableSet2 = new UnmodifiableNavigableSet<>(this.a.descendingSet());
 | |
|             this.b = unmodifiableNavigableSet2;
 | |
|             unmodifiableNavigableSet2.b = this;
 | |
|             return unmodifiableNavigableSet2;
 | |
|         }
 | |
| 
 | |
|         @Override // java.util.NavigableSet
 | |
|         public E floor(E e) {
 | |
|             return this.a.floor(e);
 | |
|         }
 | |
| 
 | |
|         @Override // java.util.NavigableSet
 | |
|         public NavigableSet<E> headSet(E e, boolean z) {
 | |
|             return Sets.a((NavigableSet) this.a.headSet(e, z));
 | |
|         }
 | |
| 
 | |
|         @Override // java.util.NavigableSet
 | |
|         public E higher(E e) {
 | |
|             return this.a.higher(e);
 | |
|         }
 | |
| 
 | |
|         @Override // java.util.NavigableSet
 | |
|         public E lower(E e) {
 | |
|             return this.a.lower(e);
 | |
|         }
 | |
| 
 | |
|         @Override // java.util.NavigableSet
 | |
|         public E pollFirst() {
 | |
|             throw new UnsupportedOperationException();
 | |
|         }
 | |
| 
 | |
|         @Override // java.util.NavigableSet
 | |
|         public E pollLast() {
 | |
|             throw new UnsupportedOperationException();
 | |
|         }
 | |
| 
 | |
|         @Override // java.util.NavigableSet
 | |
|         public NavigableSet<E> subSet(E e, boolean z, E e2, boolean z2) {
 | |
|             return Sets.a((NavigableSet) this.a.subSet(e, z, e2, z2));
 | |
|         }
 | |
| 
 | |
|         @Override // java.util.NavigableSet
 | |
|         public NavigableSet<E> tailSet(E e, boolean z) {
 | |
|             return Sets.a((NavigableSet) this.a.tailSet(e, z));
 | |
|         }
 | |
| 
 | |
|         /* JADX INFO: Access modifiers changed from: protected */
 | |
|         @Override // com.google.common.collect.ForwardingSet, com.google.common.collect.ForwardingCollection, com.google.common.collect.ForwardingObject
 | |
|         public SortedSet<E> delegate() {
 | |
|             return Collections.unmodifiableSortedSet(this.a);
 | |
|         }
 | |
|     }
 | |
| 
 | |
|     static int a(Set<?> set) {
 | |
|         Iterator<?> it = set.iterator();
 | |
|         int i = 0;
 | |
|         while (it.hasNext()) {
 | |
|             Object next = it.next();
 | |
|             i = ~(~(i + (next != null ? next.hashCode() : 0)));
 | |
|         }
 | |
|         return i;
 | |
|     }
 | |
| 
 | |
|     static boolean a(Set<?> set, Object obj) {
 | |
|         if (set == obj) {
 | |
|             return true;
 | |
|         }
 | |
|         if (obj instanceof Set) {
 | |
|             Set set2 = (Set) obj;
 | |
|             try {
 | |
|                 if (set.size() == set2.size()) {
 | |
|                     if (set.containsAll(set2)) {
 | |
|                         return true;
 | |
|                     }
 | |
|                 }
 | |
|                 return false;
 | |
|             } catch (ClassCastException | NullPointerException unused) {
 | |
|             }
 | |
|         }
 | |
|         return false;
 | |
|     }
 | |
| 
 | |
|     public static <E> NavigableSet<E> a(NavigableSet<E> navigableSet) {
 | |
|         return ((navigableSet instanceof ImmutableSortedSet) || (navigableSet instanceof UnmodifiableNavigableSet)) ? navigableSet : new UnmodifiableNavigableSet(navigableSet);
 | |
|     }
 | |
| 
 | |
|     static boolean a(Set<?> set, Iterator<?> it) {
 | |
|         boolean z = false;
 | |
|         while (it.hasNext()) {
 | |
|             z |= set.remove(it.next());
 | |
|         }
 | |
|         return z;
 | |
|     }
 | |
| 
 | |
|     static boolean a(Set<?> set, Collection<?> collection) {
 | |
|         Preconditions.a(collection);
 | |
|         if (collection instanceof Multiset) {
 | |
|             collection = ((Multiset) collection).elementSet();
 | |
|         }
 | |
|         if ((collection instanceof Set) && collection.size() > set.size()) {
 | |
|             return Iterators.a(set.iterator(), collection);
 | |
|         }
 | |
|         return a(set, collection.iterator());
 | |
|     }
 | |
| }
 |