blob: 1352c3374548e8a7339fbdcb768f8b9af142a801 [file] [log] [blame]
<!DOCTYPE HTML>
<!-- NewPage -->
<html lang="en">
<head>
<!-- Generated by javadoc (16) -->
<title>BitStream (OpenJ9 JDK 16)</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="description" content="declaration: module: openj9.dtfj, package: com.ibm.j9ddr.corereaders.tdump.zebedee.util, class: BitStream">
<meta name="generator" content="javadoc/ClassWriterImpl">
<meta name="keywords" content="com.ibm.j9ddr.corereaders.tdump.zebedee.util.BitStream class">
<meta name="keywords" content="rewind()">
<meta name="keywords" content="reset()">
<meta name="keywords" content="writeLongBits()">
<meta name="keywords" content="writeIntBits()">
<meta name="keywords" content="nextWord()">
<meta name="keywords" content="getIndex()">
<meta name="keywords" content="setIndex()">
<meta name="keywords" content="readIntBits()">
<meta name="keywords" content="readLongBits()">
<meta name="keywords" content="log2()">
<meta name="keywords" content="writeDelta()">
<meta name="keywords" content="writeGamma()">
<meta name="keywords" content="writeUnary()">
<meta name="keywords" content="readDelta()">
<meta name="keywords" content="readGamma()">
<meta name="keywords" content="readUnary()">
<meta name="keywords" content="writeVariableByte()">
<meta name="keywords" content="readVariableByte()">
<meta name="keywords" content="writeGolombRice()">
<meta name="keywords" content="readGolombRice()">
<meta name="keywords" content="memoryUsage()">
<meta name="keywords" content="main()">
<link rel="stylesheet" type="text/css" href="../../../../../../../../stylesheet.css" title="Style">
<link rel="stylesheet" type="text/css" href="../../../../../../../../script-dir/jquery-ui.min.css" title="Style">
<link rel="stylesheet" type="text/css" href="../../../../../../../../jquery-ui.overrides.css" title="Style">
<script type="text/javascript" src="../../../../../../../../script.js"></script>
<script type="text/javascript" src="../../../../../../../../script-dir/jquery-3.5.1.min.js"></script>
<script type="text/javascript" src="../../../../../../../../script-dir/jquery-ui.min.js"></script>
</head>
<body class="class-declaration-page">
<script type="text/javascript">var evenRowColor = "even-row-color";
var oddRowColor = "odd-row-color";
var tableTab = "table-tab";
var activeTableTab = "active-table-tab";
var pathtoroot = "../../../../../../../../";
loadScripts(document, 'script');</script>
<noscript>
<div>JavaScript is disabled on your browser.</div>
</noscript>
<div class="flex-box">
<header role="banner" class="flex-header">
<nav role="navigation">
<!-- ========= START OF TOP NAVBAR ======= -->
<div class="top-nav" id="navbar.top">
<div class="skip-nav"><a href="#skip.navbar.top" title="Skip navigation links">Skip navigation links</a></div>
<div class="about-language"><div style="margin-top: 9px;"><strong>OpenJ9 JDK 16</strong></div></div>
<ul id="navbar.top.firstrow" class="nav-list" title="Navigation">
<li><a href="../../../../../../../../index.html">Overview</a></li>
<li><a href="../../../../../../../module-summary.html">Module</a></li>
<li><a href="package-summary.html">Package</a></li>
<li class="nav-bar-cell1-rev">Class</li>
<li><a href="class-use/BitStream.html">Use</a></li>
<li><a href="package-tree.html">Tree</a></li>
<li><a href="../../../../../../../../deprecated-list.html">Deprecated</a></li>
<li><a href="../../../../../../../../index-files/index-1.html">Index</a></li>
<li><a href="../../../../../../../../help-doc.html">Help</a></li>
</ul>
</div>
<div class="sub-nav">
<div>
<ul class="sub-nav-list">
<li>Summary:&nbsp;</li>
<li>Nested&nbsp;|&nbsp;</li>
<li>Field&nbsp;|&nbsp;</li>
<li><a href="#constructor.summary">Constr</a>&nbsp;|&nbsp;</li>
<li><a href="#method.summary">Method</a></li>
</ul>
<ul class="sub-nav-list">
<li>Detail:&nbsp;</li>
<li>Field&nbsp;|&nbsp;</li>
<li><a href="#constructor.detail">Constr</a>&nbsp;|&nbsp;</li>
<li><a href="#method.detail">Method</a></li>
</ul>
</div>
<div class="nav-list-search"><label for="search">SEARCH:</label>
<input type="text" id="search" value="search" disabled="disabled">
<input type="reset" id="reset" value="reset" disabled="disabled">
</div>
</div>
<!-- ========= END OF TOP NAVBAR ========= -->
<span class="skip-nav" id="skip.navbar.top">
<!-- -->
</span></nav>
</header>
<div class="flex-content">
<main role="main">
<!-- ======== START OF CLASS DATA ======== -->
<div class="header">
<div class="sub-title"><span class="module-label-in-type">Module</span>&nbsp;<a href="../../../../../../../module-summary.html">openj9.dtfj</a></div>
<div class="sub-title"><span class="package-label-in-type">Package</span>&nbsp;<a href="package-summary.html">com.ibm.j9ddr.corereaders.tdump.zebedee.util</a></div>
<h1 title="Class BitStream" class="title">Class BitStream</h1>
</div>
<div class="inheritance" title="Inheritance Tree"><a href="https://docs.oracle.com/en/java/javase/16/docs/api/java.base/java/lang/Object.html" title="class or interface in java.lang" class="external-link" target="_blank">java.lang.Object</a>
<div class="inheritance">com.ibm.j9ddr.corereaders.tdump.zebedee.util.BitStream</div>
</div>
<section class="description">
<dl class="notes">
<dt>All Implemented Interfaces:</dt>
<dd><code><a href="https://docs.oracle.com/en/java/javase/16/docs/api/java.base/java/io/Serializable.html" title="class or interface in java.io" class="external-link" target="_blank">Serializable</a></code></dd>
</dl>
<hr>
<div class="type-signature"><span class="modifiers">public final class </span><span class="element-name type-name-label">BitStream</span>
<span class="extends-implements">extends <a href="https://docs.oracle.com/en/java/javase/16/docs/api/java.base/java/lang/Object.html" title="class or interface in java.lang" class="external-link" target="_blank">Object</a>
implements <a href="https://docs.oracle.com/en/java/javase/16/docs/api/java.base/java/io/Serializable.html" title="class or interface in java.io" class="external-link" target="_blank">Serializable</a></span></div>
<div class="block">This class provides a mechanism for writing and reading numbers in a bit stream. In other
words you can for instance write the number 3 in 2 bits followed by the number 1 in 3 bits
and so on, then rewind the stream and read a 2 bit number followed by a 3 bit number etc.
The stream is implemented as an array of 32-bit ints (hereafter referred to as "words")
and methods are provided to move to the next word and to get and set the current index into
the array of words. This enables you to (eg) store a number of sequences of numbers in the same
BitStream and to store the index for each sequence externally somewhere.
<p>
In addition to writing and reading numbers of fixed length, this stream also supports
variable length numbers using a variety of encodings. A good overview of the encodings
used can be found <a href="http://www.csee.umbc.edu/~ian/irF02/lectures/05Compression-for-IR.pdf">here</a>.
This <a href="http://en.wikipedia.org/wiki/Universal_code">Wikipedia article</a> also has
some cool graphs showing the scalability of the encodings.
<p>
Note that all ints are treated as unsigned. You will still get back what you put in if you
write a negative number but if you're using encoded numbers then bear in mind that (eg) -1
will be output as 0xffffffff.
<p>
Todo: might be good to wrap this class round a generic Input/OutputStream.</div>
<dl class="notes">
<dt>See Also:</dt>
<dd><a href="../../../../../../../../serialized-form.html#com.ibm.j9ddr.corereaders.tdump.zebedee.util.BitStream">Serialized Form</a></dd>
</dl>
</section>
<section class="summary">
<ul class="summary-list">
<!-- ======== CONSTRUCTOR SUMMARY ======== -->
<li>
<section class="constructor-summary" id="constructor.summary">
<h2>Constructor Summary</h2>
<div class="caption"><span>Constructors</span></div>
<div class="summary-table two-column-summary">
<div class="table-header col-first">Constructor</div>
<div class="table-header col-last">Description</div>
<div class="col-constructor-name even-row-color"><code><span class="member-name-link"><a href="#%3Cinit%3E()">BitStream</a></span>()</code></div>
<div class="col-last even-row-color">
<div class="block">Create a new BitStream with a default size of 100 bytes.</div>
</div>
<div class="col-constructor-name odd-row-color"><code><span class="member-name-link"><a href="#%3Cinit%3E(int)">BitStream</a></span>&#8203;(int&nbsp;numInts)</code></div>
<div class="col-last odd-row-color">
<div class="block">Create a new BitStream containing the given number of ints.</div>
</div>
</div>
</section>
</li>
<!-- ========== METHOD SUMMARY =========== -->
<li>
<section class="method-summary" id="method.summary">
<h2>Method Summary</h2>
<div id="method-summary-table">
<div class="table-tabs" role="tablist" aria-orientation="horizontal"><button id="method-summary-table-tab0" role="tab" aria-selected="true" aria-controls="method-summary-table.tabpanel" tabindex="0" onkeydown="switchTab(event)" onclick="show('method-summary-table', 'method-summary-table', 3)" class="active-table-tab">All Methods</button><button id="method-summary-table-tab1" role="tab" aria-selected="false" aria-controls="method-summary-table.tabpanel" tabindex="-1" onkeydown="switchTab(event)" onclick="show('method-summary-table', 'method-summary-table-tab1', 3)" class="table-tab">Static Methods</button><button id="method-summary-table-tab2" role="tab" aria-selected="false" aria-controls="method-summary-table.tabpanel" tabindex="-1" onkeydown="switchTab(event)" onclick="show('method-summary-table', 'method-summary-table-tab2', 3)" class="table-tab">Instance Methods</button><button id="method-summary-table-tab4" role="tab" aria-selected="false" aria-controls="method-summary-table.tabpanel" tabindex="-1" onkeydown="switchTab(event)" onclick="show('method-summary-table', 'method-summary-table-tab4', 3)" class="table-tab">Concrete Methods</button></div>
<div id="method-summary-table.tabpanel" role="tabpanel">
<div class="summary-table three-column-summary" aria-labelledby="method-summary-table-tab0">
<div class="table-header col-first">Modifier and Type</div>
<div class="table-header col-second">Method</div>
<div class="table-header col-last">Description</div>
<div class="col-first even-row-color method-summary-table-tab2 method-summary-table-tab4 method-summary-table"><code>int</code></div>
<div class="col-second even-row-color method-summary-table-tab2 method-summary-table-tab4 method-summary-table"><code><span class="member-name-link"><a href="#getIndex()">getIndex</a></span>()</code></div>
<div class="col-last even-row-color method-summary-table-tab2 method-summary-table-tab4 method-summary-table">
<div class="block">Returns the current word index</div>
</div>
<div class="col-first odd-row-color method-summary-table-tab1 method-summary-table-tab4 method-summary-table"><code>static int</code></div>
<div class="col-second odd-row-color method-summary-table-tab1 method-summary-table-tab4 method-summary-table"><code><span class="member-name-link"><a href="#log2(int)">log2</a></span>&#8203;(int&nbsp;n)</code></div>
<div class="col-last odd-row-color method-summary-table-tab1 method-summary-table-tab4 method-summary-table">
<div class="block">Returns the log2 of the given number.</div>
</div>
<div class="col-first even-row-color method-summary-table-tab1 method-summary-table-tab4 method-summary-table"><code>static void</code></div>
<div class="col-second even-row-color method-summary-table-tab1 method-summary-table-tab4 method-summary-table"><code><span class="member-name-link"><a href="#main(java.lang.String%5B%5D)">main</a></span>&#8203;(<a href="https://docs.oracle.com/en/java/javase/16/docs/api/java.base/java/lang/String.html" title="class or interface in java.lang" class="external-link" target="_blank">String</a>[]&nbsp;args)</code></div>
<div class="col-last even-row-color method-summary-table-tab1 method-summary-table-tab4 method-summary-table">
<div class="block">This method is provided to test the BitStream.</div>
</div>
<div class="col-first odd-row-color method-summary-table-tab2 method-summary-table-tab4 method-summary-table"><code>int</code></div>
<div class="col-second odd-row-color method-summary-table-tab2 method-summary-table-tab4 method-summary-table"><code><span class="member-name-link"><a href="#memoryUsage()">memoryUsage</a></span>()</code></div>
<div class="col-last odd-row-color method-summary-table-tab2 method-summary-table-tab4 method-summary-table">
<div class="block">Give a rough estimate of how many bytes of storage we use.</div>
</div>
<div class="col-first even-row-color method-summary-table-tab2 method-summary-table-tab4 method-summary-table"><code>void</code></div>
<div class="col-second even-row-color method-summary-table-tab2 method-summary-table-tab4 method-summary-table"><code><span class="member-name-link"><a href="#nextWord()">nextWord</a></span>()</code></div>
<div class="col-last even-row-color method-summary-table-tab2 method-summary-table-tab4 method-summary-table">
<div class="block">Move to the next full word boundary.</div>
</div>
<div class="col-first odd-row-color method-summary-table-tab2 method-summary-table-tab4 method-summary-table"><code>int</code></div>
<div class="col-second odd-row-color method-summary-table-tab2 method-summary-table-tab4 method-summary-table"><code><span class="member-name-link"><a href="#readDelta()">readDelta</a></span>()</code></div>
<div class="col-last odd-row-color method-summary-table-tab2 method-summary-table-tab4 method-summary-table">
<div class="block">Reads a delta coded integer.</div>
</div>
<div class="col-first even-row-color method-summary-table-tab2 method-summary-table-tab4 method-summary-table"><code>int</code></div>
<div class="col-second even-row-color method-summary-table-tab2 method-summary-table-tab4 method-summary-table"><code><span class="member-name-link"><a href="#readGamma()">readGamma</a></span>()</code></div>
<div class="col-last even-row-color method-summary-table-tab2 method-summary-table-tab4 method-summary-table">
<div class="block">Reads a gamma coded integer.</div>
</div>
<div class="col-first odd-row-color method-summary-table-tab2 method-summary-table-tab4 method-summary-table"><code>int</code></div>
<div class="col-second odd-row-color method-summary-table-tab2 method-summary-table-tab4 method-summary-table"><code><span class="member-name-link"><a href="#readGolombRice(int)">readGolombRice</a></span>&#8203;(int&nbsp;k)</code></div>
<div class="col-last odd-row-color method-summary-table-tab2 method-summary-table-tab4 method-summary-table">
<div class="block">Read a number using Golomb-Rice coding.</div>
</div>
<div class="col-first even-row-color method-summary-table-tab2 method-summary-table-tab4 method-summary-table"><code>int</code></div>
<div class="col-second even-row-color method-summary-table-tab2 method-summary-table-tab4 method-summary-table"><code><span class="member-name-link"><a href="#readIntBits(int)">readIntBits</a></span>&#8203;(int&nbsp;len)</code></div>
<div class="col-last even-row-color method-summary-table-tab2 method-summary-table-tab4 method-summary-table">
<div class="block">Read an int from given number of bits.</div>
</div>
<div class="col-first odd-row-color method-summary-table-tab2 method-summary-table-tab4 method-summary-table"><code>long</code></div>
<div class="col-second odd-row-color method-summary-table-tab2 method-summary-table-tab4 method-summary-table"><code><span class="member-name-link"><a href="#readLongBits(int)">readLongBits</a></span>&#8203;(int&nbsp;len)</code></div>
<div class="col-last odd-row-color method-summary-table-tab2 method-summary-table-tab4 method-summary-table">
<div class="block">Read a long from given number of bits.</div>
</div>
<div class="col-first even-row-color method-summary-table-tab2 method-summary-table-tab4 method-summary-table"><code>int</code></div>
<div class="col-second even-row-color method-summary-table-tab2 method-summary-table-tab4 method-summary-table"><code><span class="member-name-link"><a href="#readUnary()">readUnary</a></span>()</code></div>
<div class="col-last even-row-color method-summary-table-tab2 method-summary-table-tab4 method-summary-table">
<div class="block">Read a unary coded integer.</div>
</div>
<div class="col-first odd-row-color method-summary-table-tab2 method-summary-table-tab4 method-summary-table"><code>int</code></div>
<div class="col-second odd-row-color method-summary-table-tab2 method-summary-table-tab4 method-summary-table"><code><span class="member-name-link"><a href="#readVariableByte()">readVariableByte</a></span>()</code></div>
<div class="col-last odd-row-color method-summary-table-tab2 method-summary-table-tab4 method-summary-table">
<div class="block">Read a number using variable byte code.</div>
</div>
<div class="col-first even-row-color method-summary-table-tab2 method-summary-table-tab4 method-summary-table"><code>void</code></div>
<div class="col-second even-row-color method-summary-table-tab2 method-summary-table-tab4 method-summary-table"><code><span class="member-name-link"><a href="#reset()">reset</a></span>()</code></div>
<div class="col-last even-row-color method-summary-table-tab2 method-summary-table-tab4 method-summary-table">
<div class="block">Resets the stream so that it may be used again for writing.</div>
</div>
<div class="col-first odd-row-color method-summary-table-tab2 method-summary-table-tab4 method-summary-table"><code>void</code></div>
<div class="col-second odd-row-color method-summary-table-tab2 method-summary-table-tab4 method-summary-table"><code><span class="member-name-link"><a href="#rewind()">rewind</a></span>()</code></div>
<div class="col-last odd-row-color method-summary-table-tab2 method-summary-table-tab4 method-summary-table">
<div class="block">Rewinds the stream ready for reading.</div>
</div>
<div class="col-first even-row-color method-summary-table-tab2 method-summary-table-tab4 method-summary-table"><code>void</code></div>
<div class="col-second even-row-color method-summary-table-tab2 method-summary-table-tab4 method-summary-table"><code><span class="member-name-link"><a href="#setIndex(int)">setIndex</a></span>&#8203;(int&nbsp;index)</code></div>
<div class="col-last even-row-color method-summary-table-tab2 method-summary-table-tab4 method-summary-table">
<div class="block">Sets the word index to the given value.</div>
</div>
<div class="col-first odd-row-color method-summary-table-tab2 method-summary-table-tab4 method-summary-table"><code>int</code></div>
<div class="col-second odd-row-color method-summary-table-tab2 method-summary-table-tab4 method-summary-table"><code><span class="member-name-link"><a href="#writeDelta(int)">writeDelta</a></span>&#8203;(int&nbsp;n)</code></div>
<div class="col-last odd-row-color method-summary-table-tab2 method-summary-table-tab4 method-summary-table">
<div class="block">Outputs the unsigned integer using delta coding.</div>
</div>
<div class="col-first even-row-color method-summary-table-tab2 method-summary-table-tab4 method-summary-table"><code>int</code></div>
<div class="col-second even-row-color method-summary-table-tab2 method-summary-table-tab4 method-summary-table"><code><span class="member-name-link"><a href="#writeGamma(int)">writeGamma</a></span>&#8203;(int&nbsp;n)</code></div>
<div class="col-last even-row-color method-summary-table-tab2 method-summary-table-tab4 method-summary-table">
<div class="block">Outputs the given unsigned integer using gamma coding.</div>
</div>
<div class="col-first odd-row-color method-summary-table-tab2 method-summary-table-tab4 method-summary-table"><code>int</code></div>
<div class="col-second odd-row-color method-summary-table-tab2 method-summary-table-tab4 method-summary-table"><code><span class="member-name-link"><a href="#writeGolombRice(int,int)">writeGolombRice</a></span>&#8203;(int&nbsp;n,
int&nbsp;k)</code></div>
<div class="col-last odd-row-color method-summary-table-tab2 method-summary-table-tab4 method-summary-table">
<div class="block">Write a number using Golomb-Rice coding.</div>
</div>
<div class="col-first even-row-color method-summary-table-tab2 method-summary-table-tab4 method-summary-table"><code>void</code></div>
<div class="col-second even-row-color method-summary-table-tab2 method-summary-table-tab4 method-summary-table"><code><span class="member-name-link"><a href="#writeIntBits(int,int)">writeIntBits</a></span>&#8203;(int&nbsp;n,
int&nbsp;len)</code></div>
<div class="col-last even-row-color method-summary-table-tab2 method-summary-table-tab4 method-summary-table">
<div class="block">Write a number into the given number of bits.</div>
</div>
<div class="col-first odd-row-color method-summary-table-tab2 method-summary-table-tab4 method-summary-table"><code>void</code></div>
<div class="col-second odd-row-color method-summary-table-tab2 method-summary-table-tab4 method-summary-table"><code><span class="member-name-link"><a href="#writeLongBits(long,int)">writeLongBits</a></span>&#8203;(long&nbsp;n,
int&nbsp;len)</code></div>
<div class="col-last odd-row-color method-summary-table-tab2 method-summary-table-tab4 method-summary-table">
<div class="block">Write a number into the given number of bits.</div>
</div>
<div class="col-first even-row-color method-summary-table-tab2 method-summary-table-tab4 method-summary-table"><code>int</code></div>
<div class="col-second even-row-color method-summary-table-tab2 method-summary-table-tab4 method-summary-table"><code><span class="member-name-link"><a href="#writeUnary(int)">writeUnary</a></span>&#8203;(int&nbsp;n)</code></div>
<div class="col-last even-row-color method-summary-table-tab2 method-summary-table-tab4 method-summary-table">
<div class="block">Outputs the given unsigned integer as a unary number.</div>
</div>
<div class="col-first odd-row-color method-summary-table-tab2 method-summary-table-tab4 method-summary-table"><code>int</code></div>
<div class="col-second odd-row-color method-summary-table-tab2 method-summary-table-tab4 method-summary-table"><code><span class="member-name-link"><a href="#writeVariableByte(int)">writeVariableByte</a></span>&#8203;(int&nbsp;n)</code></div>
<div class="col-last odd-row-color method-summary-table-tab2 method-summary-table-tab4 method-summary-table">
<div class="block">Write a number using variable byte code.</div>
</div>
</div>
</div>
</div>
<div class="inherited-list">
<h3 id="methods.inherited.from.class.java.lang.Object">Methods declared in class&nbsp;java.lang.<a href="https://docs.oracle.com/en/java/javase/16/docs/api/java.base/java/lang/Object.html" title="class or interface in java.lang" class="external-link" target="_blank">Object</a></h3>
<code><a href="https://docs.oracle.com/en/java/javase/16/docs/api/java.base/java/lang/Object.html#clone()" title="class or interface in java.lang" class="external-link" target="_blank">clone</a>, <a href="https://docs.oracle.com/en/java/javase/16/docs/api/java.base/java/lang/Object.html#equals(java.lang.Object)" title="class or interface in java.lang" class="external-link" target="_blank">equals</a>, <a href="https://docs.oracle.com/en/java/javase/16/docs/api/java.base/java/lang/Object.html#finalize()" title="class or interface in java.lang" class="external-link" target="_blank">finalize</a>, <a href="https://docs.oracle.com/en/java/javase/16/docs/api/java.base/java/lang/Object.html#getClass()" title="class or interface in java.lang" class="external-link" target="_blank">getClass</a>, <a href="https://docs.oracle.com/en/java/javase/16/docs/api/java.base/java/lang/Object.html#hashCode()" title="class or interface in java.lang" class="external-link" target="_blank">hashCode</a>, <a href="https://docs.oracle.com/en/java/javase/16/docs/api/java.base/java/lang/Object.html#notify()" title="class or interface in java.lang" class="external-link" target="_blank">notify</a>, <a href="https://docs.oracle.com/en/java/javase/16/docs/api/java.base/java/lang/Object.html#notifyAll()" title="class or interface in java.lang" class="external-link" target="_blank">notifyAll</a>, <a href="https://docs.oracle.com/en/java/javase/16/docs/api/java.base/java/lang/Object.html#toString()" title="class or interface in java.lang" class="external-link" target="_blank">toString</a>, <a href="https://docs.oracle.com/en/java/javase/16/docs/api/java.base/java/lang/Object.html#wait()" title="class or interface in java.lang" class="external-link" target="_blank">wait</a>, <a href="https://docs.oracle.com/en/java/javase/16/docs/api/java.base/java/lang/Object.html#wait(long)" title="class or interface in java.lang" class="external-link" target="_blank">wait</a>, <a href="https://docs.oracle.com/en/java/javase/16/docs/api/java.base/java/lang/Object.html#wait(long,int)" title="class or interface in java.lang" class="external-link" target="_blank">wait</a></code></div>
</section>
</li>
</ul>
</section>
<section class="details">
<ul class="details-list">
<!-- ========= CONSTRUCTOR DETAIL ======== -->
<li>
<section class="constructor-details" id="constructor.detail">
<h2>Constructor Details</h2>
<ul class="member-list">
<li>
<section class="detail" id="&lt;init&gt;()">
<h3>BitStream</h3>
<div class="member-signature"><span class="modifiers">public</span>&nbsp;<span class="element-name">BitStream</span>()</div>
<div class="block">Create a new BitStream with a default size of 100 bytes.</div>
</section>
</li>
<li>
<section class="detail" id="&lt;init&gt;(int)">
<h3>BitStream</h3>
<div class="member-signature"><span class="modifiers">public</span>&nbsp;<span class="element-name">BitStream</span>&#8203;<span class="parameters">(int&nbsp;numInts)</span></div>
<div class="block">Create a new BitStream containing the given number of ints. The BitStream is
implemented as an array of ints which will grow if necessary.</div>
<dl class="notes">
<dt>Parameters:</dt>
<dd><code>numInts</code> - the initial size of the array of ints</dd>
</dl>
</section>
</li>
</ul>
</section>
</li>
<!-- ============ METHOD DETAIL ========== -->
<li>
<section class="method-details" id="method.detail">
<h2>Method Details</h2>
<ul class="member-list">
<li>
<section class="detail" id="rewind()">
<h3>rewind</h3>
<div class="member-signature"><span class="modifiers">public</span>&nbsp;<span class="return-type">void</span>&nbsp;<span class="element-name">rewind</span>()</div>
<div class="block">Rewinds the stream ready for reading.</div>
</section>
</li>
<li>
<section class="detail" id="reset()">
<h3>reset</h3>
<div class="member-signature"><span class="modifiers">public</span>&nbsp;<span class="return-type">void</span>&nbsp;<span class="element-name">reset</span>()</div>
<div class="block">Resets the stream so that it may be used again for writing.</div>
</section>
</li>
<li>
<section class="detail" id="writeLongBits(long,int)">
<h3>writeLongBits</h3>
<div class="member-signature"><span class="modifiers">public</span>&nbsp;<span class="return-type">void</span>&nbsp;<span class="element-name">writeLongBits</span>&#8203;<span class="parameters">(long&nbsp;n,
int&nbsp;len)</span></div>
<div class="block">Write a number into the given number of bits.</div>
<dl class="notes">
<dt>Parameters:</dt>
<dd><code>n</code> - the number to write</dd>
<dd><code>len</code> - the number of bits to write the number to</dd>
</dl>
</section>
</li>
<li>
<section class="detail" id="writeIntBits(int,int)">
<h3>writeIntBits</h3>
<div class="member-signature"><span class="modifiers">public</span>&nbsp;<span class="return-type">void</span>&nbsp;<span class="element-name">writeIntBits</span>&#8203;<span class="parameters">(int&nbsp;n,
int&nbsp;len)</span></div>
<div class="block">Write a number into the given number of bits. Note that there is no requirement
that the given number be small enough to fit, the number written will be masked
appropriately.</div>
<dl class="notes">
<dt>Parameters:</dt>
<dd><code>n</code> - the number to write</dd>
<dd><code>len</code> - the number of bits to write the number to</dd>
</dl>
</section>
</li>
<li>
<section class="detail" id="nextWord()">
<h3>nextWord</h3>
<div class="member-signature"><span class="modifiers">public</span>&nbsp;<span class="return-type">void</span>&nbsp;<span class="element-name">nextWord</span>()</div>
<div class="block">Move to the next full word boundary.</div>
</section>
</li>
<li>
<section class="detail" id="getIndex()">
<h3>getIndex</h3>
<div class="member-signature"><span class="modifiers">public</span>&nbsp;<span class="return-type">int</span>&nbsp;<span class="element-name">getIndex</span>()</div>
<div class="block">Returns the current word index</div>
</section>
</li>
<li>
<section class="detail" id="setIndex(int)">
<h3>setIndex</h3>
<div class="member-signature"><span class="modifiers">public</span>&nbsp;<span class="return-type">void</span>&nbsp;<span class="element-name">setIndex</span>&#8203;<span class="parameters">(int&nbsp;index)</span></div>
<div class="block">Sets the word index to the given value. This also resets the bit offset to the
beginning of the word. This method must only be used when reading to start reading
a number stream from a saved position.</div>
</section>
</li>
<li>
<section class="detail" id="readIntBits(int)">
<h3>readIntBits</h3>
<div class="member-signature"><span class="modifiers">public</span>&nbsp;<span class="return-type">int</span>&nbsp;<span class="element-name">readIntBits</span>&#8203;<span class="parameters">(int&nbsp;len)</span></div>
<div class="block">Read an int from given number of bits.</div>
<dl class="notes">
<dt>Parameters:</dt>
<dd><code>len</code> - the number of bits to read the number from</dd>
</dl>
</section>
</li>
<li>
<section class="detail" id="readLongBits(int)">
<h3>readLongBits</h3>
<div class="member-signature"><span class="modifiers">public</span>&nbsp;<span class="return-type">long</span>&nbsp;<span class="element-name">readLongBits</span>&#8203;<span class="parameters">(int&nbsp;len)</span></div>
<div class="block">Read a long from given number of bits.</div>
<dl class="notes">
<dt>Parameters:</dt>
<dd><code>len</code> - the number of bits to read the number from</dd>
</dl>
</section>
</li>
<li>
<section class="detail" id="log2(int)">
<h3>log2</h3>
<div class="member-signature"><span class="modifiers">public static</span>&nbsp;<span class="return-type">int</span>&nbsp;<span class="element-name">log2</span>&#8203;<span class="parameters">(int&nbsp;n)</span></div>
<div class="block">Returns the log2 of the given number.</div>
</section>
</li>
<li>
<section class="detail" id="writeDelta(int)">
<h3>writeDelta</h3>
<div class="member-signature"><span class="modifiers">public</span>&nbsp;<span class="return-type">int</span>&nbsp;<span class="element-name">writeDelta</span>&#8203;<span class="parameters">(int&nbsp;n)</span></div>
<div class="block">Outputs the unsigned integer using delta coding. Delta coding gives better results
than gamma when larger numbers are more frequent.</div>
<dl class="notes">
<dt>Returns:</dt>
<dd>the number of bits used</dd>
</dl>
</section>
</li>
<li>
<section class="detail" id="writeGamma(int)">
<h3>writeGamma</h3>
<div class="member-signature"><span class="modifiers">public</span>&nbsp;<span class="return-type">int</span>&nbsp;<span class="element-name">writeGamma</span>&#8203;<span class="parameters">(int&nbsp;n)</span></div>
<div class="block">Outputs the given unsigned integer using gamma coding. Gamma coding is good when you
know small numbers are much more frequent than large numbers.</div>
<dl class="notes">
<dt>Returns:</dt>
<dd>the number of bits used</dd>
</dl>
</section>
</li>
<li>
<section class="detail" id="writeUnary(int)">
<h3>writeUnary</h3>
<div class="member-signature"><span class="modifiers">public</span>&nbsp;<span class="return-type">int</span>&nbsp;<span class="element-name">writeUnary</span>&#8203;<span class="parameters">(int&nbsp;n)</span></div>
<div class="block">Outputs the given unsigned integer as a unary number. Unary numbers are good for
small integers.</div>
<dl class="notes">
<dt>Returns:</dt>
<dd>the number of bits used</dd>
</dl>
</section>
</li>
<li>
<section class="detail" id="readDelta()">
<h3>readDelta</h3>
<div class="member-signature"><span class="modifiers">public</span>&nbsp;<span class="return-type">int</span>&nbsp;<span class="element-name">readDelta</span>()</div>
<div class="block">Reads a delta coded integer.</div>
</section>
</li>
<li>
<section class="detail" id="readGamma()">
<h3>readGamma</h3>
<div class="member-signature"><span class="modifiers">public</span>&nbsp;<span class="return-type">int</span>&nbsp;<span class="element-name">readGamma</span>()</div>
<div class="block">Reads a gamma coded integer.</div>
</section>
</li>
<li>
<section class="detail" id="readUnary()">
<h3>readUnary</h3>
<div class="member-signature"><span class="modifiers">public</span>&nbsp;<span class="return-type">int</span>&nbsp;<span class="element-name">readUnary</span>()</div>
<div class="block">Read a unary coded integer.</div>
</section>
</li>
<li>
<section class="detail" id="writeVariableByte(int)">
<h3>writeVariableByte</h3>
<div class="member-signature"><span class="modifiers">public</span>&nbsp;<span class="return-type">int</span>&nbsp;<span class="element-name">writeVariableByte</span>&#8203;<span class="parameters">(int&nbsp;n)</span></div>
<div class="block">Write a number using variable byte code. This is good when you have lots of
medium size numbers.</div>
<dl class="notes">
<dt>Returns:</dt>
<dd>the number of bits used</dd>
</dl>
</section>
</li>
<li>
<section class="detail" id="readVariableByte()">
<h3>readVariableByte</h3>
<div class="member-signature"><span class="modifiers">public</span>&nbsp;<span class="return-type">int</span>&nbsp;<span class="element-name">readVariableByte</span>()</div>
<div class="block">Read a number using variable byte code.</div>
</section>
</li>
<li>
<section class="detail" id="writeGolombRice(int,int)">
<h3>writeGolombRice</h3>
<div class="member-signature"><span class="modifiers">public</span>&nbsp;<span class="return-type">int</span>&nbsp;<span class="element-name">writeGolombRice</span>&#8203;<span class="parameters">(int&nbsp;n,
int&nbsp;k)</span></div>
<div class="block">Write a number using Golomb-Rice coding. Good all rounder if you choose
the right value of k, absolute rubbish otherwise!</div>
<dl class="notes">
<dt>Parameters:</dt>
<dd><code>n</code> - the unsigned number to write</dd>
<dd><code>k</code> - the number of bits to use for the remainder</dd>
<dt>Returns:</dt>
<dd>the number of bits used</dd>
</dl>
</section>
</li>
<li>
<section class="detail" id="readGolombRice(int)">
<h3>readGolombRice</h3>
<div class="member-signature"><span class="modifiers">public</span>&nbsp;<span class="return-type">int</span>&nbsp;<span class="element-name">readGolombRice</span>&#8203;<span class="parameters">(int&nbsp;k)</span></div>
<div class="block">Read a number using Golomb-Rice coding.</div>
<dl class="notes">
<dt>Parameters:</dt>
<dd><code>k</code> - the number of bits to use for the remainder</dd>
</dl>
</section>
</li>
<li>
<section class="detail" id="memoryUsage()">
<h3>memoryUsage</h3>
<div class="member-signature"><span class="modifiers">public</span>&nbsp;<span class="return-type">int</span>&nbsp;<span class="element-name">memoryUsage</span>()</div>
<div class="block">Give a rough estimate of how many bytes of storage we use. This is the actual storage
allocated so may be more that what is in use at any one time.</div>
</section>
</li>
<li>
<section class="detail" id="main(java.lang.String[])">
<h3>main</h3>
<div class="member-signature"><span class="modifiers">public static</span>&nbsp;<span class="return-type">void</span>&nbsp;<span class="element-name">main</span>&#8203;<span class="parameters">(<a href="https://docs.oracle.com/en/java/javase/16/docs/api/java.base/java/lang/String.html" title="class or interface in java.lang" class="external-link" target="_blank">String</a>[]&nbsp;args)</span></div>
<div class="block">This method is provided to test the BitStream. We need to change this to use unit
tests at some point.</div>
</section>
</li>
</ul>
</section>
</li>
</ul>
</section>
<!-- ========= END OF CLASS DATA ========= -->
</main>
<footer role="contentinfo">
<hr>
<p class="legal-copy"><small><a href="https://www.eclipse.org/openj9/" target="_blank">Eclipse OpenJ9 website.</a><br> To raise a bug report or suggest an improvement create an <a href="https://github.com/eclipse-openj9/openj9/issues" target="_blank">Eclipse Openj9 issue.</a><br> Copyright &copy; 1998, 2021, IBM Corp. and others.</small></p>
</footer>
</div>
</div>
</body>
</html>