home *** CD-ROM | disk | FTP | other *** search
- package java.io;
-
- import java.util.Arrays;
-
- class ObjectOutputStream$HandleTable {
- private int size;
- private int threshold;
- private final float loadFactor;
- private int[] spine;
- private int[] next;
- private Object[] objs;
-
- ObjectOutputStream$HandleTable(int var1, float var2) {
- this.loadFactor = var2;
- this.spine = new int[var1];
- this.next = new int[var1];
- this.objs = new Object[var1];
- this.threshold = (int)((float)var1 * var2);
- this.clear();
- }
-
- int assign(Object var1) {
- if (this.size >= this.next.length) {
- this.growEntries();
- }
-
- if (this.size >= this.threshold) {
- this.growSpine();
- }
-
- this.insert(var1, this.size);
- return this.size++;
- }
-
- int lookup(Object var1) {
- if (this.size == 0) {
- return -1;
- } else {
- int var2 = this.hash(var1) % this.spine.length;
-
- for(int var3 = this.spine[var2]; var3 >= 0; var3 = this.next[var3]) {
- if (this.objs[var3] == var1) {
- return var3;
- }
- }
-
- return -1;
- }
- }
-
- void clear() {
- Arrays.fill(this.spine, -1);
- Arrays.fill(this.objs, 0, this.size, (Object)null);
- this.size = 0;
- }
-
- int size() {
- return this.size;
- }
-
- private void insert(Object var1, int var2) {
- int var3 = this.hash(var1) % this.spine.length;
- this.objs[var2] = var1;
- this.next[var2] = this.spine[var3];
- this.spine[var3] = var2;
- }
-
- private void growSpine() {
- this.spine = new int[(this.spine.length << 1) + 1];
- this.threshold = (int)((float)this.spine.length * this.loadFactor);
- Arrays.fill(this.spine, -1);
-
- for(int var1 = 0; var1 < this.size; ++var1) {
- this.insert(this.objs[var1], var1);
- }
-
- }
-
- private void growEntries() {
- int var1 = (this.next.length << 1) + 1;
- int[] var2 = new int[var1];
- System.arraycopy(this.next, 0, var2, 0, this.size);
- this.next = var2;
- Object[] var3 = new Object[var1];
- System.arraycopy(this.objs, 0, var3, 0, this.size);
- this.objs = var3;
- }
-
- private int hash(Object var1) {
- return System.identityHashCode(var1) & Integer.MAX_VALUE;
- }
- }
-