CompactByteArray.java
2.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
/*
* Decompiled with CFR 0_118.
*/
package com.adobe.agl.util;
public final class CompactByteArray
implements Cloneable {
private byte[] values = new byte[65536];
private char[] indices = new char[512];
private int[] hashes = new int[512];
private boolean isCompact;
byte defaultValue;
public CompactByteArray() {
this(0);
}
public CompactByteArray(byte defaultValue) {
int i;
for (i = 0; i < 65536; ++i) {
this.values[i] = defaultValue;
}
for (i = 0; i < 512; ++i) {
this.indices[i] = (char)(i << 7);
this.hashes[i] = 0;
}
this.isCompact = false;
this.defaultValue = defaultValue;
}
public byte elementAt(char index) {
return this.values[(this.indices[index >> 7] & 65535) + (index & 127)];
}
public Object clone() {
try {
CompactByteArray other = (CompactByteArray)super.clone();
other.values = (byte[])this.values.clone();
other.indices = (char[])this.indices.clone();
if (this.hashes != null) {
other.hashes = (int[])this.hashes.clone();
}
return other;
}
catch (CloneNotSupportedException e) {
throw new IllegalStateException();
}
}
public boolean equals(Object obj) {
if (obj == null) {
return false;
}
if (this == obj) {
return true;
}
if (this.getClass() != obj.getClass()) {
return false;
}
CompactByteArray other = (CompactByteArray)obj;
for (int i = 0; i < 65536; ++i) {
if (this.elementAt((char)i) == other.elementAt((char)i)) continue;
return false;
}
return true;
}
public int hashCode() {
int result = 0;
int increment = Math.min(3, this.values.length / 16);
for (int i = 0; i < this.values.length; i += increment) {
result = result * 37 + this.values[i];
}
return result;
}
}