congrats Icon
New! Announcing Tabnine Chat Beta
Learn More
Tabnine Logo
HuTuckerCodec
Code IndexAdd Tabnine to your IDE (free)

How to use
HuTuckerCodec
in
it.unimi.dsi.compression

Best Java code snippets using it.unimi.dsi.compression.HuTuckerCodec (Showing top 20 results out of 315)

origin: it.unimi.dsi/dsiutils

@Deprecated
public PrefixCoder getCoder() { return coder(); }
@Deprecated
origin: blazegraph/database

  @Deprecated
  public Decoder getDecoder() { return decoder(); }
}
origin: com.blazegraph/dsi-utils

public HuTuckerCodec( final int[] frequency ) {
  this( intArray2LongArray( frequency ) );
}

origin: blazegraph/database

return new Object[] { new HuTuckerCodec( packedFrequency ).coder().codeWords(), char2symbol };
origin: it.unimi.dsi/dsiutils

markRec(node[minLeft], 0);
root = rebuildTree(node[minLeft]);
decoder = new TreeDecoder(root, size);
coder = new CodeWordCoder(decoder.buildCodes());
origin: blazegraph/database

codec = new HuTuckerCodec( packedFrequency );
prefixCoder = codec.coder();
decoder = codec.decoder();
origin: blazegraph/database

/** Mark recursively the height of each node. */
private void markRec( final LevelNode n, final int height ) {
  if ( n == null ) return;
  n.level = height;
  markRec( (LevelNode) n.left, height + 1 );
  markRec( (LevelNode) n.right, height + 1 );
}
origin: blazegraph/database

/** We scan recursively the tree, making a copy that uses lightweight nodes. */

private TreeDecoder.Node rebuildTree( final LevelNode n ) {
  if ( n == null ) return null;
  if ( n.symbol != -1 ) return new TreeDecoder.LeafNode( n.symbol );
  
  TreeDecoder.Node newNode = new TreeDecoder.Node();
  newNode.left = rebuildTree( (LevelNode) n.left );
  newNode.right = rebuildTree( (LevelNode) n.right );
  
  return newNode;
}
origin: it.unimi.dsi/dsiutils

private static Object[] getCoder(final Iterable<? extends CharSequence> iterable, boolean prefixFree) {
  // First of all, we gather frequencies for all Unicode characters
  long[] frequency = new long[Character.MAX_VALUE + 1];
  int maxWordLength = 0;
  CharSequence s;
  int n = 0;
  for(Iterator<? extends CharSequence> i = iterable.iterator(); i.hasNext();) {
    s = i.next();
    maxWordLength = Math.max(s.length(), maxWordLength);
    for(int j = s.length(); j-- != 0;) frequency[s.charAt(j)]++;
    n++;
  }
  // Then, we compute the number of actually used characters. We count from the start the stop character.
  int count = prefixFree ? 1 : 0;
  for(int i = frequency.length; i-- != 0;) if (frequency[i] != 0) count++;
  /* Now we remap used characters in f, building at the same time the map from characters to symbols (except for the stop character). */
  long[] packedFrequency = new long[count];
  final Char2IntMap char2symbol = new Char2IntOpenHashMap(count);
  for(int i = frequency.length, k = count; i-- != 0;) {
    if (frequency[i] != 0) {
      packedFrequency[--k] = frequency[i];
      char2symbol.put((char)i, k);
    }
  }
  if (prefixFree) packedFrequency[0] = n; // The stop character appears once in each string.
  // We now build the coder used to code the strings
  return new Object[] { new HuTuckerCodec(packedFrequency).coder().codeWords(), char2symbol };
}
origin: blazegraph/database

markRec( node[ minLeft ], 0 );
root = rebuildTree( node[ minLeft ] );
decoder = new TreeDecoder( root, size );
coder = new CodeWordCoder( decoder.buildCodes() );
origin: it.unimi.dsi/dsiutils

codec = new HuTuckerCodec(packedFrequency);
prefixCoder = codec.coder();
decoder = codec.decoder();
origin: com.blazegraph/dsi-utils

/** Mark recursively the height of each node. */
private void markRec( final LevelNode n, final int height ) {
  if ( n == null ) return;
  n.level = height;
  markRec( (LevelNode) n.left, height + 1 );
  markRec( (LevelNode) n.right, height + 1 );
}
origin: com.blazegraph/dsi-utils

