home *** CD-ROM | disk | FTP | other *** search
- package java.text;
-
- final class CompactShortArray implements Cloneable {
- public static final int UNICODECOUNT = 65536;
- static final int BLOCKSHIFT = 7;
- static final int BLOCKCOUNT = 128;
- static final int INDEXSHIFT = 9;
- static final int INDEXCOUNT = 512;
- static final int BLOCKMASK = 127;
- private short[] values;
- private short[] indices;
- private int[] hashes;
- private boolean isCompact;
- short defaultValue;
-
- public CompactShortArray() {
- this((short)0);
- }
-
- public CompactShortArray(short var1) {
- this.values = new short[65536];
- this.indices = new short[512];
- this.hashes = new int[512];
-
- for(int var2 = 0; var2 < 65536; ++var2) {
- this.values[var2] = var1;
- }
-
- for(int var3 = 0; var3 < 512; ++var3) {
- this.indices[var3] = (short)(var3 << 7);
- this.hashes[var3] = 0;
- }
-
- this.isCompact = false;
- this.defaultValue = var1;
- }
-
- public CompactShortArray(short[] var1, short[] var2, short var3) {
- if (var1.length != 512) {
- throw new IllegalArgumentException("Index out of bounds.");
- } else {
- for(int var4 = 0; var4 < 512; ++var4) {
- short var5 = var1[var4];
- if (var5 < 0 || var5 >= var2.length + 128) {
- throw new IllegalArgumentException("Index out of bounds.");
- }
- }
-
- this.indices = var1;
- this.values = var2;
- this.isCompact = true;
- this.defaultValue = var3;
- }
- }
-
- public short elementAt(char var1) {
- return this.values[(this.indices[var1 >> 7] & '\uffff') + (var1 & 127)];
- }
-
- public void setElementAt(char var1, short var2) {
- if (this.isCompact) {
- this.expand();
- }
-
- this.values[var1] = var2;
- this.touchBlock(var1 >> 7, var2);
- }
-
- public void setElementAt(char var1, char var2, short var3) {
- if (this.isCompact) {
- this.expand();
- }
-
- for(int var4 = var1; var4 <= var2; ++var4) {
- this.values[var4] = var3;
- this.touchBlock(var4 >> 7, var3);
- }
-
- }
-
- public void compact() {
- if (!this.isCompact) {
- int var1 = 0;
- int var2 = 0;
- short var3 = -1;
-
- for(int var4 = 0; var4 < this.indices.length; var2 += 128) {
- this.indices[var4] = -1;
- boolean var5 = this.blockTouched(var4);
- if (!var5 && var3 != -1) {
- this.indices[var4] = var3;
- } else {
- int var6 = 0;
- int var7 = 0;
-
- for(var7 = 0; var7 < var1; var6 += 128) {
- if (this.hashes[var4] == this.hashes[var7] && arrayRegionMatches(this.values, var2, this.values, var6, 128)) {
- this.indices[var4] = (short)var6;
- }
-
- ++var7;
- }
-
- if (this.indices[var4] == -1) {
- System.arraycopy(this.values, var2, this.values, var6, 128);
- this.indices[var4] = (short)var6;
- this.hashes[var7] = this.hashes[var4];
- ++var1;
- if (!var5) {
- var3 = (short)var6;
- }
- }
- }
-
- ++var4;
- }
-
- int var8 = var1 * 128;
- short[] var9 = new short[var8];
- System.arraycopy(this.values, 0, var9, 0, var8);
- this.values = var9;
- this.isCompact = true;
- this.hashes = null;
- }
-
- }
-
- static final boolean arrayRegionMatches(short[] var0, int var1, short[] var2, int var3, int var4) {
- int var5 = var1 + var4;
- int var6 = var3 - var1;
-
- for(int var7 = var1; var7 < var5; ++var7) {
- if (var0[var7] != var2[var7 + var6]) {
- return false;
- }
- }
-
- return true;
- }
-
- private final void touchBlock(int var1, int var2) {
- this.hashes[var1] = this.hashes[var1] + (var2 << 1) | 1;
- }
-
- private final boolean blockTouched(int var1) {
- return this.hashes[var1] != 0;
- }
-
- public short[] getIndexArray() {
- return this.indices;
- }
-
- public short[] getStringArray() {
- return this.values;
- }
-
- public Object clone() {
- try {
- CompactShortArray var1 = (CompactShortArray)super.clone();
- var1.values = (short[])this.values.clone();
- var1.indices = (short[])this.indices.clone();
- return var1;
- } catch (CloneNotSupportedException var2) {
- throw new InternalError();
- }
- }
-
- public boolean equals(Object var1) {
- if (var1 == null) {
- return false;
- } else if (this == var1) {
- return true;
- } else if (this.getClass() != var1.getClass()) {
- return false;
- } else {
- CompactShortArray var2 = (CompactShortArray)var1;
-
- for(int var3 = 0; var3 < 65536; ++var3) {
- if (this.elementAt((char)var3) != var2.elementAt((char)var3)) {
- return false;
- }
- }
-
- return true;
- }
- }
-
- public int hashCode() {
- int var1 = 0;
- int var2 = Math.min(3, this.values.length / 16);
-
- for(int var3 = 0; var3 < this.values.length; var3 += var2) {
- var1 = var1 * 37 + this.values[var3];
- }
-
- return var1;
- }
-
- public Iterator getIterator() {
- return new Iterator(this);
- }
-
- private void expand() {
- if (this.isCompact) {
- short[] var2 = new short[65536];
-
- for(int var1 = 0; var1 < 65536; ++var1) {
- var2[var1] = this.elementAt((char)var1);
- }
-
- for(int var3 = 0; var3 < 512; ++var3) {
- this.indices[var3] = (short)(var3 << 7);
- }
-
- this.values = null;
- this.values = var2;
- this.isCompact = false;
- }
-
- }
-
- // $FF: synthetic method
- static short[] access$000(CompactShortArray var0) {
- return var0.indices;
- }
- }
-