blob: 7210721bc1681e0818b4bea9b2b39ac480555a72 [file] [log] [blame]
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<!-- NewPage -->
<html lang="en">
<head>
<!-- Generated by javadoc (1.8.0_162) on Thu Oct 25 17:06:10 PDT 2018 -->
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Util (com.yahoo.datasketches:sketches-core 0.12.1-SNAPSHOT API)</title>
<meta name="date" content="2018-10-25">
<link rel="stylesheet" type="text/css" href="../../../stylesheet.css" title="Style">
<script type="text/javascript" src="../../../script.js"></script>
</head>
<body>
<script type="text/javascript"><!--
try {
if (location.href.indexOf('is-external=true') == -1) {
parent.document.title="Util (com.yahoo.datasketches:sketches-core 0.12.1-SNAPSHOT API)";
}
}
catch(err) {
}
//-->
var methods = {"i0":9,"i1":9,"i2":9,"i3":9,"i4":9,"i5":9,"i6":9,"i7":9,"i8":9,"i9":9,"i10":9,"i11":9,"i12":9,"i13":9,"i14":9,"i15":9,"i16":9,"i17":9,"i18":9,"i19":9,"i20":9,"i21":9,"i22":9,"i23":9,"i24":9,"i25":9,"i26":9,"i27":9,"i28":9};
var tabs = {65535:["t0","All Methods"],1:["t1","Static Methods"],8:["t4","Concrete Methods"]};
var altColor = "altColor";
var rowColor = "rowColor";
var tableTab = "tableTab";
var activeTableTab = "activeTableTab";
</script>
<noscript>
<div>JavaScript is disabled on your browser.</div>
</noscript>
<!-- ========= START OF TOP NAVBAR ======= -->
<div class="topNav"><a name="navbar.top">
<!-- -->
</a>
<div class="skipNav"><a href="#skip.navbar.top" title="Skip navigation links">Skip navigation links</a></div>
<a name="navbar.top.firstrow">
<!-- -->
</a>
<ul class="navList" title="Navigation">
<li><a href="../../../overview-summary.html">Overview</a></li>
<li><a href="package-summary.html">Package</a></li>
<li class="navBarCell1Rev">Class</li>
<li><a href="class-use/Util.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-all.html">Index</a></li>
<li><a href="../../../help-doc.html">Help</a></li>
</ul>
</div>
<div class="subNav">
<ul class="navList">
<li><a href="../../../com/yahoo/sketches/SketchesStateException.html" title="class in com.yahoo.sketches"><span class="typeNameLink">Prev&nbsp;Class</span></a></li>
<li>Next&nbsp;Class</li>
</ul>
<ul class="navList">
<li><a href="../../../index.html?com/yahoo/sketches/Util.html" target="_top">Frames</a></li>
<li><a href="Util.html" target="_top">No&nbsp;Frames</a></li>
</ul>
<ul class="navList" id="allclasses_navbar_top">
<li><a href="../../../allclasses-noframe.html">All&nbsp;Classes</a></li>
</ul>
<div>
<script type="text/javascript"><!--
allClassesLink = document.getElementById("allclasses_navbar_top");
if(window==top) {
allClassesLink.style.display = "block";
}
else {
allClassesLink.style.display = "none";
}
//-->
</script>
</div>
<div>
<ul class="subNavList">
<li>Summary:&nbsp;</li>
<li>Nested&nbsp;|&nbsp;</li>
<li><a href="#field.summary">Field</a>&nbsp;|&nbsp;</li>
<li>Constr&nbsp;|&nbsp;</li>
<li><a href="#method.summary">Method</a></li>
</ul>
<ul class="subNavList">
<li>Detail:&nbsp;</li>
<li><a href="#field.detail">Field</a>&nbsp;|&nbsp;</li>
<li>Constr&nbsp;|&nbsp;</li>
<li><a href="#method.detail">Method</a></li>
</ul>
</div>
<a name="skip.navbar.top">
<!-- -->
</a></div>
<!-- ========= END OF TOP NAVBAR ========= -->
<!-- ======== START OF CLASS DATA ======== -->
<div class="header">
<div class="subTitle">com.yahoo.sketches</div>
<h2 title="Class Util" class="title">Class Util</h2>
</div>
<div class="contentContainer">
<ul class="inheritance">
<li><a href="https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html?is-external=true" title="class or interface in java.lang">java.lang.Object</a></li>
<li>
<ul class="inheritance">
<li>com.yahoo.sketches.Util</li>
</ul>
</li>
</ul>
<div class="description">
<ul class="blockList">
<li class="blockList">
<hr>
<br>
<pre>public final class <span class="typeNameLabel">Util</span>
extends <a href="https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html?is-external=true" title="class or interface in java.lang">Object</a></pre>
<div class="block">Common utility functions.</div>
<dl>
<dt><span class="simpleTagLabel">Author:</span></dt>
<dd>Lee Rhodes</dd>
</dl>
</li>
</ul>
</div>
<div class="summary">
<ul class="blockList">
<li class="blockList">
<!-- =========== FIELD SUMMARY =========== -->
<ul class="blockList">
<li class="blockList"><a name="field.summary">
<!-- -->
</a>
<h3>Field Summary</h3>
<table class="memberSummary" border="0" cellpadding="3" cellspacing="0" summary="Field Summary table, listing fields, and an explanation">
<caption><span>Fields</span><span class="tabEnd">&nbsp;</span></caption>
<tr>
<th class="colFirst" scope="col">Modifier and Type</th>
<th class="colLast" scope="col">Field and Description</th>
</tr>
<tr class="altColor">
<td class="colFirst"><code>static int</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../com/yahoo/sketches/Util.html#DEFAULT_NOMINAL_ENTRIES">DEFAULT_NOMINAL_ENTRIES</a></span></code>
<div class="block">The default nominal entries is provided as a convenience for those cases where the
nominal sketch size in number of entries is not provided.</div>
</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><code>static long</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../com/yahoo/sketches/Util.html#DEFAULT_UPDATE_SEED">DEFAULT_UPDATE_SEED</a></span></code>
<div class="block">The seed 9001 used in the sketch update methods is a prime number that
was chosen very early on in experimental testing.</div>
</td>
</tr>
<tr class="altColor">
<td class="colFirst"><code>static double</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../com/yahoo/sketches/Util.html#iGolden">iGolden</a></span></code>
<div class="block">The inverse golden ratio as a fraction.</div>
</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><code>static long</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../com/yahoo/sketches/Util.html#iGoldenU64">iGoldenU64</a></span></code>
<div class="block">The inverse golden ratio as an unsigned long.</div>
</td>
</tr>
<tr class="altColor">
<td class="colFirst"><code>static double</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../com/yahoo/sketches/Util.html#LOG2">LOG2</a></span></code>
<div class="block">The natural logarithm of 2.0.</div>
</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><code>static <a href="https://docs.oracle.com/javase/8/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a></code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../com/yahoo/sketches/Util.html#LS">LS</a></span></code>
<div class="block">The java line separator character as a String.</div>
</td>
</tr>
<tr class="altColor">
<td class="colFirst"><code>static int</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../com/yahoo/sketches/Util.html#MAX_LG_NOM_LONGS">MAX_LG_NOM_LONGS</a></span></code>
<div class="block">The largest Log2 nom entries allowed: 26.</div>
</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><code>static int</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../com/yahoo/sketches/Util.html#MIN_LG_ARR_LONGS">MIN_LG_ARR_LONGS</a></span></code>
<div class="block">The smallest Log2 cache size allowed: 5.</div>
</td>
</tr>
<tr class="altColor">
<td class="colFirst"><code>static int</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../com/yahoo/sketches/Util.html#MIN_LG_NOM_LONGS">MIN_LG_NOM_LONGS</a></span></code>
<div class="block">The smallest Log2 nom entries allowed: 4.</div>
</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><code>static double</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../com/yahoo/sketches/Util.html#REBUILD_THRESHOLD">REBUILD_THRESHOLD</a></span></code>
<div class="block">The hash table rebuild threshold = 15.0/16.0.</div>
</td>
</tr>
<tr class="altColor">
<td class="colFirst"><code>static double</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../com/yahoo/sketches/Util.html#RESIZE_THRESHOLD">RESIZE_THRESHOLD</a></span></code>
<div class="block">The resize threshold = 0.5; tuned for speed.</div>
</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><code>static char</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../com/yahoo/sketches/Util.html#TAB">TAB</a></span></code>
<div class="block">The tab character</div>
</td>
</tr>
</table>
</li>
</ul>
<!-- ========== METHOD SUMMARY =========== -->
<ul class="blockList">
<li class="blockList"><a name="method.summary">
<!-- -->
</a>
<h3>Method Summary</h3>
<table class="memberSummary" border="0" cellpadding="3" cellspacing="0" summary="Method Summary table, listing methods, and an explanation">
<caption><span id="t0" class="activeTableTab"><span>All Methods</span><span class="tabEnd">&nbsp;</span></span><span id="t1" class="tableTab"><span><a href="javascript:show(1);">Static Methods</a></span><span class="tabEnd">&nbsp;</span></span><span id="t4" class="tableTab"><span><a href="javascript:show(8);">Concrete Methods</a></span><span class="tabEnd">&nbsp;</span></span></caption>
<tr>
<th class="colFirst" scope="col">Modifier and Type</th>
<th class="colLast" scope="col">Method and Description</th>
</tr>
<tr id="i0" class="altColor">
<td class="colFirst"><code>static int</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../com/yahoo/sketches/Util.html#bytesToInt-byte:A-">bytesToInt</a></span>(byte[]&nbsp;arr)</code>
<div class="block">Returns an int extracted from a Little-Endian byte array.</div>
</td>
</tr>
<tr id="i1" class="rowColor">
<td class="colFirst"><code>static long</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../com/yahoo/sketches/Util.html#bytesToLong-byte:A-">bytesToLong</a></span>(byte[]&nbsp;arr)</code>
<div class="block">Returns a long extracted from a Little-Endian byte array.</div>
</td>
</tr>
<tr id="i2" class="altColor">
<td class="colFirst"><code>static <a href="https://docs.oracle.com/javase/8/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a></code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../com/yahoo/sketches/Util.html#bytesToString-byte:A-boolean-boolean-java.lang.String-">bytesToString</a></span>(byte[]&nbsp;arr,
boolean&nbsp;signed,
boolean&nbsp;littleEndian,
<a href="https://docs.oracle.com/javase/8/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a>&nbsp;sep)</code>
<div class="block">Returns a string view of a byte array</div>
</td>
</tr>
<tr id="i3" class="rowColor">
<td class="colFirst"><code>static int</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../com/yahoo/sketches/Util.html#ceilingPowerOf2-int-">ceilingPowerOf2</a></span>(int&nbsp;n)</code>
<div class="block">Computes the ceiling power of 2 within the range [1, 2^30].</div>
</td>
</tr>
<tr id="i4" class="altColor">
<td class="colFirst"><code>static <a href="https://docs.oracle.com/javase/8/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a></code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../com/yahoo/sketches/Util.html#characterPad-java.lang.String-int-char-boolean-">characterPad</a></span>(<a href="https://docs.oracle.com/javase/8/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a>&nbsp;s,
int&nbsp;fieldLength,
char&nbsp;padChar,
boolean&nbsp;postpend)</code>
<div class="block">Prepend or postpend the given string with the given character to fill the given field length.</div>
</td>
</tr>
<tr id="i5" class="rowColor">
<td class="colFirst"><code>static void</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../com/yahoo/sketches/Util.html#checkIfMultipleOf8AndGT0-long-java.lang.String-">checkIfMultipleOf8AndGT0</a></span>(long&nbsp;v,
<a href="https://docs.oracle.com/javase/8/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a>&nbsp;argName)</code>
<div class="block">Checks if parameter v is a multiple of 8 and greater than zero.</div>
</td>
</tr>
<tr id="i6" class="altColor">
<td class="colFirst"><code>static void</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../com/yahoo/sketches/Util.html#checkIfPowerOf2-int-java.lang.String-">checkIfPowerOf2</a></span>(int&nbsp;v,
<a href="https://docs.oracle.com/javase/8/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a>&nbsp;argName)</code>
<div class="block">Checks the given parameter to make sure it is positive, an integer-power of 2 and greater than
zero.</div>
</td>
</tr>
<tr id="i7" class="rowColor">
<td class="colFirst"><code>static void</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../com/yahoo/sketches/Util.html#checkProbability-double-java.lang.String-">checkProbability</a></span>(double&nbsp;p,
<a href="https://docs.oracle.com/javase/8/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a>&nbsp;argName)</code>
<div class="block">Checks the given parameter to make sure it is positive and between 0.0 inclusive and 1.0
inclusive.</div>
</td>
</tr>
<tr id="i8" class="altColor">
<td class="colFirst"><code>static short</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../com/yahoo/sketches/Util.html#checkSeedHashes-short-short-">checkSeedHashes</a></span>(short&nbsp;seedHashA,
short&nbsp;seedHashB)</code>
<div class="block">Check if the two seed hashes are equal.</div>
</td>
</tr>
<tr id="i9" class="rowColor">
<td class="colFirst"><code>static short</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../com/yahoo/sketches/Util.html#computeSeedHash-long-">computeSeedHash</a></span>(long&nbsp;seed)</code>
<div class="block">Computes and checks the 16-bit seed hash from the given long seed.</div>
</td>
</tr>
<tr id="i10" class="altColor">
<td class="colFirst"><code>static int[]</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../com/yahoo/sketches/Util.html#evenlyLgSpaced-int-int-int-">evenlyLgSpaced</a></span>(int&nbsp;lgStart,
int&nbsp;lgEnd,
int&nbsp;points)</code>
<div class="block">Returns an int array of points that will be evenly spaced on a log axis.</div>
</td>
</tr>
<tr id="i11" class="rowColor">
<td class="colFirst"><code>static int</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../com/yahoo/sketches/Util.html#floorPowerOf2-int-">floorPowerOf2</a></span>(int&nbsp;n)</code>
<div class="block">Computes the floor power of 2 within the range [1, 2^30].</div>
</td>
</tr>
<tr id="i12" class="altColor">
<td class="colFirst"><code>static byte[]</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../com/yahoo/sketches/Util.html#intToBytes-int-byte:A-">intToBytes</a></span>(int&nbsp;v,
byte[]&nbsp;arr)</code>
<div class="block">Returns a Little-Endian byte array extracted from the given int.</div>
</td>
</tr>
<tr id="i13" class="rowColor">
<td class="colFirst"><code>static double</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../com/yahoo/sketches/Util.html#invPow2-int-">invPow2</a></span>(int&nbsp;e)</code>
<div class="block">Computes the inverse integer power of 2: 1/(2^e) = 2^(-e).</div>
</td>
</tr>
<tr id="i14" class="altColor">
<td class="colFirst"><code>static boolean</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../com/yahoo/sketches/Util.html#isLessThanUnsigned-long-long-">isLessThanUnsigned</a></span>(long&nbsp;n1,
long&nbsp;n2)</code>
<div class="block">Unsigned compare with longs.</div>
</td>
</tr>
<tr id="i15" class="rowColor">
<td class="colFirst"><code>static boolean</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../com/yahoo/sketches/Util.html#isMultipleOf8AndGT0-long-">isMultipleOf8AndGT0</a></span>(long&nbsp;v)</code>
<div class="block">Returns true if v is a multiple of 8 and greater than zero</div>
</td>
</tr>
<tr id="i16" class="altColor">
<td class="colFirst"><code>static boolean</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../com/yahoo/sketches/Util.html#isPowerOf2-int-">isPowerOf2</a></span>(int&nbsp;v)</code>
<div class="block">Returns true if argument is exactly a positive power of 2 and greater than zero.</div>
</td>
</tr>
<tr id="i17" class="rowColor">
<td class="colFirst"><code>static double</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../com/yahoo/sketches/Util.html#log2-double-">log2</a></span>(double&nbsp;value)</code>
<div class="block">The log base 2 of the value</div>
</td>
</tr>
<tr id="i18" class="altColor">
<td class="colFirst"><code>static byte[]</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../com/yahoo/sketches/Util.html#longToBytes-long-byte:A-">longToBytes</a></span>(long&nbsp;v,
byte[]&nbsp;arr)</code>
<div class="block">Returns a Little-Endian byte array extracted from the given long.</div>
</td>
</tr>
<tr id="i19" class="rowColor">
<td class="colFirst"><code>static <a href="https://docs.oracle.com/javase/8/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a></code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../com/yahoo/sketches/Util.html#longToHexBytes-long-">longToHexBytes</a></span>(long&nbsp;v)</code>
<div class="block">Returns a string of spaced hex bytes in Big-Endian order.</div>
</td>
</tr>
<tr id="i20" class="altColor">
<td class="colFirst"><code>static <a href="https://docs.oracle.com/javase/8/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a></code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../com/yahoo/sketches/Util.html#milliSecToString-long-">milliSecToString</a></span>(long&nbsp;mS)</code>
<div class="block">Returns the given time in milliseconds formatted as Hours:Min:Sec.mSec</div>
</td>
</tr>
<tr id="i21" class="rowColor">
<td class="colFirst"><code>static <a href="https://docs.oracle.com/javase/8/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a></code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../com/yahoo/sketches/Util.html#nanoSecToString-long-">nanoSecToString</a></span>(long&nbsp;nS)</code>
<div class="block">Returns the given time in nanoseconds formatted as Sec.mSec uSec nSec</div>
</td>
</tr>
<tr id="i22" class="altColor">
<td class="colFirst"><code>static int</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../com/yahoo/sketches/Util.html#pwr2LawNext-int-int-">pwr2LawNext</a></span>(int&nbsp;ppo,
int&nbsp;curPoint)</code>
<div class="block">Computes the next larger integer point in the power series
<i>point = 2<sup>( i / ppo )</sup></i> given the current point in the series.</div>
</td>
</tr>
<tr id="i23" class="rowColor">
<td class="colFirst"><code>static double</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../com/yahoo/sketches/Util.html#pwr2LawNextDouble-int-double-">pwr2LawNextDouble</a></span>(int&nbsp;ppo,
double&nbsp;curPoint)</code>
<div class="block">Computes the next larger double in the power series
<i>point = 2<sup>( i / ppo )</sup></i> given the current point in the series.</div>
</td>
</tr>
<tr id="i24" class="altColor">
<td class="colFirst"><code>static int</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../com/yahoo/sketches/Util.html#pwr2LawPrev-int-int-">pwr2LawPrev</a></span>(int&nbsp;ppo,
int&nbsp;curPoint)</code>
<div class="block">Computes the previous, smaller integer point in the power series
<i>point = 2<sup>( i / ppo )</sup></i> given the current point in the series.</div>
</td>
</tr>
<tr id="i25" class="rowColor">
<td class="colFirst"><code>static int</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../com/yahoo/sketches/Util.html#simpleIntLog2-int-">simpleIntLog2</a></span>(int&nbsp;x)</code>
<div class="block">Gives the log2 of an integer that is known to be a power of 2.</div>
</td>
</tr>
<tr id="i26" class="altColor">
<td class="colFirst"><code>static int</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../com/yahoo/sketches/Util.html#startingSubMultiple-int-com.yahoo.sketches.ResizeFactor-int-">startingSubMultiple</a></span>(int&nbsp;lgTarget,
<a href="../../../com/yahoo/sketches/ResizeFactor.html" title="enum in com.yahoo.sketches">ResizeFactor</a>&nbsp;rf,
int&nbsp;lgMin)</code>
<div class="block">Gets the smallest allowed exponent of 2 that it is a sub-multiple of the target by zero,
one or more resize factors.</div>
</td>
</tr>
<tr id="i27" class="rowColor">
<td class="colFirst"><code>static int</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../com/yahoo/sketches/Util.html#toLog2-int-java.lang.String-">toLog2</a></span>(int&nbsp;value,
<a href="https://docs.oracle.com/javase/8/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a>&nbsp;argName)</code>
<div class="block">Checks the given value if it is a power of 2.</div>
</td>
</tr>
<tr id="i28" class="altColor">
<td class="colFirst"><code>static <a href="https://docs.oracle.com/javase/8/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a></code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../com/yahoo/sketches/Util.html#zeroPad-java.lang.String-int-">zeroPad</a></span>(<a href="https://docs.oracle.com/javase/8/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a>&nbsp;s,
int&nbsp;fieldLength)</code>
<div class="block">Prepend the given string with zeros.</div>
</td>
</tr>
</table>
<ul class="blockList">
<li class="blockList"><a name="methods.inherited.from.class.java.lang.Object">
<!-- -->
</a>
<h3>Methods inherited from class&nbsp;java.lang.<a href="https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html?is-external=true" title="class or interface in java.lang">Object</a></h3>
<code><a href="https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html?is-external=true#clone--" title="class or interface in java.lang">clone</a>, <a href="https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html?is-external=true#equals-java.lang.Object-" title="class or interface in java.lang">equals</a>, <a href="https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html?is-external=true#finalize--" title="class or interface in java.lang">finalize</a>, <a href="https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html?is-external=true#getClass--" title="class or interface in java.lang">getClass</a>, <a href="https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html?is-external=true#hashCode--" title="class or interface in java.lang">hashCode</a>, <a href="https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html?is-external=true#notify--" title="class or interface in java.lang">notify</a>, <a href="https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html?is-external=true#notifyAll--" title="class or interface in java.lang">notifyAll</a>, <a href="https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html?is-external=true#toString--" title="class or interface in java.lang">toString</a>, <a href="https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html?is-external=true#wait--" title="class or interface in java.lang">wait</a>, <a href="https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html?is-external=true#wait-long-" title="class or interface in java.lang">wait</a>, <a href="https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html?is-external=true#wait-long-int-" title="class or interface in java.lang">wait</a></code></li>
</ul>
</li>
</ul>
</li>
</ul>
</div>
<div class="details">
<ul class="blockList">
<li class="blockList">
<!-- ============ FIELD DETAIL =========== -->
<ul class="blockList">
<li class="blockList"><a name="field.detail">
<!-- -->
</a>
<h3>Field Detail</h3>
<a name="MIN_LG_ARR_LONGS">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>MIN_LG_ARR_LONGS</h4>
<pre>public static final&nbsp;int MIN_LG_ARR_LONGS</pre>
<div class="block">The smallest Log2 cache size allowed: 5.</div>
<dl>
<dt><span class="seeLabel">See Also:</span></dt>
<dd><a href="../../../constant-values.html#com.yahoo.sketches.Util.MIN_LG_ARR_LONGS">Constant Field Values</a></dd>
</dl>
</li>
</ul>
<a name="MIN_LG_NOM_LONGS">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>MIN_LG_NOM_LONGS</h4>
<pre>public static final&nbsp;int MIN_LG_NOM_LONGS</pre>
<div class="block">The smallest Log2 nom entries allowed: 4.</div>
<dl>
<dt><span class="seeLabel">See Also:</span></dt>
<dd><a href="../../../constant-values.html#com.yahoo.sketches.Util.MIN_LG_NOM_LONGS">Constant Field Values</a></dd>
</dl>
</li>
</ul>
<a name="MAX_LG_NOM_LONGS">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>MAX_LG_NOM_LONGS</h4>
<pre>public static final&nbsp;int MAX_LG_NOM_LONGS</pre>
<div class="block">The largest Log2 nom entries allowed: 26.</div>
<dl>
<dt><span class="seeLabel">See Also:</span></dt>
<dd><a href="../../../constant-values.html#com.yahoo.sketches.Util.MAX_LG_NOM_LONGS">Constant Field Values</a></dd>
</dl>
</li>
</ul>
<a name="REBUILD_THRESHOLD">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>REBUILD_THRESHOLD</h4>
<pre>public static final&nbsp;double REBUILD_THRESHOLD</pre>
<div class="block">The hash table rebuild threshold = 15.0/16.0.</div>
<dl>
<dt><span class="seeLabel">See Also:</span></dt>
<dd><a href="../../../constant-values.html#com.yahoo.sketches.Util.REBUILD_THRESHOLD">Constant Field Values</a></dd>
</dl>
</li>
</ul>
<a name="RESIZE_THRESHOLD">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>RESIZE_THRESHOLD</h4>
<pre>public static final&nbsp;double RESIZE_THRESHOLD</pre>
<div class="block">The resize threshold = 0.5; tuned for speed.</div>
<dl>
<dt><span class="seeLabel">See Also:</span></dt>
<dd><a href="../../../constant-values.html#com.yahoo.sketches.Util.RESIZE_THRESHOLD">Constant Field Values</a></dd>
</dl>
</li>
</ul>
<a name="DEFAULT_NOMINAL_ENTRIES">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>DEFAULT_NOMINAL_ENTRIES</h4>
<pre>public static final&nbsp;int DEFAULT_NOMINAL_ENTRIES</pre>
<div class="block">The default nominal entries is provided as a convenience for those cases where the
nominal sketch size in number of entries is not provided.
A sketch of 4096 entries has a Relative Standard Error (RSE) of +/- 1.56% at a confidence of
68%; or equivalently, a Relative Error of +/- 3.1% at a confidence of 95.4%.
<a href="../../../resources/dictionary.html#defaultNomEntries">See Default Nominal Entries</a></div>
<dl>
<dt><span class="seeLabel">See Also:</span></dt>
<dd><a href="../../../constant-values.html#com.yahoo.sketches.Util.DEFAULT_NOMINAL_ENTRIES">Constant Field Values</a></dd>
</dl>
</li>
</ul>
<a name="DEFAULT_UPDATE_SEED">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>DEFAULT_UPDATE_SEED</h4>
<pre>public static final&nbsp;long DEFAULT_UPDATE_SEED</pre>
<div class="block">The seed 9001 used in the sketch update methods is a prime number that
was chosen very early on in experimental testing. Choosing a seed is somewhat arbitrary, and
the author cannot prove that this particular seed is somehow superior to other seeds. There
was some early Internet discussion that a seed of 0 did not produce as clean avalanche diagrams
as non-zero seeds, but this may have been more related to the MurmurHash2 release, which did
have some issues. As far as the author can determine, MurmurHash3 does not have these problems.
<p>In order to perform set operations on two sketches it is critical that the same hash
function and seed are identical for both sketches, otherwise the assumed 1:1 relationship
between the original source key value and the hashed bit string would be violated. Once
you have developed a history of stored sketches you are stuck with it.
<a href="../../../resources/dictionary.html#defaultUpdateSeed">See Default Update Seed</a></div>
<dl>
<dt><span class="seeLabel">See Also:</span></dt>
<dd><a href="../../../constant-values.html#com.yahoo.sketches.Util.DEFAULT_UPDATE_SEED">Constant Field Values</a></dd>
</dl>
</li>
</ul>
<a name="LS">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>LS</h4>
<pre>public static final&nbsp;<a href="https://docs.oracle.com/javase/8/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a> LS</pre>
<div class="block">The java line separator character as a String.</div>
</li>
</ul>
<a name="TAB">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>TAB</h4>
<pre>public static final&nbsp;char TAB</pre>
<div class="block">The tab character</div>
<dl>
<dt><span class="seeLabel">See Also:</span></dt>
<dd><a href="../../../constant-values.html#com.yahoo.sketches.Util.TAB">Constant Field Values</a></dd>
</dl>
</li>
</ul>
<a name="LOG2">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>LOG2</h4>
<pre>public static final&nbsp;double LOG2</pre>
<div class="block">The natural logarithm of 2.0.</div>
</li>
</ul>
<a name="iGoldenU64">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>iGoldenU64</h4>
<pre>public static final&nbsp;long iGoldenU64</pre>
<div class="block">The inverse golden ratio as an unsigned long.</div>
<dl>
<dt><span class="seeLabel">See Also:</span></dt>
<dd><a href="../../../constant-values.html#com.yahoo.sketches.Util.iGoldenU64">Constant Field Values</a></dd>
</dl>
</li>
</ul>
<a name="iGolden">
<!-- -->
</a>
<ul class="blockListLast">
<li class="blockList">
<h4>iGolden</h4>
<pre>public static final&nbsp;double iGolden</pre>
<div class="block">The inverse golden ratio as a fraction.
This has more precision than using the formula: (Math.sqrt(5.0) - 1.0) / 2.0.</div>
<dl>
<dt><span class="seeLabel">See Also:</span></dt>
<dd><a href="../../../constant-values.html#com.yahoo.sketches.Util.iGolden">Constant Field Values</a></dd>
</dl>
</li>
</ul>
</li>
</ul>
<!-- ============ METHOD DETAIL ========== -->
<ul class="blockList">
<li class="blockList"><a name="method.detail">
<!-- -->
</a>
<h3>Method Detail</h3>
<a name="bytesToInt-byte:A-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>bytesToInt</h4>
<pre>public static&nbsp;int&nbsp;bytesToInt(byte[]&nbsp;arr)</pre>
<div class="block">Returns an int extracted from a Little-Endian byte array.</div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>arr</code> - the given byte array</dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>an int extracted from a Little-Endian byte array.</dd>
</dl>
</li>
</ul>
<a name="bytesToLong-byte:A-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>bytesToLong</h4>
<pre>public static&nbsp;long&nbsp;bytesToLong(byte[]&nbsp;arr)</pre>
<div class="block">Returns a long extracted from a Little-Endian byte array.</div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>arr</code> - the given byte array</dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>a long extracted from a Little-Endian byte array.</dd>
</dl>
</li>
</ul>
<a name="intToBytes-int-byte:A-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>intToBytes</h4>
<pre>public static&nbsp;byte[]&nbsp;intToBytes(int&nbsp;v,
byte[]&nbsp;arr)</pre>
<div class="block">Returns a Little-Endian byte array extracted from the given int.</div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>v</code> - the given int</dd>
<dd><code>arr</code> - a given array of 4 bytes that will be returned with the data</dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>a Little-Endian byte array extracted from the given int.</dd>
</dl>
</li>
</ul>
<a name="longToBytes-long-byte:A-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>longToBytes</h4>
<pre>public static&nbsp;byte[]&nbsp;longToBytes(long&nbsp;v,
byte[]&nbsp;arr)</pre>
<div class="block">Returns a Little-Endian byte array extracted from the given long.</div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>v</code> - the given long</dd>
<dd><code>arr</code> - a given array of 8 bytes that will be returned with the data</dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>a Little-Endian byte array extracted from the given long.</dd>
</dl>
</li>
</ul>
<a name="longToHexBytes-long-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>longToHexBytes</h4>
<pre>public static&nbsp;<a href="https://docs.oracle.com/javase/8/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a>&nbsp;longToHexBytes(long&nbsp;v)</pre>
<div class="block">Returns a string of spaced hex bytes in Big-Endian order.</div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>v</code> - the given long</dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>string of spaced hex bytes in Big-Endian order.</dd>
</dl>
</li>
</ul>
<a name="bytesToString-byte:A-boolean-boolean-java.lang.String-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>bytesToString</h4>
<pre>public static&nbsp;<a href="https://docs.oracle.com/javase/8/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a>&nbsp;bytesToString(byte[]&nbsp;arr,
boolean&nbsp;signed,
boolean&nbsp;littleEndian,
<a href="https://docs.oracle.com/javase/8/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a>&nbsp;sep)</pre>
<div class="block">Returns a string view of a byte array</div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>arr</code> - the given byte array</dd>
<dd><code>signed</code> - set true if you want the byte values signed.</dd>
<dd><code>littleEndian</code> - set true if you want Little-Endian order</dd>
<dd><code>sep</code> - the separator string between bytes</dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>a string view of a byte array</dd>
</dl>
</li>
</ul>
<a name="nanoSecToString-long-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>nanoSecToString</h4>
<pre>public static&nbsp;<a href="https://docs.oracle.com/javase/8/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a>&nbsp;nanoSecToString(long&nbsp;nS)</pre>
<div class="block">Returns the given time in nanoseconds formatted as Sec.mSec uSec nSec</div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>nS</code> - the given nanoseconds</dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>the given time in nanoseconds formatted as Sec.mSec uSec nSec</dd>
</dl>
</li>
</ul>
<a name="milliSecToString-long-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>milliSecToString</h4>
<pre>public static&nbsp;<a href="https://docs.oracle.com/javase/8/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a>&nbsp;milliSecToString(long&nbsp;mS)</pre>
<div class="block">Returns the given time in milliseconds formatted as Hours:Min:Sec.mSec</div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>mS</code> - the given nanoseconds</dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>the given time in milliseconds formatted as Hours:Min:Sec.mSec</dd>
</dl>
</li>
</ul>
<a name="zeroPad-java.lang.String-int-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>zeroPad</h4>
<pre>public static final&nbsp;<a href="https://docs.oracle.com/javase/8/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a>&nbsp;zeroPad(<a href="https://docs.oracle.com/javase/8/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a>&nbsp;s,
int&nbsp;fieldLength)</pre>
<div class="block">Prepend the given string with zeros. If the given string is equal or greater than the given
field length, it will be returned without modification.</div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>s</code> - the given string</dd>
<dd><code>fieldLength</code> - desired total field length including the given string</dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>the given string prepended with zeros.</dd>
</dl>
</li>
</ul>
<a name="characterPad-java.lang.String-int-char-boolean-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>characterPad</h4>
<pre>public static final&nbsp;<a href="https://docs.oracle.com/javase/8/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a>&nbsp;characterPad(<a href="https://docs.oracle.com/javase/8/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a>&nbsp;s,
int&nbsp;fieldLength,
char&nbsp;padChar,
boolean&nbsp;postpend)</pre>
<div class="block">Prepend or postpend the given string with the given character to fill the given field length.
If the given string is equal or greater than the given field length, it will be returned
without modification.</div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>s</code> - the given string</dd>
<dd><code>fieldLength</code> - the desired field length</dd>
<dd><code>padChar</code> - the desired pad character</dd>
<dd><code>postpend</code> - if true append the pacCharacters to the end of the string.</dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>prepended or postpended given string with the given character to fill the given field
length.</dd>
</dl>
</li>
</ul>
<a name="checkSeedHashes-short-short-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>checkSeedHashes</h4>
<pre>public static final&nbsp;short&nbsp;checkSeedHashes(short&nbsp;seedHashA,
short&nbsp;seedHashB)</pre>
<div class="block">Check if the two seed hashes are equal. If not, throw an SketchesArgumentException.</div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>seedHashA</code> - the seedHash A</dd>
<dd><code>seedHashB</code> - the seedHash B</dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>seedHashA if they are equal</dd>
</dl>
</li>
</ul>
<a name="computeSeedHash-long-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>computeSeedHash</h4>
<pre>public static&nbsp;short&nbsp;computeSeedHash(long&nbsp;seed)</pre>
<div class="block">Computes and checks the 16-bit seed hash from the given long seed.
The seed hash may not be zero in order to maintain compatibility with older serialized
versions that did not have this concept.</div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>seed</code> - <a href="../../../resources/dictionary.html#seed">See Update Hash Seed</a></dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>the seed hash.</dd>
</dl>
</li>
</ul>
<a name="checkIfMultipleOf8AndGT0-long-java.lang.String-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>checkIfMultipleOf8AndGT0</h4>
<pre>public static&nbsp;void&nbsp;checkIfMultipleOf8AndGT0(long&nbsp;v,
<a href="https://docs.oracle.com/javase/8/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a>&nbsp;argName)</pre>
<div class="block">Checks if parameter v is a multiple of 8 and greater than zero.</div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>v</code> - The parameter to check</dd>
<dd><code>argName</code> - This name will be part of the error message if the check fails.</dd>
</dl>
</li>
</ul>
<a name="isMultipleOf8AndGT0-long-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>isMultipleOf8AndGT0</h4>
<pre>public static&nbsp;boolean&nbsp;isMultipleOf8AndGT0(long&nbsp;v)</pre>
<div class="block">Returns true if v is a multiple of 8 and greater than zero</div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>v</code> - The parameter to check</dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>true if v is a multiple of 8 and greater than zero</dd>
</dl>
</li>
</ul>
<a name="isPowerOf2-int-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>isPowerOf2</h4>
<pre>public static&nbsp;boolean&nbsp;isPowerOf2(int&nbsp;v)</pre>
<div class="block">Returns true if argument is exactly a positive power of 2 and greater than zero.</div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>v</code> - The input argument.</dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>true if argument is exactly a positive power of 2 and greater than zero.</dd>
</dl>
</li>
</ul>
<a name="checkIfPowerOf2-int-java.lang.String-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>checkIfPowerOf2</h4>
<pre>public static&nbsp;void&nbsp;checkIfPowerOf2(int&nbsp;v,
<a href="https://docs.oracle.com/javase/8/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a>&nbsp;argName)</pre>
<div class="block">Checks the given parameter to make sure it is positive, an integer-power of 2 and greater than
zero.</div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>v</code> - The input argument.</dd>
<dd><code>argName</code> - Used in the thrown exception.</dd>
</dl>
</li>
</ul>
<a name="toLog2-int-java.lang.String-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>toLog2</h4>
<pre>public static&nbsp;int&nbsp;toLog2(int&nbsp;value,
<a href="https://docs.oracle.com/javase/8/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a>&nbsp;argName)</pre>
<div class="block">Checks the given value if it is a power of 2. If not, it throws an exception.
Otherwise, returns the log-base2 of the given value.</div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>value</code> - must be a power of 2 and greater than zero.</dd>
<dd><code>argName</code> - the argument name used in the exception if thrown.</dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>the log-base2 of the given value</dd>
</dl>
</li>
</ul>
<a name="ceilingPowerOf2-int-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>ceilingPowerOf2</h4>
<pre>public static&nbsp;int&nbsp;ceilingPowerOf2(int&nbsp;n)</pre>
<div class="block">Computes the ceiling power of 2 within the range [1, 2^30]. This is the smallest positive power
of 2 that equal to or greater than the given n. <br>
For:
<ul>
<li>n &le; 1: returns 1</li>
<li>2^30 &le; n &le; 2^31 -1 : returns 2^30</li>
<li>n == a power of 2 : returns n</li>
<li>otherwise returns the smallest power of 2 greater than n</li>
</ul></div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>n</code> - The input argument.</dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>the ceiling power of 2.</dd>
</dl>
</li>
</ul>
<a name="floorPowerOf2-int-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>floorPowerOf2</h4>
<pre>public static&nbsp;int&nbsp;floorPowerOf2(int&nbsp;n)</pre>
<div class="block">Computes the floor power of 2 within the range [1, 2^30]. This is the largest positive power of
2 that equal to or less than the given n. <br>
For:
<ul>
<li>n &le; 1: returns 1</li>
<li>2^30 &le; n &le; 2^31 -1 : returns 2^30</li>
<li>n == a power of 2 : returns n</li>
<li>otherwise returns the largest power of 2 less than n</li>
</ul></div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>n</code> - The given argument.</dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>the floor power of 2.</dd>
</dl>
</li>
</ul>
<a name="invPow2-int-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>invPow2</h4>
<pre>public static&nbsp;double&nbsp;invPow2(int&nbsp;e)</pre>
<div class="block">Computes the inverse integer power of 2: 1/(2^e) = 2^(-e).</div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>e</code> - a positive value between 0 and 1023 inclusive</dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>the inverse integer power of 2: 1/(2^e) = 2^(-e)</dd>
</dl>
</li>
</ul>
<a name="evenlyLgSpaced-int-int-int-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>evenlyLgSpaced</h4>
<pre>public static&nbsp;int[]&nbsp;evenlyLgSpaced(int&nbsp;lgStart,
int&nbsp;lgEnd,
int&nbsp;points)</pre>
<div class="block">Returns an int array of points that will be evenly spaced on a log axis.
This is designed for Log_base2 numbers.</div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>lgStart</code> - the Log_base2 of the starting value. E.g., for 1 lgStart = 0.</dd>
<dd><code>lgEnd</code> - the Log_base2 of the ending value. E.g. for 1024 lgEnd = 10.</dd>
<dd><code>points</code> - the total number of points including the starting and ending values.</dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>an int array of points that will be evenly spaced on a log axis.</dd>
</dl>
</li>
</ul>
<a name="pwr2LawNext-int-int-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>pwr2LawNext</h4>
<pre>public static final&nbsp;int&nbsp;pwr2LawNext(int&nbsp;ppo,
int&nbsp;curPoint)</pre>
<div class="block">Computes the next larger integer point in the power series
<i>point = 2<sup>( i / ppo )</sup></i> given the current point in the series.
For illustration, this can be used in a loop as follows:
<pre><code>
int maxP = 1024;
int minP = 1;
int ppo = 2;
for (int p = minP; p &lt;= maxP; p = pwr2LawNext(ppo, p)) {
System.out.print(p + " ");
}
//generates the following series:
//1 2 3 4 6 8 11 16 23 32 45 64 91 128 181 256 362 512 724 1024
</code></pre></div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>ppo</code> - Points-Per-Octave, or the number of points per integer powers of 2 in the series.</dd>
<dd><code>curPoint</code> - the current point of the series. Must be &ge; 1.</dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>the next point in the power series.</dd>
</dl>
</li>
</ul>
<a name="pwr2LawNextDouble-int-double-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>pwr2LawNextDouble</h4>
<pre>public static final&nbsp;double&nbsp;pwr2LawNextDouble(int&nbsp;ppo,
double&nbsp;curPoint)</pre>
<div class="block">Computes the next larger double in the power series
<i>point = 2<sup>( i / ppo )</sup></i> given the current point in the series.
For illustration, this can be used in a loop as follows:
<pre><code>
double maxP = 1024.0;
double minP = 1.0;
int ppo = 2;
for (double p = minP; p &lt;= maxP; p = pwr2LawNextDouble(ppo, p)) {
System.out.print(Math.round(p) + " ");
}
//generates the following series:
//1 2 3 4 6 8 11 16 23 32 45 64 91 128 181 256 362 512 724 1024
</code></pre></div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>ppo</code> - Points-Per-Octave, or the number of points per integer powers of 2 in the series.</dd>
<dd><code>curPoint</code> - the current point of the series. Must be &ge; 1.0.</dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>the next point in the power series.</dd>
</dl>
</li>
</ul>
<a name="pwr2LawPrev-int-int-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>pwr2LawPrev</h4>
<pre>public static final&nbsp;int&nbsp;pwr2LawPrev(int&nbsp;ppo,
int&nbsp;curPoint)</pre>
<div class="block">Computes the previous, smaller integer point in the power series
<i>point = 2<sup>( i / ppo )</sup></i> given the current point in the series.
For illustration, this can be used in a loop as follows:
<pre><code>
int maxP = 1024;
int minP = 1;
int ppo = 2;
for (int p = maxP; p &gt;= minP; p = pwr2LawPrev(ppo, p)) {
System.out.print(p + " ");
}
//generates the following series:
//1024 724 512 362 256 181 128 91 64 45 32 23 16 11 8 6 4 3 2 1
</code></pre></div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>ppo</code> - Points-Per-Octave, or the number of points per integer powers of 2 in the series.</dd>
<dd><code>curPoint</code> - the current point of the series. Must be &ge; 1.</dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>the previous, smaller point in the power series.
A returned value of zero terminates the series.</dd>
</dl>
</li>
</ul>
<a name="log2-double-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>log2</h4>
<pre>public static final&nbsp;double&nbsp;log2(double&nbsp;value)</pre>
<div class="block">The log base 2 of the value</div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>value</code> - the given value</dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>The log base 2 of the value</dd>
</dl>
</li>
</ul>
<a name="simpleIntLog2-int-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>simpleIntLog2</h4>
<pre>public static&nbsp;int&nbsp;simpleIntLog2(int&nbsp;x)</pre>
<div class="block">Gives the log2 of an integer that is known to be a power of 2.</div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>x</code> - number</dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>the log2 of an integer that is known to be a power of 2.</dd>
</dl>
</li>
</ul>
<a name="startingSubMultiple-int-com.yahoo.sketches.ResizeFactor-int-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>startingSubMultiple</h4>
<pre>public static final&nbsp;int&nbsp;startingSubMultiple(int&nbsp;lgTarget,
<a href="../../../com/yahoo/sketches/ResizeFactor.html" title="enum in com.yahoo.sketches">ResizeFactor</a>&nbsp;rf,
int&nbsp;lgMin)</pre>
<div class="block">Gets the smallest allowed exponent of 2 that it is a sub-multiple of the target by zero,
one or more resize factors.</div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>lgTarget</code> - Log2 of the target size</dd>
<dd><code>rf</code> - <a href="../../../resources/dictionary.html#resizeFactor">See Resize Factor</a></dd>
<dd><code>lgMin</code> - Log2 of the minimum allowed starting size</dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>The Log2 of the starting size</dd>
</dl>
</li>
</ul>
<a name="checkProbability-double-java.lang.String-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>checkProbability</h4>
<pre>public static&nbsp;void&nbsp;checkProbability(double&nbsp;p,
<a href="https://docs.oracle.com/javase/8/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a>&nbsp;argName)</pre>
<div class="block">Checks the given parameter to make sure it is positive and between 0.0 inclusive and 1.0
inclusive.</div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>p</code> - <a href="../../../resources/dictionary.html#p">See Sampling Probability, <i>p</i></a></dd>
<dd><code>argName</code> - Used in the thrown exception.</dd>
</dl>
</li>
</ul>
<a name="isLessThanUnsigned-long-long-">
<!-- -->
</a>
<ul class="blockListLast">
<li class="blockList">
<h4>isLessThanUnsigned</h4>
<pre>public static&nbsp;boolean&nbsp;isLessThanUnsigned(long&nbsp;n1,
long&nbsp;n2)</pre>
<div class="block">Unsigned compare with longs.</div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>n1</code> - A long to be treated as if unsigned.</dd>
<dd><code>n2</code> - A long to be treated as if unsigned.</dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>true if n1 &gt; n2.</dd>
</dl>
</li>
</ul>
</li>
</ul>
</li>
</ul>
</div>
</div>
<!-- ========= END OF CLASS DATA ========= -->
<!-- ======= START OF BOTTOM NAVBAR ====== -->
<div class="bottomNav"><a name="navbar.bottom">
<!-- -->
</a>
<div class="skipNav"><a href="#skip.navbar.bottom" title="Skip navigation links">Skip navigation links</a></div>
<a name="navbar.bottom.firstrow">
<!-- -->
</a>
<ul class="navList" title="Navigation">
<li><a href="../../../overview-summary.html">Overview</a></li>
<li><a href="package-summary.html">Package</a></li>
<li class="navBarCell1Rev">Class</li>
<li><a href="class-use/Util.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-all.html">Index</a></li>
<li><a href="../../../help-doc.html">Help</a></li>
</ul>
</div>
<div class="subNav">
<ul class="navList">
<li><a href="../../../com/yahoo/sketches/SketchesStateException.html" title="class in com.yahoo.sketches"><span class="typeNameLink">Prev&nbsp;Class</span></a></li>
<li>Next&nbsp;Class</li>
</ul>
<ul class="navList">
<li><a href="../../../index.html?com/yahoo/sketches/Util.html" target="_top">Frames</a></li>
<li><a href="Util.html" target="_top">No&nbsp;Frames</a></li>
</ul>
<ul class="navList" id="allclasses_navbar_bottom">
<li><a href="../../../allclasses-noframe.html">All&nbsp;Classes</a></li>
</ul>
<div>
<script type="text/javascript"><!--
allClassesLink = document.getElementById("allclasses_navbar_bottom");
if(window==top) {
allClassesLink.style.display = "block";
}
else {
allClassesLink.style.display = "none";
}
//-->
</script>
</div>
<div>
<ul class="subNavList">
<li>Summary:&nbsp;</li>
<li>Nested&nbsp;|&nbsp;</li>
<li><a href="#field.summary">Field</a>&nbsp;|&nbsp;</li>
<li>Constr&nbsp;|&nbsp;</li>
<li><a href="#method.summary">Method</a></li>
</ul>
<ul class="subNavList">
<li>Detail:&nbsp;</li>
<li><a href="#field.detail">Field</a>&nbsp;|&nbsp;</li>
<li>Constr&nbsp;|&nbsp;</li>
<li><a href="#method.detail">Method</a></li>
</ul>
</div>
<a name="skip.navbar.bottom">
<!-- -->
</a></div>
<!-- ======== END OF BOTTOM NAVBAR ======= -->
<p class="legalCopy"><small>Copyright &#169; 2015&#x2013;2018. All rights reserved.</small></p>
</body>
</html>