ImmutableRangeSet.java
13.5 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
package com.google.common.collect;
import com.google.common.annotations.Beta;
import com.google.common.annotations.GwtIncompatible;
import com.google.common.base.Preconditions;
import com.google.common.primitives.Ints;
import java.io.Serializable;
import java.util.Iterator;
import java.util.NoSuchElementException;
import java.util.Set;
import javax.annotation.Nullable;
import na;
import nq;
import pp;
@Beta
public final class ImmutableRangeSet<C extends Comparable>
extends na<C>
implements Serializable
{
private static final ImmutableRangeSet<Comparable<?>> a = new ImmutableRangeSet(ImmutableList.of());
private static final ImmutableRangeSet<Comparable<?>> b = new ImmutableRangeSet(ImmutableList.of(Range.all()));
private final transient ImmutableList<Range<C>> c;
private transient ImmutableRangeSet<C> d;
ImmutableRangeSet(ImmutableList<Range<C>> paramImmutableList)
{
this.c = paramImmutableList;
}
private ImmutableRangeSet(ImmutableList<Range<C>> paramImmutableList, ImmutableRangeSet<C> paramImmutableRangeSet)
{
this.c = paramImmutableList;
this.d = paramImmutableRangeSet;
}
static <C extends Comparable> ImmutableRangeSet<C> a()
{
return b;
}
public static <C extends Comparable<?>> Builder<C> builder()
{
return new Builder();
}
public static <C extends Comparable> ImmutableRangeSet<C> copyOf(RangeSet<C> paramRangeSet)
{
Preconditions.checkNotNull(paramRangeSet);
Object localObject;
if (paramRangeSet.isEmpty()) {
localObject = of();
}
ImmutableRangeSet localImmutableRangeSet;
do
{
return (ImmutableRangeSet<C>)localObject;
if (paramRangeSet.encloses(Range.all())) {
return b;
}
if (!(paramRangeSet instanceof ImmutableRangeSet)) {
break;
}
localImmutableRangeSet = (ImmutableRangeSet)paramRangeSet;
localObject = localImmutableRangeSet;
} while (!localImmutableRangeSet.c.a());
return new ImmutableRangeSet(ImmutableList.copyOf(paramRangeSet.asRanges()));
}
public static <C extends Comparable> ImmutableRangeSet<C> of()
{
return a;
}
public static <C extends Comparable> ImmutableRangeSet<C> of(Range<C> paramRange)
{
Preconditions.checkNotNull(paramRange);
if (paramRange.isEmpty()) {
return of();
}
if (paramRange.equals(Range.all())) {
return b;
}
return new ImmutableRangeSet(ImmutableList.of(paramRange));
}
public final void add(Range<C> paramRange)
{
throw new UnsupportedOperationException();
}
public final void addAll(RangeSet<C> paramRangeSet)
{
throw new UnsupportedOperationException();
}
public final ImmutableSet<Range<C>> asRanges()
{
if (this.c.isEmpty()) {
return ImmutableSet.of();
}
return new pp(this.c, Range.a);
}
public final ImmutableSortedSet<C> asSet(DiscreteDomain<C> paramDiscreteDomain)
{
Preconditions.checkNotNull(paramDiscreteDomain);
if (isEmpty()) {
return ImmutableSortedSet.of();
}
Range localRange = span().canonical(paramDiscreteDomain);
if (!localRange.hasLowerBound()) {
throw new IllegalArgumentException("Neither the DiscreteDomain nor this range set are bounded below");
}
if (!localRange.hasUpperBound()) {}
try
{
paramDiscreteDomain.maxValue();
return new a(paramDiscreteDomain);
}
catch (NoSuchElementException paramDiscreteDomain)
{
throw new IllegalArgumentException("Neither the DiscreteDomain nor this range set are bounded above");
}
}
public final ImmutableRangeSet<C> complement()
{
ImmutableRangeSet localImmutableRangeSet = this.d;
if (localImmutableRangeSet != null) {
return localImmutableRangeSet;
}
if (this.c.isEmpty())
{
localImmutableRangeSet = b;
this.d = localImmutableRangeSet;
return localImmutableRangeSet;
}
if ((this.c.size() == 1) && (((Range)this.c.get(0)).equals(Range.all())))
{
localImmutableRangeSet = of();
this.d = localImmutableRangeSet;
return localImmutableRangeSet;
}
localImmutableRangeSet = new ImmutableRangeSet(new c(), this);
this.d = localImmutableRangeSet;
return localImmutableRangeSet;
}
public final boolean encloses(Range<C> paramRange)
{
int i = SortedLists.a(this.c, Range.a(), paramRange.b, Ordering.natural(), SortedLists.KeyPresentBehavior.ANY_PRESENT, SortedLists.KeyAbsentBehavior.NEXT_LOWER);
return (i != -1) && (((Range)this.c.get(i)).encloses(paramRange));
}
public final boolean isEmpty()
{
return this.c.isEmpty();
}
public final Range<C> rangeContaining(C paramC)
{
int i = SortedLists.a(this.c, Range.a(), nq.b(paramC), Ordering.natural(), SortedLists.KeyPresentBehavior.ANY_PRESENT, SortedLists.KeyAbsentBehavior.NEXT_LOWER);
if (i != -1)
{
Range localRange = (Range)this.c.get(i);
if (localRange.contains(paramC)) {
return localRange;
}
return null;
}
return null;
}
public final void remove(Range<C> paramRange)
{
throw new UnsupportedOperationException();
}
public final void removeAll(RangeSet<C> paramRangeSet)
{
throw new UnsupportedOperationException();
}
public final Range<C> span()
{
if (this.c.isEmpty()) {
throw new NoSuchElementException();
}
return Range.a(((Range)this.c.get(0)).b, ((Range)this.c.get(this.c.size() - 1)).c);
}
public final ImmutableRangeSet<C> subRangeSet(final Range<C> paramRange)
{
if (!isEmpty())
{
Range localRange = span();
if (paramRange.encloses(localRange)) {
return this;
}
if (paramRange.isConnected(localRange))
{
if ((this.c.isEmpty()) || (paramRange.isEmpty())) {
paramRange = ImmutableList.of();
}
for (;;)
{
return new ImmutableRangeSet(paramRange);
if (paramRange.encloses(span()))
{
paramRange = this.c;
}
else
{
final int i;
if (paramRange.hasLowerBound())
{
i = SortedLists.a(this.c, Range.b(), paramRange.b, SortedLists.KeyPresentBehavior.FIRST_AFTER, SortedLists.KeyAbsentBehavior.NEXT_HIGHER);
label110:
if (!paramRange.hasUpperBound()) {
break label158;
}
}
label158:
for (final int j = SortedLists.a(this.c, Range.a(), paramRange.c, SortedLists.KeyPresentBehavior.FIRST_PRESENT, SortedLists.KeyAbsentBehavior.NEXT_HIGHER);; j = this.c.size())
{
j -= i;
if (j != 0) {
break label169;
}
paramRange = ImmutableList.of();
break;
i = 0;
break label110;
}
label169:
paramRange = new ImmutableList()
{
final boolean a()
{
return true;
}
public final int size()
{
return j;
}
};
}
}
}
}
return of();
}
final Object writeReplace()
{
return new d(this.c);
}
public static class Builder<C extends Comparable<?>>
{
private final RangeSet<C> a = TreeRangeSet.create();
public Builder<C> add(Range<C> paramRange)
{
if (paramRange.isEmpty())
{
paramRange = String.valueOf(String.valueOf(paramRange));
throw new IllegalArgumentException(paramRange.length() + 33 + "range must not be empty, but was " + paramRange);
}
if (!this.a.complement().encloses(paramRange))
{
Iterator localIterator = this.a.asRanges().iterator();
if (localIterator.hasNext())
{
Range localRange = (Range)localIterator.next();
if ((!localRange.isConnected(paramRange)) || (localRange.intersection(paramRange).isEmpty())) {}
for (boolean bool = true;; bool = false)
{
Preconditions.checkArgument(bool, "Ranges may not overlap, but received %s and %s", new Object[] { localRange, paramRange });
break;
}
}
throw new AssertionError("should have thrown an IAE above");
}
this.a.add(paramRange);
return this;
}
public Builder<C> addAll(RangeSet<C> paramRangeSet)
{
paramRangeSet = paramRangeSet.asRanges().iterator();
while (paramRangeSet.hasNext()) {
add((Range)paramRangeSet.next());
}
return this;
}
public ImmutableRangeSet<C> build()
{
return ImmutableRangeSet.copyOf(this.a);
}
}
final class a
extends ImmutableSortedSet<C>
{
private final DiscreteDomain<C> d;
private transient Integer e;
a()
{
super();
DiscreteDomain localDiscreteDomain;
this.d = localDiscreteDomain;
}
private ImmutableSortedSet<C> a(Range<C> paramRange)
{
return ImmutableRangeSet.this.subRangeSet(paramRange).asSet(this.d);
}
final int a(Object paramObject)
{
if (contains(paramObject))
{
paramObject = (Comparable)paramObject;
Iterator localIterator = ImmutableRangeSet.a(ImmutableRangeSet.this).iterator();
Range localRange;
for (long l = 0L; localIterator.hasNext(); l = ContiguousSet.create(localRange, this.d).size() + l)
{
localRange = (Range)localIterator.next();
if (localRange.contains((Comparable)paramObject)) {
return Ints.saturatedCast(ContiguousSet.create(localRange, this.d).a(paramObject) + l);
}
}
throw new AssertionError("impossible");
}
return -1;
}
final boolean a()
{
return ImmutableRangeSet.a(ImmutableRangeSet.this).a();
}
public final boolean contains(@Nullable Object paramObject)
{
if (paramObject == null) {
return false;
}
try
{
paramObject = (Comparable)paramObject;
boolean bool = ImmutableRangeSet.this.contains((Comparable)paramObject);
return bool;
}
catch (ClassCastException paramObject) {}
return false;
}
@GwtIncompatible("NavigableSet")
public final UnmodifiableIterator<C> descendingIterator()
{
new AbstractIterator()
{
final Iterator<Range<C>> a = ImmutableRangeSet.a(ImmutableRangeSet.this).reverse().iterator();
Iterator<C> b = Iterators.emptyIterator();
};
}
public final UnmodifiableIterator<C> iterator()
{
new AbstractIterator()
{
final Iterator<Range<C>> a = ImmutableRangeSet.a(ImmutableRangeSet.this).iterator();
Iterator<C> b = Iterators.emptyIterator();
};
}
public final int size()
{
Integer localInteger = this.e;
Object localObject = localInteger;
long l;
if (localInteger == null)
{
localObject = ImmutableRangeSet.a(ImmutableRangeSet.this).iterator();
l = 0L;
if (!((Iterator)localObject).hasNext()) {
break label88;
}
l = ContiguousSet.create((Range)((Iterator)localObject).next(), this.d).size() + l;
if (l < 2147483647L) {
break label85;
}
}
label85:
label88:
for (;;)
{
localObject = Integer.valueOf(Ints.saturatedCast(l));
this.e = ((Integer)localObject);
return ((Integer)localObject).intValue();
break;
}
}
public final String toString()
{
return ImmutableRangeSet.a(ImmutableRangeSet.this).toString();
}
final Object writeReplace()
{
return new ImmutableRangeSet.b(ImmutableRangeSet.a(ImmutableRangeSet.this), this.d);
}
}
static final class b<C extends Comparable>
implements Serializable
{
private final ImmutableList<Range<C>> a;
private final DiscreteDomain<C> b;
b(ImmutableList<Range<C>> paramImmutableList, DiscreteDomain<C> paramDiscreteDomain)
{
this.a = paramImmutableList;
this.b = paramDiscreteDomain;
}
final Object readResolve()
{
return new ImmutableRangeSet(this.a).asSet(this.b);
}
}
final class c
extends ImmutableList<Range<C>>
{
private final boolean b = ((Range)ImmutableRangeSet.a(ImmutableRangeSet.this).get(0)).hasLowerBound();
private final boolean c = ((Range)Iterables.getLast(ImmutableRangeSet.a(ImmutableRangeSet.this))).hasUpperBound();
private final int d;
c()
{
int j = ImmutableRangeSet.a(ImmutableRangeSet.this).size() - 1;
int i = j;
if (this.b) {
i = j + 1;
}
j = i;
if (this.c) {
j = i + 1;
}
this.d = j;
}
final boolean a()
{
return true;
}
public final int size()
{
return this.d;
}
}
static final class d<C extends Comparable>
implements Serializable
{
private final ImmutableList<Range<C>> a;
d(ImmutableList<Range<C>> paramImmutableList)
{
this.a = paramImmutableList;
}
final Object readResolve()
{
if (this.a.isEmpty()) {
return ImmutableRangeSet.of();
}
if (this.a.equals(ImmutableList.of(Range.all()))) {
return ImmutableRangeSet.a();
}
return new ImmutableRangeSet(this.a);
}
}
}
/* Location: /home/merong/decompile/hackery-dex2jar.jar!/com/google/common/collect/ImmutableRangeSet.class
* Java compiler version: 6 (50.0)
* JD-Core Version: 0.7.1
*/