CircularArray.java
4.05 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
package android.support.v4.util;
public final class CircularArray<E>
{
private E[] a;
private int b;
private int c;
private int d;
public CircularArray()
{
this(8);
}
public CircularArray(int paramInt)
{
if (paramInt <= 0) {
throw new IllegalArgumentException("capacity must be >= 1");
}
if (paramInt > 1073741824) {
throw new IllegalArgumentException("capacity must be <= 2^30");
}
int i = paramInt;
if (Integer.bitCount(paramInt) != 1) {
i = Integer.highestOneBit(paramInt - 1) << 1;
}
this.d = (i - 1);
this.a = ((Object[])new Object[i]);
}
private void a()
{
int i = this.a.length;
int j = i - this.b;
int k = i << 1;
if (k < 0) {
throw new RuntimeException("Max array capacity exceeded");
}
Object[] arrayOfObject = new Object[k];
System.arraycopy(this.a, this.b, arrayOfObject, 0, j);
System.arraycopy(this.a, 0, arrayOfObject, j, this.b);
this.a = ((Object[])arrayOfObject);
this.b = 0;
this.c = i;
this.d = (k - 1);
}
public final void addFirst(E paramE)
{
this.b = (this.b - 1 & this.d);
this.a[this.b] = paramE;
if (this.b == this.c) {
a();
}
}
public final void addLast(E paramE)
{
this.a[this.c] = paramE;
this.c = (this.c + 1 & this.d);
if (this.c == this.b) {
a();
}
}
public final void clear()
{
removeFromStart(size());
}
public final E get(int paramInt)
{
if ((paramInt < 0) || (paramInt >= size())) {
throw new ArrayIndexOutOfBoundsException();
}
return (E)this.a[(this.b + paramInt & this.d)];
}
public final E getFirst()
{
if (this.b == this.c) {
throw new ArrayIndexOutOfBoundsException();
}
return (E)this.a[this.b];
}
public final E getLast()
{
if (this.b == this.c) {
throw new ArrayIndexOutOfBoundsException();
}
return (E)this.a[(this.c - 1 & this.d)];
}
public final boolean isEmpty()
{
return this.b == this.c;
}
public final E popFirst()
{
if (this.b == this.c) {
throw new ArrayIndexOutOfBoundsException();
}
Object localObject = this.a[this.b];
this.a[this.b] = null;
this.b = (this.b + 1 & this.d);
return (E)localObject;
}
public final E popLast()
{
if (this.b == this.c) {
throw new ArrayIndexOutOfBoundsException();
}
int i = this.c - 1 & this.d;
Object localObject = this.a[i];
this.a[i] = null;
this.c = i;
return (E)localObject;
}
public final void removeFromEnd(int paramInt)
{
if (paramInt <= 0) {}
do
{
return;
if (paramInt > size()) {
throw new ArrayIndexOutOfBoundsException();
}
i = 0;
if (paramInt < this.c) {
i = this.c - paramInt;
}
int j = i;
while (j < this.c)
{
this.a[j] = null;
j += 1;
}
i = this.c - i;
paramInt -= i;
this.c -= i;
} while (paramInt <= 0);
this.c = this.a.length;
int i = this.c - paramInt;
paramInt = i;
while (paramInt < this.c)
{
this.a[paramInt] = null;
paramInt += 1;
}
this.c = i;
}
public final void removeFromStart(int paramInt)
{
if (paramInt <= 0) {}
int i;
do
{
return;
if (paramInt > size()) {
throw new ArrayIndexOutOfBoundsException();
}
int j = this.a.length;
i = j;
if (paramInt < j - this.b) {
i = this.b + paramInt;
}
j = this.b;
while (j < i)
{
this.a[j] = null;
j += 1;
}
j = i - this.b;
i = paramInt - j;
this.b = (j + this.b & this.d);
} while (i <= 0);
paramInt = 0;
while (paramInt < i)
{
this.a[paramInt] = null;
paramInt += 1;
}
this.b = i;
}
public final int size()
{
return this.c - this.b & this.d;
}
}
/* Location: /home/merong/decompile/hackery-dex2jar.jar!/android/support/v4/util/CircularArray.class
* Java compiler version: 6 (50.0)
* JD-Core Version: 0.7.1
*/