public JPEGHuffmanTable(short[] lengths,short[] values){
  if (lengths == null || values == null || lengths.length == 0 || values.length == 0 || lengths.length > 16 || values.length > 256) {
    throw new IllegalArgumentException("Illegal lengths or values");
  }
  for (int i=0; i < lengths.length; i++) {
    if (lengths[i] < 0) {
      throw new IllegalArgumentException("lengths[" + i + "] < 0");
    }
  }
  for (int i=0; i < values.length; i++) {
    if (values[i] < 0) {
      throw new IllegalArgumentException("values[" + i + "] < 0");
    }
  }
  this.lengths=Arrays.copyOf(lengths,lengths.length);
  this.values=Arrays.copyOf(values,values.length);
  validate();
}

public JPEGHuffmanTable ( short [ ] lengths , short [ ] values ) { if ( lengths == null || values == null || lengths . length == 0 || values . length == 0 || lengths . length > 16 || values . length > 256 ) { throw new IllegalArgumentException ( "Illegal lengths or values" ) ; } for ( int i = 0 ; i < lengths . length ; i ++ ) { if ( lengths [ i ] < 0 ) { throw new IllegalArgumentException ( "lengths[" + i + "] < 0" ) ; } } for ( int i = 0 ; i < values . length ; i ++ ) { if ( values [ i ] < 0 ) { throw new IllegalArgumentException ( "values[" + i + "] < 0" ) ; } } this . lengths = Arrays . copyOf ( lengths , lengths . length ) ; this . values = Arrays . copyOf ( values , values . length ) ; validate ( ) ; }
creates a huffman table and initializes it . the input arrays are copied . the arrays must describe a possible huffman table . for example , 3 codes cannot be expressed with a single bit .
