public Huffman(int[] codeLensFromSym) { // Remember the minimum and maximum code lengths. mMinCodeLen = Math.max(Misc.min(codeLensFromSym), 1); mMaxCodeLen = Misc.max(codeLensFromSym); // Count the number of entries for each code length. int[] countsFromCodeLen = createCountsFromCodeLen(codeLensFromSym, mMaxCodeLen); // Create an array holding the maximum code values for each code length. Object[] out = new Object[2]; mMaxCodeValsFromCodeLen = createMaxCodeValsFromCodeLen(countsFromCodeLen, mMaxCodeLen, out); // Create a table to convert code values int symbols. int[] codeValsFromCodeLen = (int[])out[0]; int maxCodeVal = ((Integer)out[1]).intValue(); mSymsFromCodeVal = createSymsFromCodeVal(codeLensFromSym, codeValsFromCodeLen, maxCodeVal); }
public Huffman(int[] codeLensFromSym) { // Remember the minimum and maximum code lengths. mMinCodeLen = Math.max(Misc.min(codeLensFromSym), 1); mMaxCodeLen = Misc.max(codeLensFromSym); // Count the number of entries for each code length. int[] countsFromCodeLen = createCountsFromCodeLen(codeLensFromSym, mMaxCodeLen); // Create an array holding the maximum code values for each code length. Object[] out = new Object[2]; mMaxCodeValsFromCodeLen = createMaxCodeValsFromCodeLen(countsFromCodeLen, mMaxCodeLen, out); // Create a table to convert code values int symbols. int[] codeValsFromCodeLen = (int[])out[0]; int maxCodeVal = ((Integer)out[1]).intValue(); mSymsFromCodeVal = createSymsFromCodeVal(codeLensFromSym, codeValsFromCodeLen, maxCodeVal); }