ImmutableRangeMap.java
7.85 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
package com.google.common.collect;
import com.google.common.annotations.Beta;
import com.google.common.annotations.GwtIncompatible;
import com.google.common.base.Preconditions;
import java.util.Iterator;
import java.util.Map;
import java.util.Map.Entry;
import java.util.NoSuchElementException;
import java.util.Set;
import javax.annotation.Nullable;
import nq;
import pn;
import pp;
@Beta
@GwtIncompatible("NavigableMap")
public class ImmutableRangeMap<K extends Comparable<?>, V>
implements RangeMap<K, V>
{
private static final ImmutableRangeMap<Comparable<?>, Object> a = new ImmutableRangeMap(ImmutableList.of(), ImmutableList.of());
private final ImmutableList<Range<K>> b;
private final ImmutableList<V> c;
ImmutableRangeMap(ImmutableList<Range<K>> paramImmutableList, ImmutableList<V> paramImmutableList1)
{
this.b = paramImmutableList;
this.c = paramImmutableList1;
}
public static <K extends Comparable<?>, V> Builder<K, V> builder()
{
return new Builder();
}
public static <K extends Comparable<?>, V> ImmutableRangeMap<K, V> copyOf(RangeMap<K, ? extends V> paramRangeMap)
{
if ((paramRangeMap instanceof ImmutableRangeMap)) {
return (ImmutableRangeMap)paramRangeMap;
}
Object localObject = paramRangeMap.asMapOfRanges();
paramRangeMap = new ImmutableList.Builder(((Map)localObject).size());
ImmutableList.Builder localBuilder = new ImmutableList.Builder(((Map)localObject).size());
localObject = ((Map)localObject).entrySet().iterator();
while (((Iterator)localObject).hasNext())
{
Map.Entry localEntry = (Map.Entry)((Iterator)localObject).next();
paramRangeMap.add(localEntry.getKey());
localBuilder.add(localEntry.getValue());
}
return new ImmutableRangeMap(paramRangeMap.build(), localBuilder.build());
}
public static <K extends Comparable<?>, V> ImmutableRangeMap<K, V> of()
{
return a;
}
public static <K extends Comparable<?>, V> ImmutableRangeMap<K, V> of(Range<K> paramRange, V paramV)
{
return new ImmutableRangeMap(ImmutableList.of(paramRange), ImmutableList.of(paramV));
}
public ImmutableMap<Range<K>, V> asMapOfRanges()
{
if (this.b.isEmpty()) {
return ImmutableMap.of();
}
return new pn(new pp(this.b, Range.a), this.c);
}
public void clear()
{
throw new UnsupportedOperationException();
}
public boolean equals(@Nullable Object paramObject)
{
if ((paramObject instanceof RangeMap))
{
paramObject = (RangeMap)paramObject;
return asMapOfRanges().equals(((RangeMap)paramObject).asMapOfRanges());
}
return false;
}
@Nullable
public V get(K paramK)
{
int i = SortedLists.a(this.b, Range.a(), nq.b(paramK), SortedLists.KeyPresentBehavior.ANY_PRESENT, SortedLists.KeyAbsentBehavior.NEXT_LOWER);
if (i == -1) {
return null;
}
if (((Range)this.b.get(i)).contains(paramK)) {
return (V)this.c.get(i);
}
return null;
}
@Nullable
public Map.Entry<Range<K>, V> getEntry(K paramK)
{
int i = SortedLists.a(this.b, Range.a(), nq.b(paramK), SortedLists.KeyPresentBehavior.ANY_PRESENT, SortedLists.KeyAbsentBehavior.NEXT_LOWER);
if (i == -1) {
return null;
}
Range localRange = (Range)this.b.get(i);
if (localRange.contains(paramK)) {
return Maps.immutableEntry(localRange, this.c.get(i));
}
return null;
}
public int hashCode()
{
return asMapOfRanges().hashCode();
}
public void put(Range<K> paramRange, V paramV)
{
throw new UnsupportedOperationException();
}
public void putAll(RangeMap<K, V> paramRangeMap)
{
throw new UnsupportedOperationException();
}
public void remove(Range<K> paramRange)
{
throw new UnsupportedOperationException();
}
public Range<K> span()
{
if (this.b.isEmpty()) {
throw new NoSuchElementException();
}
Range localRange1 = (Range)this.b.get(0);
Range localRange2 = (Range)this.b.get(this.b.size() - 1);
return Range.a(localRange1.b, localRange2.c);
}
public ImmutableRangeMap<K, V> subRangeMap(final Range<K> paramRange)
{
if (((Range)Preconditions.checkNotNull(paramRange)).isEmpty()) {
return of();
}
if ((this.b.isEmpty()) || (paramRange.encloses(span()))) {
return this;
}
final int i = SortedLists.a(this.b, Range.b(), paramRange.b, SortedLists.KeyPresentBehavior.FIRST_AFTER, SortedLists.KeyAbsentBehavior.NEXT_HIGHER);
int j = SortedLists.a(this.b, Range.a(), paramRange.c, SortedLists.KeyPresentBehavior.ANY_PRESENT, SortedLists.KeyAbsentBehavior.NEXT_HIGHER);
if (i >= j) {
return of();
}
new ImmutableRangeMap(new ImmutableList()
{
final boolean a()
{
return true;
}
public final int size()
{
return this.a;
}
}, this.c.subList(i, j))
{
public final ImmutableRangeMap<K, V> subRangeMap(Range<K> paramAnonymousRange)
{
if (paramRange.isConnected(paramAnonymousRange)) {
return jdField_this.subRangeMap(paramAnonymousRange.intersection(paramRange));
}
return ImmutableRangeMap.of();
}
};
}
public String toString()
{
return asMapOfRanges().toString();
}
public static final class Builder<K extends Comparable<?>, V>
{
private final RangeSet<K> a = TreeRangeSet.create();
private final RangeMap<K, V> b = TreeRangeMap.create();
public final ImmutableRangeMap<K, V> build()
{
Object localObject = this.b.asMapOfRanges();
ImmutableList.Builder localBuilder1 = new ImmutableList.Builder(((Map)localObject).size());
ImmutableList.Builder localBuilder2 = new ImmutableList.Builder(((Map)localObject).size());
localObject = ((Map)localObject).entrySet().iterator();
while (((Iterator)localObject).hasNext())
{
Map.Entry localEntry = (Map.Entry)((Iterator)localObject).next();
localBuilder1.add(localEntry.getKey());
localBuilder2.add(localEntry.getValue());
}
return new ImmutableRangeMap(localBuilder1.build(), localBuilder2.build());
}
public final Builder<K, V> put(Range<K> paramRange, V paramV)
{
Preconditions.checkNotNull(paramRange);
Preconditions.checkNotNull(paramV);
if (!paramRange.isEmpty()) {}
for (boolean bool = true;; bool = false)
{
Preconditions.checkArgument(bool, "Range must not be empty, but was %s", new Object[] { paramRange });
if (this.a.complement().encloses(paramRange)) {
break;
}
Iterator localIterator = this.b.asMapOfRanges().entrySet().iterator();
Map.Entry localEntry;
Range localRange;
do
{
if (!localIterator.hasNext()) {
break;
}
localEntry = (Map.Entry)localIterator.next();
localRange = (Range)localEntry.getKey();
} while ((!localRange.isConnected(paramRange)) || (localRange.intersection(paramRange).isEmpty()));
paramRange = String.valueOf(String.valueOf(paramRange));
paramV = String.valueOf(String.valueOf(localEntry));
throw new IllegalArgumentException(paramRange.length() + 47 + paramV.length() + "Overlapping ranges: range " + paramRange + " overlaps with entry " + paramV);
}
this.a.add(paramRange);
this.b.put(paramRange, paramV);
return this;
}
public final Builder<K, V> putAll(RangeMap<K, ? extends V> paramRangeMap)
{
paramRangeMap = paramRangeMap.asMapOfRanges().entrySet().iterator();
while (paramRangeMap.hasNext())
{
Map.Entry localEntry = (Map.Entry)paramRangeMap.next();
put((Range)localEntry.getKey(), localEntry.getValue());
}
return this;
}
}
}
/* Location: /home/merong/decompile/hackery-dex2jar.jar!/com/google/common/collect/ImmutableRangeMap.class
* Java compiler version: 6 (50.0)
* JD-Core Version: 0.7.1
*/