TrieBuilder.java 2.18 KB
/*
 * Decompiled with CFR 0_118.
 */
package com.adobe.agl.impl;

import java.util.Arrays;

public class TrieBuilder {
    protected int[] m_index_ = new int[34816];
    protected int m_indexLength_;
    protected int m_dataCapacity_;
    protected int m_dataLength_;
    protected boolean m_isLatin1Linear_;
    protected boolean m_isCompacted_;
    protected int[] m_map_;

    public boolean isInZeroBlock(int ch) {
        if (this.m_isCompacted_ || ch > 1114111 || ch < 0) {
            return true;
        }
        return this.m_index_[ch >> 5] == 0;
    }

    protected TrieBuilder() {
        this.m_map_ = new int[34849];
        this.m_isLatin1Linear_ = false;
        this.m_isCompacted_ = false;
        this.m_indexLength_ = 34816;
    }

    protected TrieBuilder(TrieBuilder table) {
        this.m_indexLength_ = table.m_indexLength_;
        System.arraycopy(table.m_index_, 0, this.m_index_, 0, this.m_indexLength_);
        this.m_dataCapacity_ = table.m_dataCapacity_;
        this.m_dataLength_ = table.m_dataLength_;
        this.m_map_ = new int[table.m_map_.length];
        System.arraycopy(table.m_map_, 0, this.m_map_, 0, this.m_map_.length);
        this.m_isLatin1Linear_ = table.m_isLatin1Linear_;
        this.m_isCompacted_ = table.m_isCompacted_;
    }

    protected static final boolean equal_int(int[] array, int start1, int start2, int length) {
        while (length > 0 && array[start1] == array[start2]) {
            ++start1;
            ++start2;
            --length;
        }
        return length == 0;
    }

    protected void findUnusedBlocks() {
        Arrays.fill(this.m_map_, 255);
        for (int i = 0; i < this.m_indexLength_; ++i) {
            this.m_map_[Math.abs((int)this.m_index_[i]) >> 5] = 0;
        }
        this.m_map_[0] = 0;
    }

    protected static final int findSameIndexBlock(int[] index, int indexLength, int otherBlock) {
        for (int block = 2048; block < indexLength; block += 32) {
            if (!TrieBuilder.equal_int(index, block, otherBlock, 32)) continue;
            return block;
        }
        return indexLength;
    }

    public static interface DataManipulate {
        public int getFoldedValue(int var1, int var2);
    }

}