CircularIntArray.java
3.09 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
package android.support.v4.util;
public final class CircularIntArray
{
private int[] a;
private int b;
private int c;
private int d;
public CircularIntArray()
{
this(8);
}
public CircularIntArray(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 = new int[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");
}
int[] arrayOfInt = new int[k];
System.arraycopy(this.a, this.b, arrayOfInt, 0, j);
System.arraycopy(this.a, 0, arrayOfInt, j, this.b);
this.a = arrayOfInt;
this.b = 0;
this.c = i;
this.d = (k - 1);
}
public final void addFirst(int paramInt)
{
this.b = (this.b - 1 & this.d);
this.a[this.b] = paramInt;
if (this.b == this.c) {
a();
}
}
public final void addLast(int paramInt)
{
this.a[this.c] = paramInt;
this.c = (this.c + 1 & this.d);
if (this.c == this.b) {
a();
}
}
public final void clear()
{
this.c = this.b;
}
public final int get(int paramInt)
{
if ((paramInt < 0) || (paramInt >= size())) {
throw new ArrayIndexOutOfBoundsException();
}
return this.a[(this.b + paramInt & this.d)];
}
public final int getFirst()
{
if (this.b == this.c) {
throw new ArrayIndexOutOfBoundsException();
}
return this.a[this.b];
}
public final int getLast()
{
if (this.b == this.c) {
throw new ArrayIndexOutOfBoundsException();
}
return this.a[(this.c - 1 & this.d)];
}
public final boolean isEmpty()
{
return this.b == this.c;
}
public final int popFirst()
{
if (this.b == this.c) {
throw new ArrayIndexOutOfBoundsException();
}
int i = this.a[this.b];
this.b = (this.b + 1 & this.d);
return i;
}
public final int popLast()
{
if (this.b == this.c) {
throw new ArrayIndexOutOfBoundsException();
}
int i = this.c - 1 & this.d;
int j = this.a[i];
this.c = i;
return j;
}
public final void removeFromEnd(int paramInt)
{
if (paramInt <= 0) {
return;
}
if (paramInt > size()) {
throw new ArrayIndexOutOfBoundsException();
}
this.c = (this.c - paramInt & this.d);
}
public final void removeFromStart(int paramInt)
{
if (paramInt <= 0) {
return;
}
if (paramInt > size()) {
throw new ArrayIndexOutOfBoundsException();
}
this.b = (this.b + paramInt & this.d);
}
public final int size()
{
return this.c - this.b & this.d;
}
}
/* Location: /home/merong/decompile/hackery-dex2jar.jar!/android/support/v4/util/CircularIntArray.class
* Java compiler version: 6 (50.0)
* JD-Core Version: 0.7.1
*/