PostScriptStack.java 1.7 KB
/*
 * Decompiled with CFR 0_118.
 */
package com.adobe.internal.pdftoolkit.pdf.graphics.impl;

import java.util.ArrayList;

/*
 * This class specifies class file version 49.0 but uses Java 6 signatures.  Assumed Java 6.
 */
public class PostScriptStack<T> {
    private ArrayList<T> list = new ArrayList();
    private int pos = 0;

    public T pop() {
        return this.list.get(--this.pos);
    }

    public void push(T value) {
        if (this.list.size() == this.pos) {
            this.list.add(value);
            ++this.pos;
        } else {
            this.list.set(this.pos++, value);
        }
    }

    public boolean isEmpty() {
        return this.pos == 0;
    }

    public T peek() {
        return this.list.get(this.pos - 1);
    }

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

    public void clear() {
        this.list.clear();
        this.pos = 0;
    }

    /*
     * Enabled force condition propagation
     * Lifted jumps to return sites
     */
    public boolean equals(Object obj) {
        if (this == obj) {
            return true;
        }
        PostScriptStack postScriptObj = null;
        if (obj == null) return false;
        if (obj.getClass() != this.getClass()) return false;
        postScriptObj = (PostScriptStack)obj;
        if (this.size() != postScriptObj.size()) {
            return false;
        }
        int i = 0;
        while (i < this.size()) {
            T elem1 = this.list.get(i);
            T elem2 = postScriptObj.list.get(i);
            if (elem1 == null) {
                if (elem2 != null) return false;
            } else if (!elem1.equals(elem2)) {
                return false;
            }
            ++i;
        }
        return true;
    }
}