本文整理汇总了Java中it.unimi.dsi.io.OutputBitStream.writeGamma方法的典型用法代码示例。如果您正苦于以下问题:Java OutputBitStream.writeGamma方法的具体用法?Java OutputBitStream.writeGamma怎么用?Java OutputBitStream.writeGamma使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类it.unimi.dsi.io.OutputBitStream
的用法示例。
在下文中一共展示了OutputBitStream.writeGamma方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createGraphWithFixedWidthLabels
import it.unimi.dsi.io.OutputBitStream; //导入方法依赖的package包/类
public String createGraphWithFixedWidthLabels( File basename, ImmutableGraph g, int width ) throws IllegalArgumentException, SecurityException, IOException {
final int n = g.numNodes();
System.err.println( "Testing " + n + " nodes, width " + width+ ", basename " + basename );
OutputBitStream labels = createTempBitStream( basename + "-fixedlabel" + BitStreamArcLabelledImmutableGraph.LABELS_EXTENSION );
OutputBitStream offsets = createTempBitStream( basename + "-fixedlabel" + BitStreamArcLabelledImmutableGraph.LABEL_OFFSETS_EXTENSION );
offsets.writeGamma( 0 );
for( int i = 0; i < n; i++ ) {
int bits = 0;
for( IntIterator j = LazyIntIterators.eager( g.successors( i ) ); j.hasNext(); ) bits += labels.writeInt( i * j.nextInt() + i, width );
offsets.writeGamma( bits );
}
labels.close();
offsets.close();
PrintWriter pw = new PrintWriter( new FileWriter( basename + "-fixedlabel.properties" ) );
pw.println( ImmutableGraph.GRAPHCLASS_PROPERTY_KEY + " = " + BitStreamArcLabelledImmutableGraph.class.getName() );
pw.println( BitStreamArcLabelledImmutableGraph.LABELSPEC_PROPERTY_KEY + " = " + FixedWidthIntLabel.class.getName() + "(TEST," + width + ")" );
pw.println( ArcLabelledImmutableGraph.UNDERLYINGGRAPH_PROPERTY_KEY + " = " + basename.getName() );
pw.close();
return basename + "-fixedlabel";
}
示例2: createGraphWithGammaLabels
import it.unimi.dsi.io.OutputBitStream; //导入方法依赖的package包/类
public String createGraphWithGammaLabels( File basename, ImmutableGraph g ) throws IllegalArgumentException, SecurityException, IOException {
// We create a complete graph with labels
final int n = g.numNodes();
System.err.println( "Testing " + n + " nodes, gamma coding, basename " + basename );
OutputBitStream labels = createTempBitStream( basename + "-gammalabel" + BitStreamArcLabelledImmutableGraph.LABELS_EXTENSION );
OutputBitStream offsets = createTempBitStream( basename + "-gammalabel" + BitStreamArcLabelledImmutableGraph.LABEL_OFFSETS_EXTENSION );
offsets.writeGamma( 0 );
for( int i = 0; i < n; i++ ) {
int bits = 0;
for( IntIterator j = LazyIntIterators.eager( g.successors( i ) ); j.hasNext(); ) bits += labels.writeGamma( i * j.nextInt() + i );
offsets.writeGamma( bits );
}
labels.close();
offsets.close();
PrintWriter pw = new PrintWriter( new FileWriter( basename + "-gammalabel" + ImmutableGraph.PROPERTIES_EXTENSION ) );
pw.println( ImmutableGraph.GRAPHCLASS_PROPERTY_KEY + " = " + BitStreamArcLabelledImmutableGraph.class.getName() );
pw.println( BitStreamArcLabelledImmutableGraph.LABELSPEC_PROPERTY_KEY + " = " + GammaCodedIntLabel.class.getName() + "(TEST)" );
pw.println( ArcLabelledImmutableGraph.UNDERLYINGGRAPH_PROPERTY_KEY + " = " + basename.getName() );
pw.close();
return basename + "-gammalabel";
}
示例3: store
import it.unimi.dsi.io.OutputBitStream; //导入方法依赖的package包/类
public static void store( final ArcLabelledImmutableGraph graph, final CharSequence basename, final CharSequence underlyingBasename, final ProgressLogger pl ) throws IOException {
final OutputBitStream labels = new OutputBitStream( basename + LABELS_EXTENSION, STD_BUFFER_SIZE );
final OutputBitStream offsets = new OutputBitStream( basename + LABEL_OFFSETS_EXTENSION, STD_BUFFER_SIZE );
if ( pl != null ) {
pl.itemsName = "nodes";
pl.expectedUpdates = graph.numNodes();
pl.start( "Saving labels..." );
}
final ArcLabelledNodeIterator nodeIterator = graph.nodeIterator();
offsets.writeGamma( 0 );
int curr;
long count;
LabelledArcIterator successors;
while( nodeIterator.hasNext() ) {
curr = nodeIterator.nextInt();
successors = nodeIterator.successors();
count = 0;
while( successors.nextInt() != -1 ) count += successors.label().toBitStream( labels, curr );
offsets.writeLongGamma( count );
if ( pl != null ) pl.lightUpdate();
}
if ( pl != null ) pl.done();
labels.close();
offsets.close();
final PrintWriter properties = new PrintWriter( new FileOutputStream( basename + ImmutableGraph.PROPERTIES_EXTENSION ) );
properties.println( ImmutableGraph.GRAPHCLASS_PROPERTY_KEY + " = " + BitStreamArcLabelledImmutableGraph.class.getName() );
properties.println( ArcLabelledImmutableGraph.UNDERLYINGGRAPH_PROPERTY_KEY + " = " + underlyingBasename );
properties.println( BitStreamArcLabelledImmutableGraph.LABELSPEC_PROPERTY_KEY + " = " + graph.prototype().toSpec() );
properties.close();
}
示例4: writeOutdegree
import it.unimi.dsi.io.OutputBitStream; //导入方法依赖的package包/类
/** Writes an outdegree to the given stream.
*
* @param obs a graph-file output bit stream.
* @param d an outdegree to be stored in the stream.
* @return the number of bits written.
*/
protected final int writeOutdegree( final OutputBitStream obs, final int d ) throws IOException {
switch( outdegreeCoding ) {
case GAMMA: return obs.writeGamma( d );
case DELTA: return obs.writeDelta( d );
default: throw new UnsupportedOperationException( "The required outdegree coding (" + outdegreeCoding + ") is not supported." );
}
}
示例5: writeReference
import it.unimi.dsi.io.OutputBitStream; //导入方法依赖的package包/类
/** Writes a reference to the given stream.
*
* @param obs a graph-file output bit stream.
* @param ref the reference.
* @return the number of bits written.
*/
protected final int writeReference( final OutputBitStream obs, final int ref ) throws IOException {
if ( ref > windowSize ) throw new IllegalStateException( "The required reference (" + ref + ") is incompatible with the window size (" + windowSize + ")" );
switch( referenceCoding ) {
case UNARY: return obs.writeUnary( ref );
case GAMMA: return obs.writeGamma( ref );
case DELTA: return obs.writeDelta( ref );
default: throw new UnsupportedOperationException( "The required reference coding (" + referenceCoding + ") is not supported." );
}
}
示例6: writeBlockCount
import it.unimi.dsi.io.OutputBitStream; //导入方法依赖的package包/类
/** Writes a block count to the given stream.
*
* @param obs a graph-file output bit stream.
* @param count the block count.
* @return the number of written bits.
*/
protected final int writeBlockCount( final OutputBitStream obs, final int count ) throws IOException {
switch( blockCountCoding ) {
case UNARY: return obs.writeUnary( count );
case GAMMA: return obs.writeGamma( count );
case DELTA: return obs.writeDelta( count );
default: throw new UnsupportedOperationException( "The required block count coding (" + blockCountCoding + ") is not supported." );
}
}
示例7: writeBlock
import it.unimi.dsi.io.OutputBitStream; //导入方法依赖的package包/类
/** Writes a block to the given stream.
*
* @param obs a graph-file output bit stream.
* @param block the block.
* @return the number of written bits.
*/
protected final int writeBlock( final OutputBitStream obs, final int block ) throws IOException {
switch( blockCoding ) {
case UNARY: return obs.writeUnary( block );
case GAMMA: return obs.writeGamma( block );
case DELTA: return obs.writeDelta( block );
default: throw new UnsupportedOperationException( "The required block coding (" + blockCoding + ") is not supported." );
}
}
示例8: writeResidual
import it.unimi.dsi.io.OutputBitStream; //导入方法依赖的package包/类
/** Writes a residual to the given stream.
*
* @param obs a graph-file output bit stream.
* @param residual the residual.
* @return the number of written bits.
*/
protected final int writeResidual( final OutputBitStream obs, final int residual ) throws IOException {
switch( residualCoding ) {
case GAMMA: return obs.writeGamma( residual );
case ZETA: return obs.writeZeta( residual, zetaK );
case DELTA: return obs.writeDelta( residual );
case GOLOMB: return obs.writeGolomb( residual, zetaK );
case NIBBLE: return obs.writeNibble( residual );
default: throw new UnsupportedOperationException( "The required residuals coding (" + residualCoding + ") is not supported." );
}
}
示例9: createGraph
import it.unimi.dsi.io.OutputBitStream; //导入方法依赖的package包/类
public String createGraph( File basename, ImmutableGraph g, int width ) throws IllegalArgumentException, SecurityException, IOException {
final int n = g.numNodes();
System.err.println( "Testing " + n + " nodes, width " + width+ ", basename " + basename );
OutputBitStream labels = new OutputBitStream( basename + "-fixedlabel" + BitStreamArcLabelledImmutableGraph.LABELS_EXTENSION );
OutputBitStream offsets = new OutputBitStream( basename + "-fixedlabel" + BitStreamArcLabelledImmutableGraph.LABEL_OFFSETS_EXTENSION );
Label lab;
offsets.writeGamma( 0 );
for( int i = 0; i < n; i++ ) {
int bits = 0;
for( IntIterator j = LazyIntIterators.eager( g.successors( i ) ); j.hasNext(); ) {
int succ = j.nextInt();
lab = new FakeCSFixedWidthIntLabel( "TEST", width, i * succ + i );
bits += lab.toBitStream( labels, i );
}
offsets.writeGamma( bits );
}
labels.close();
offsets.close();
PrintWriter pw = new PrintWriter( new FileWriter( basename + "-fixedlabel" + ImmutableGraph.PROPERTIES_EXTENSION ) );
pw.println( ImmutableGraph.GRAPHCLASS_PROPERTY_KEY + " = " + BitStreamArcLabelledImmutableGraph.class.getName() );
pw.println( BitStreamArcLabelledImmutableGraph.LABELSPEC_PROPERTY_KEY + " = " + FakeCSFixedWidthIntLabel.class.getName() + "(TEST," + width + ")" );
pw.println( ArcLabelledImmutableGraph.UNDERLYINGGRAPH_PROPERTY_KEY + " = " + basename.getName() );
pw.close();
return basename + "-fixedlabel";
}
示例10: createGraphWithFixedWidthListLabels
import it.unimi.dsi.io.OutputBitStream; //导入方法依赖的package包/类
public String createGraphWithFixedWidthListLabels( File basename, ImmutableGraph g, int width ) throws IllegalArgumentException, SecurityException, IOException {
final int n = g.numNodes();
System.err.println( "Testing " + n + " nodes, element width " + width+ ", basename " + basename );
OutputBitStream labels = createTempBitStream( basename + "-fixedlistlabel" + BitStreamArcLabelledImmutableGraph.LABELS_EXTENSION );
OutputBitStream offsets = createTempBitStream( basename + "-fixedlistlabel" + BitStreamArcLabelledImmutableGraph.LABEL_OFFSETS_EXTENSION );
offsets.writeGamma( 0 );
for( int i = 0; i < n; i++ ) {
int bits = 0;
for( IntIterator j = LazyIntIterators.eager( g.successors( i ) ); j.hasNext(); ) {
int succ = j.nextInt();
bits += labels.writeGamma( ( succ + 1 ) * 2 ); // list length
for( int k = 0; k < ( succ + 1 ) * 2 ; k++ ) bits += labels.writeInt( i * k + i, width );
}
offsets.writeGamma( bits );
}
labels.close();
offsets.close();
PrintWriter pw = new PrintWriter( new FileWriter( basename + "-fixedlistlabel" + ImmutableGraph.PROPERTIES_EXTENSION ) );
pw.println( ImmutableGraph.GRAPHCLASS_PROPERTY_KEY + " = " + BitStreamArcLabelledImmutableGraph.class.getName() );
pw.println( BitStreamArcLabelledImmutableGraph.LABELSPEC_PROPERTY_KEY + " = " + FixedWidthIntListLabel.class.getName() + "(TEST," + width + ")" );
pw.println( ArcLabelledImmutableGraph.UNDERLYINGGRAPH_PROPERTY_KEY + " = " + basename.getName() );
pw.close();
return basename + "-fixedlistlabel";
}
示例11: write
import it.unimi.dsi.io.OutputBitStream; //导入方法依赖的package包/类
@Override
protected void write(OutputBitStream obs, int[] in, int offset, int len) throws IOException {
for (int i = offset; i < offset + len; i++) {
obs.writeGamma(in[i]);
}
}
示例12: toBitStream
import it.unimi.dsi.io.OutputBitStream; //导入方法依赖的package包/类
public int toBitStream( OutputBitStream outputBitStream, final int sourceUnused ) throws IOException {
int bits = outputBitStream.writeGamma( value.length );
for( int i = 0; i < value.length; i++ ) bits += outputBitStream.writeInt( value[ i ], width );
return bits;
}
示例13: toBitStream
import it.unimi.dsi.io.OutputBitStream; //导入方法依赖的package包/类
/** Writes this label {@linkplain OutputBitStream#writeGamma(int) as a γ-coded natural number}
* to the given output bit stream.
*
* @param outputBitStream an output bit stream.
* @return the number of bits written.
*/
public int toBitStream( OutputBitStream outputBitStream, final int sourceUnused ) throws IOException {
return outputBitStream.writeGamma( value );
}