SparseArray.java 2.06 KB
/*
 * Decompiled with CFR 0_118.
 */
package com.adobe.fontengine;

import java.io.Serializable;
import java.util.AbstractList;
import java.util.HashMap;

public final class SparseArray
extends AbstractList
implements Serializable {
    static final long serialVersionUID = 1;
    HashMap entries = new HashMap();

    public Object get(int index) {
        Entry entry = (Entry)this.entries.get(new Integer(index));
        return entry == null ? null : entry.value;
    }

    public int size() {
        return this.entries.size();
    }

    public void add(int index, Object element) {
        this.entries.put(new Integer(index), new Entry(index, element));
    }

    public Object remove(int index) {
        return this.entries.remove(new Integer(index));
    }

    public Object set(int index, Object element) {
        Entry entry = (Entry)this.entries.get(new Integer(index));
        Object originalElement = entry.value;
        entry.value = element;
        return originalElement;
    }

    public boolean equals(Object obj) {
        if (obj == null) {
            return false;
        }
        if (obj == this) {
            return true;
        }
        if (!(obj instanceof SparseArray)) {
            return false;
        }
        return this.entries.equals(((SparseArray)obj).entries);
    }

    public int hashCode() {
        return this.entries.hashCode();
    }

    private static class Entry
    implements Serializable {
        static final long serialVersionUID = 1;
        int index;
        Object value;

        Entry(int index, Object value) {
            this.index = index;
            this.value = value;
        }

        public boolean equals(Object obj) {
            if (obj == null) {
                return false;
            }
            if (obj == this) {
                return true;
            }
            if (!(obj instanceof Entry)) {
                return false;
            }
            return this.value.equals(((Entry)obj).value);
        }

        public int hashCode() {
            return this.value.hashCode();
        }
    }

}