Multisets.java
20.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
package com.google.common.collect;
import com.google.common.annotations.Beta;
import com.google.common.annotations.GwtCompatible;
import com.google.common.base.Objects;
import com.google.common.base.Preconditions;
import com.google.common.base.Predicate;
import com.google.common.base.Predicates;
import com.google.common.primitives.Ints;
import java.io.Serializable;
import java.util.Collection;
import java.util.Collections;
import java.util.Iterator;
import java.util.NoSuchElementException;
import java.util.Set;
import javax.annotation.Nullable;
import my;
import nj;
import qg;
import qi;
@GwtCompatible
public final class Multisets
{
private static final Ordering<Multiset.Entry<?>> a = new Ordering() {};
public static <E> int a(Multiset<E> paramMultiset, E paramE, int paramInt)
{
nj.a(paramInt, "count");
int i = paramMultiset.count(paramE);
paramInt -= i;
if (paramInt > 0) {
paramMultiset.add(paramE, paramInt);
}
while (paramInt >= 0) {
return i;
}
paramMultiset.remove(paramE, -paramInt);
return i;
}
static int a(Iterable<?> paramIterable)
{
if ((paramIterable instanceof Multiset)) {
return ((Multiset)paramIterable).elementSet().size();
}
return 11;
}
public static <E> Iterator<E> a(Multiset<E> paramMultiset)
{
return new f(paramMultiset, paramMultiset.entrySet().iterator());
}
public static boolean a(Multiset<?> paramMultiset, @Nullable Object paramObject)
{
if (paramObject == paramMultiset) {
return true;
}
if ((paramObject instanceof Multiset))
{
paramObject = (Multiset)paramObject;
if ((paramMultiset.size() != ((Multiset)paramObject).size()) || (paramMultiset.entrySet().size() != ((Multiset)paramObject).entrySet().size())) {
return false;
}
paramObject = ((Multiset)paramObject).entrySet().iterator();
while (((Iterator)paramObject).hasNext())
{
Multiset.Entry localEntry = (Multiset.Entry)((Iterator)paramObject).next();
if (paramMultiset.count(localEntry.getElement()) != localEntry.getCount()) {
return false;
}
}
return true;
}
return false;
}
public static <E> boolean a(Multiset<E> paramMultiset, E paramE, int paramInt1, int paramInt2)
{
nj.a(paramInt1, "oldCount");
nj.a(paramInt2, "newCount");
if (paramMultiset.count(paramE) == paramInt1)
{
paramMultiset.setCount(paramE, paramInt2);
return true;
}
return false;
}
public static <E> boolean a(Multiset<E> paramMultiset, Collection<? extends E> paramCollection)
{
if (paramCollection.isEmpty()) {
return false;
}
if ((paramCollection instanceof Multiset))
{
paramCollection = ((Multiset)paramCollection).entrySet().iterator();
while (paramCollection.hasNext())
{
Multiset.Entry localEntry = (Multiset.Entry)paramCollection.next();
paramMultiset.add(localEntry.getElement(), localEntry.getCount());
}
}
Iterators.addAll(paramMultiset, paramCollection.iterator());
return true;
}
public static int b(Multiset<?> paramMultiset)
{
paramMultiset = paramMultiset.entrySet().iterator();
for (long l = 0L; paramMultiset.hasNext(); l = ((Multiset.Entry)paramMultiset.next()).getCount() + l) {}
return Ints.saturatedCast(l);
}
static <T> Multiset<T> b(Iterable<T> paramIterable)
{
return (Multiset)paramIterable;
}
public static boolean b(Multiset<?> paramMultiset, Collection<?> paramCollection)
{
Object localObject = paramCollection;
if ((paramCollection instanceof Multiset)) {
localObject = ((Multiset)paramCollection).elementSet();
}
return paramMultiset.elementSet().removeAll((Collection)localObject);
}
public static boolean c(Multiset<?> paramMultiset, Collection<?> paramCollection)
{
Preconditions.checkNotNull(paramCollection);
Object localObject = paramCollection;
if ((paramCollection instanceof Multiset)) {
localObject = ((Multiset)paramCollection).elementSet();
}
return paramMultiset.elementSet().retainAll((Collection)localObject);
}
public static boolean containsOccurrences(Multiset<?> paramMultiset1, Multiset<?> paramMultiset2)
{
Preconditions.checkNotNull(paramMultiset1);
Preconditions.checkNotNull(paramMultiset2);
paramMultiset2 = paramMultiset2.entrySet().iterator();
while (paramMultiset2.hasNext())
{
Multiset.Entry localEntry = (Multiset.Entry)paramMultiset2.next();
if (paramMultiset1.count(localEntry.getElement()) < localEntry.getCount()) {
return false;
}
}
return true;
}
@Beta
public static <E> ImmutableMultiset<E> copyHighestCountFirst(Multiset<E> paramMultiset)
{
return ImmutableMultiset.a(a.immutableSortedCopy(paramMultiset.entrySet()));
}
@Beta
public static <E> Multiset<E> difference(Multiset<E> paramMultiset, final Multiset<?> paramMultiset1)
{
Preconditions.checkNotNull(paramMultiset);
Preconditions.checkNotNull(paramMultiset1);
new my()
{
final Iterator<Multiset.Entry<E>> a()
{
new AbstractIterator() {};
}
final int b()
{
return Iterators.size(a());
}
public final int count(@Nullable Object paramAnonymousObject)
{
int i = this.a.count(paramAnonymousObject);
if (i == 0) {
return 0;
}
return Math.max(0, i - paramMultiset1.count(paramAnonymousObject));
}
};
}
@Beta
public static <E> Multiset<E> filter(Multiset<E> paramMultiset, Predicate<? super E> paramPredicate)
{
if ((paramMultiset instanceof d))
{
paramMultiset = (d)paramMultiset;
paramPredicate = Predicates.and(paramMultiset.b, paramPredicate);
return new d(paramMultiset.a, paramPredicate);
}
return new d(paramMultiset, paramPredicate);
}
public static <E> Multiset.Entry<E> immutableEntry(@Nullable E paramE, int paramInt)
{
return new e(paramE, paramInt);
}
public static <E> Multiset<E> intersection(Multiset<E> paramMultiset, final Multiset<?> paramMultiset1)
{
Preconditions.checkNotNull(paramMultiset);
Preconditions.checkNotNull(paramMultiset1);
new my()
{
final Iterator<Multiset.Entry<E>> a()
{
new AbstractIterator() {};
}
final int b()
{
return elementSet().size();
}
final Set<E> c()
{
return Sets.intersection(this.a.elementSet(), paramMultiset1.elementSet());
}
public final int count(Object paramAnonymousObject)
{
int i = this.a.count(paramAnonymousObject);
if (i == 0) {
return 0;
}
return Math.min(i, paramMultiset1.count(paramAnonymousObject));
}
};
}
public static boolean removeOccurrences(Multiset<?> paramMultiset, Iterable<?> paramIterable)
{
boolean bool1 = false;
boolean bool2;
if ((paramIterable instanceof Multiset))
{
paramIterable = (Multiset)paramIterable;
Preconditions.checkNotNull(paramMultiset);
Preconditions.checkNotNull(paramIterable);
Iterator localIterator = paramMultiset.entrySet().iterator();
Multiset.Entry localEntry;
int i;
for (bool1 = false;; bool1 = true)
{
bool2 = bool1;
if (!localIterator.hasNext()) {
break label172;
}
localEntry = (Multiset.Entry)localIterator.next();
i = paramIterable.count(localEntry.getElement());
if (i < localEntry.getCount()) {
break;
}
localIterator.remove();
}
if (i <= 0) {
break label175;
}
paramMultiset.remove(localEntry.getElement(), i);
bool1 = true;
}
label172:
label175:
for (;;)
{
break;
Preconditions.checkNotNull(paramMultiset);
Preconditions.checkNotNull(paramIterable);
paramIterable = paramIterable.iterator();
while (paramIterable.hasNext()) {
bool1 |= paramMultiset.remove(paramIterable.next());
}
bool2 = bool1;
return bool2;
}
}
public static boolean retainOccurrences(Multiset<?> paramMultiset1, Multiset<?> paramMultiset2)
{
Preconditions.checkNotNull(paramMultiset1);
Preconditions.checkNotNull(paramMultiset2);
Iterator localIterator = paramMultiset1.entrySet().iterator();
boolean bool = false;
while (localIterator.hasNext())
{
Multiset.Entry localEntry = (Multiset.Entry)localIterator.next();
int i = paramMultiset2.count(localEntry.getElement());
if (i == 0)
{
localIterator.remove();
bool = true;
}
else
{
if (i >= localEntry.getCount()) {
break label110;
}
paramMultiset1.setCount(localEntry.getElement(), i);
bool = true;
}
}
label110:
for (;;)
{
break;
return bool;
}
}
@Beta
public static <E> Multiset<E> sum(Multiset<? extends E> paramMultiset1, final Multiset<? extends E> paramMultiset2)
{
Preconditions.checkNotNull(paramMultiset1);
Preconditions.checkNotNull(paramMultiset2);
new my()
{
final Iterator<Multiset.Entry<E>> a()
{
new AbstractIterator() {};
}
final int b()
{
return elementSet().size();
}
final Set<E> c()
{
return Sets.union(this.a.elementSet(), paramMultiset2.elementSet());
}
public final boolean contains(@Nullable Object paramAnonymousObject)
{
return (this.a.contains(paramAnonymousObject)) || (paramMultiset2.contains(paramAnonymousObject));
}
public final int count(Object paramAnonymousObject)
{
return this.a.count(paramAnonymousObject) + paramMultiset2.count(paramAnonymousObject);
}
public final boolean isEmpty()
{
return (this.a.isEmpty()) && (paramMultiset2.isEmpty());
}
public final int size()
{
return this.a.size() + paramMultiset2.size();
}
};
}
@Beta
public static <E> Multiset<E> union(Multiset<? extends E> paramMultiset1, final Multiset<? extends E> paramMultiset2)
{
Preconditions.checkNotNull(paramMultiset1);
Preconditions.checkNotNull(paramMultiset2);
new my()
{
final Iterator<Multiset.Entry<E>> a()
{
new AbstractIterator() {};
}
final int b()
{
return elementSet().size();
}
final Set<E> c()
{
return Sets.union(this.a.elementSet(), paramMultiset2.elementSet());
}
public final boolean contains(@Nullable Object paramAnonymousObject)
{
return (this.a.contains(paramAnonymousObject)) || (paramMultiset2.contains(paramAnonymousObject));
}
public final int count(Object paramAnonymousObject)
{
return Math.max(this.a.count(paramAnonymousObject), paramMultiset2.count(paramAnonymousObject));
}
public final boolean isEmpty()
{
return (this.a.isEmpty()) && (paramMultiset2.isEmpty());
}
};
}
@Deprecated
public static <E> Multiset<E> unmodifiableMultiset(ImmutableMultiset<E> paramImmutableMultiset)
{
return (Multiset)Preconditions.checkNotNull(paramImmutableMultiset);
}
public static <E> Multiset<E> unmodifiableMultiset(Multiset<? extends E> paramMultiset)
{
if (((paramMultiset instanceof g)) || ((paramMultiset instanceof ImmutableMultiset))) {
return paramMultiset;
}
return new g((Multiset)Preconditions.checkNotNull(paramMultiset));
}
@Beta
public static <E> SortedMultiset<E> unmodifiableSortedMultiset(SortedMultiset<E> paramSortedMultiset)
{
return new qi((SortedMultiset)Preconditions.checkNotNull(paramSortedMultiset));
}
public static abstract class a<E>
implements Multiset.Entry<E>
{
public boolean equals(@Nullable Object paramObject)
{
boolean bool2 = false;
boolean bool1 = bool2;
if ((paramObject instanceof Multiset.Entry))
{
paramObject = (Multiset.Entry)paramObject;
bool1 = bool2;
if (getCount() == ((Multiset.Entry)paramObject).getCount())
{
bool1 = bool2;
if (Objects.equal(getElement(), ((Multiset.Entry)paramObject).getElement())) {
bool1 = true;
}
}
}
return bool1;
}
public int hashCode()
{
Object localObject = getElement();
if (localObject == null) {}
for (int i = 0;; i = localObject.hashCode()) {
return i ^ getCount();
}
}
public String toString()
{
String str = String.valueOf(getElement());
int i = getCount();
if (i == 1) {
return str;
}
str = String.valueOf(String.valueOf(str));
return str.length() + 14 + str + " x " + i;
}
}
public static abstract class b<E>
extends Sets.f<E>
{
public abstract Multiset<E> a();
public void clear()
{
a().clear();
}
public boolean contains(Object paramObject)
{
return a().contains(paramObject);
}
public boolean containsAll(Collection<?> paramCollection)
{
return a().containsAll(paramCollection);
}
public boolean isEmpty()
{
return a().isEmpty();
}
public Iterator<E> iterator()
{
new qg(a().entrySet().iterator()) {};
}
public boolean remove(Object paramObject)
{
int i = a().count(paramObject);
if (i > 0)
{
a().remove(paramObject, i);
return true;
}
return false;
}
public int size()
{
return a().entrySet().size();
}
}
public static abstract class c<E>
extends Sets.f<Multiset.Entry<E>>
{
public abstract Multiset<E> a();
public void clear()
{
a().clear();
}
public boolean contains(@Nullable Object paramObject)
{
if ((paramObject instanceof Multiset.Entry))
{
paramObject = (Multiset.Entry)paramObject;
if (((Multiset.Entry)paramObject).getCount() > 0) {
break label23;
}
}
label23:
while (a().count(((Multiset.Entry)paramObject).getElement()) != ((Multiset.Entry)paramObject).getCount()) {
return false;
}
return true;
}
public boolean remove(Object paramObject)
{
boolean bool2 = false;
boolean bool1 = bool2;
if ((paramObject instanceof Multiset.Entry))
{
paramObject = (Multiset.Entry)paramObject;
Object localObject = ((Multiset.Entry)paramObject).getElement();
int i = ((Multiset.Entry)paramObject).getCount();
bool1 = bool2;
if (i != 0) {
bool1 = a().setCount(localObject, i, 0);
}
}
return bool1;
}
}
static final class d<E>
extends my<E>
{
final Multiset<E> a;
final Predicate<? super E> b;
d(Multiset<E> paramMultiset, Predicate<? super E> paramPredicate)
{
this.a = ((Multiset)Preconditions.checkNotNull(paramMultiset));
this.b = ((Predicate)Preconditions.checkNotNull(paramPredicate));
}
final Iterator<Multiset.Entry<E>> a()
{
throw new AssertionError("should never be called");
}
public final int add(@Nullable E paramE, int paramInt)
{
Preconditions.checkArgument(this.b.apply(paramE), "Element %s does not match predicate %s", new Object[] { paramE, this.b });
return this.a.add(paramE, paramInt);
}
final int b()
{
return elementSet().size();
}
final Set<E> c()
{
return Sets.filter(this.a.elementSet(), this.b);
}
public final void clear()
{
elementSet().clear();
}
public final int count(@Nullable Object paramObject)
{
int i = this.a.count(paramObject);
if (i > 0)
{
if (this.b.apply(paramObject)) {
return i;
}
return 0;
}
return 0;
}
final Set<Multiset.Entry<E>> createEntrySet()
{
Sets.filter(this.a.entrySet(), new Predicate() {});
}
public final int remove(@Nullable Object paramObject, int paramInt)
{
nj.a(paramInt, "occurrences");
if (paramInt == 0) {
return count(paramObject);
}
if (contains(paramObject)) {
return this.a.remove(paramObject, paramInt);
}
return 0;
}
}
static final class e<E>
extends Multisets.a<E>
implements Serializable
{
private static final long serialVersionUID = 0L;
@Nullable
final E a;
final int b;
e(@Nullable E paramE, int paramInt)
{
this.a = paramE;
this.b = paramInt;
nj.a(paramInt, "count");
}
public final int getCount()
{
return this.b;
}
@Nullable
public final E getElement()
{
return (E)this.a;
}
}
static final class f<E>
implements Iterator<E>
{
private final Multiset<E> a;
private final Iterator<Multiset.Entry<E>> b;
private Multiset.Entry<E> c;
private int d;
private int e;
private boolean f;
f(Multiset<E> paramMultiset, Iterator<Multiset.Entry<E>> paramIterator)
{
this.a = paramMultiset;
this.b = paramIterator;
}
public final boolean hasNext()
{
return (this.d > 0) || (this.b.hasNext());
}
public final E next()
{
if (!hasNext()) {
throw new NoSuchElementException();
}
if (this.d == 0)
{
this.c = ((Multiset.Entry)this.b.next());
int i = this.c.getCount();
this.d = i;
this.e = i;
}
this.d -= 1;
this.f = true;
return (E)this.c.getElement();
}
public final void remove()
{
Preconditions.checkState(this.f, "no calls to next() since the last call to remove()");
if (this.e == 1) {
this.b.remove();
}
for (;;)
{
this.e -= 1;
this.f = false;
return;
this.a.remove(this.c.getElement());
}
}
}
public static class g<E>
extends ForwardingMultiset<E>
implements Serializable
{
private static final long serialVersionUID = 0L;
final Multiset<? extends E> a;
transient Set<E> b;
transient Set<Multiset.Entry<E>> c;
protected g(Multiset<? extends E> paramMultiset)
{
this.a = paramMultiset;
}
protected Set<E> a()
{
return Collections.unmodifiableSet(this.a.elementSet());
}
public int add(E paramE, int paramInt)
{
throw new UnsupportedOperationException();
}
public boolean add(E paramE)
{
throw new UnsupportedOperationException();
}
public boolean addAll(Collection<? extends E> paramCollection)
{
throw new UnsupportedOperationException();
}
public void clear()
{
throw new UnsupportedOperationException();
}
protected Multiset<E> delegate()
{
return this.a;
}
public Set<E> elementSet()
{
Set localSet2 = this.b;
Set localSet1 = localSet2;
if (localSet2 == null)
{
localSet1 = a();
this.b = localSet1;
}
return localSet1;
}
public Set<Multiset.Entry<E>> entrySet()
{
Set localSet2 = this.c;
Set localSet1 = localSet2;
if (localSet2 == null)
{
localSet1 = Collections.unmodifiableSet(this.a.entrySet());
this.c = localSet1;
}
return localSet1;
}
public Iterator<E> iterator()
{
return Iterators.unmodifiableIterator(this.a.iterator());
}
public int remove(Object paramObject, int paramInt)
{
throw new UnsupportedOperationException();
}
public boolean remove(Object paramObject)
{
throw new UnsupportedOperationException();
}
public boolean removeAll(Collection<?> paramCollection)
{
throw new UnsupportedOperationException();
}
public boolean retainAll(Collection<?> paramCollection)
{
throw new UnsupportedOperationException();
}
public int setCount(E paramE, int paramInt)
{
throw new UnsupportedOperationException();
}
public boolean setCount(E paramE, int paramInt1, int paramInt2)
{
throw new UnsupportedOperationException();
}
}
}
/* Location: /home/merong/decompile/hackery-dex2jar.jar!/com/google/common/collect/Multisets.class
* Java compiler version: 6 (50.0)
* JD-Core Version: 0.7.1
*/