Class Huffman



  • public final class Huffman
    extends java.lang.Object
    Huffman coding table.

    Instances of this class are safe for use by multiple threads.

    Since:
    9
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static Huffman INSTANCE
      Shared instance.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      int lengthOf(java.lang.CharSequence value)
      Calculates the number of bytes required to represent the given CharSequence with the Huffman coding.
      int lengthOf(java.lang.CharSequence value, int start, int end)
      Calculates the number of bytes required to represent a subsequence of the given CharSequence with the Huffman coding.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • INSTANCE

        public static final Huffman INSTANCE
        Shared instance.
    • Method Detail

      • lengthOf

        public int lengthOf(java.lang.CharSequence value)
        Calculates the number of bytes required to represent the given CharSequence with the Huffman coding.
        Parameters:
        value - characters
        Returns:
        number of bytes
        Throws:
        java.lang.NullPointerException - if the value is null
      • lengthOf

        public int lengthOf(java.lang.CharSequence value,
                            int start,
                            int end)
        Calculates the number of bytes required to represent a subsequence of the given CharSequence with the Huffman coding.
        Parameters:
        value - characters
        start - the start index, inclusive
        end - the end index, exclusive
        Returns:
        number of bytes
        Throws:
        java.lang.NullPointerException - if the value is null
        java.lang.IndexOutOfBoundsException - if any invocation of value.charAt(i), where start <= i < end would throw an IndexOutOfBoundsException