/** We scan recursively the tree, making a copy that uses lightweight nodes. */

private TreeDecoder.Node rebuildTree( final LevelNode n ) {
  if ( n == null ) return null;
  if ( n.symbol != -1 ) return new TreeDecoder.LeafNode( n.symbol );
  
  TreeDecoder.Node newNode = new TreeDecoder.Node();
  newNode.left = rebuildTree( (LevelNode) n.left );
  newNode.right = rebuildTree( (LevelNode) n.right );
  
  return newNode;
}
origin: com.blazegraph/dsi-utils

return new Object[] { new HuTuckerCodec( packedFrequency ).coder().codeWords(), char2symbol };
origin: com.blazegraph/dsi-utils

markRec( node[ minLeft ], 0 );
root = rebuildTree( node[ minLeft ] );
decoder = new TreeDecoder( root, size );
coder = new CodeWordCoder( decoder.buildCodes() );
origin: com.blazegraph/dsi-utils

codec = new HuTuckerCodec( packedFrequency );
prefixCoder = codec.coder();
decoder = codec.decoder();
origin: it.unimi.dsi/dsiutils

/** Mark recursively the height of each node. */
private void markRec(final LevelNode n, final int height) {
  if (n == null) return;
  n.level = height;
  markRec((LevelNode) n.left, height + 1);
  markRec((LevelNode) n.right, height + 1);
}
origin: it.unimi.dsi/dsiutils

/** We scan recursively the tree, making a copy that uses lightweight nodes. */
private TreeDecoder.Node rebuildTree(final LevelNode n) {
  if (n == null) return null;
  if (n.symbol != -1) return new TreeDecoder.LeafNode(n.symbol);
  TreeDecoder.Node newNode = new TreeDecoder.Node();
  newNode.left = rebuildTree((LevelNode) n.left);
  newNode.right = rebuildTree((LevelNode) n.right);
  return newNode;
}
origin: blazegraph/database

@Deprecated
public PrefixCoder getCoder() { return coder(); }
@Deprecated
origin: blazegraph/database

public HuTuckerCodec( final int[] frequency ) {
  this( intArray2LongArray( frequency ) );
}

it.unimi.dsi.compressionHuTuckerCodec

Javadoc

An implementation of the Hu–Tucker optimal lexicographical prefix-free code.

The familiar Huffman coding technique can be extended so to preserve the order in which symbols are given to the coder, in the sense that if j<k, then the j-th symbol will get a code lexicographically smaller than the one assigned to the k-th symbol. This result can be obtained with a small loss in code length (for more details, see the third volume of The Art of Computer Programming).

A Hu–Tucker coder is built given an array of frequencies corresponding to each symbol. Frequency 0 symbols are allowed, but they will degrade the resulting code.

The implementation of this class is rather inefficient, and the time required to build a Hu–Tucker code is quadratic in the number of symbols. An O(n log n) implementation is possible, but it requires very sophisticated data structures.

Most used methods

  • <init>
  • coder
  • decoder
  • intArray2LongArray
  • markRec
    Mark recursively the height of each node.
  • rebuildTree
    We scan recursively the tree, making a copy that uses lightweight nodes.

Popular in Java

  • Creating JSON documents from java classes using gson
  • orElseThrow (Optional)
    Return the contained value, if present, otherwise throw an exception to be created by the provided s
  • notifyDataSetChanged (ArrayAdapter)
  • addToBackStack (FragmentTransaction)
  • HttpURLConnection (java.net)
    An URLConnection for HTTP (RFC 2616 [http://tools.ietf.org/html/rfc2616]) used to send and receive d
  • Permission (java.security)
    Legacy security code; do not use.
  • Calendar (java.util)
    Calendar is an abstract base class for converting between a Date object and a set of integer fields
  • Collections (java.util)
    This class consists exclusively of static methods that operate on or return collections. It contains
  • PriorityQueue (java.util)
    A PriorityQueue holds elements on a priority heap, which orders the elements according to their natu
  • Annotation (javassist.bytecode.annotation)
    The annotation structure.An instance of this class is returned bygetAnnotations() in AnnotationsAttr
  • Top plugins for WebStorm
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now