mirror of
https://github.com/ChronosX88/FreePastry.git
synced 2025-01-16 01:26:27 +00:00
757 lines
26 KiB
HTML
757 lines
26 KiB
HTML
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||
|
<!--NewPage-->
|
||
|
<HTML>
|
||
|
<HEAD>
|
||
|
<!-- Generated by javadoc (build 1.6.0_07) on Fri Mar 13 20:01:31 CET 2009 -->
|
||
|
<TITLE>
|
||
|
MathUtils (Rice Pastry - API Specifications)
|
||
|
</TITLE>
|
||
|
|
||
|
<META NAME="date" CONTENT="2009-03-13">
|
||
|
|
||
|
<LINK REL ="stylesheet" TYPE="text/css" HREF="../../../stylesheet.css" TITLE="Style">
|
||
|
|
||
|
<SCRIPT type="text/javascript">
|
||
|
function windowTitle()
|
||
|
{
|
||
|
if (location.href.indexOf('is-external=true') == -1) {
|
||
|
parent.document.title="MathUtils (Rice Pastry - API Specifications)";
|
||
|
}
|
||
|
}
|
||
|
</SCRIPT>
|
||
|
<NOSCRIPT>
|
||
|
</NOSCRIPT>
|
||
|
|
||
|
</HEAD>
|
||
|
|
||
|
<BODY BGCOLOR="white" onload="windowTitle();">
|
||
|
<HR>
|
||
|
|
||
|
|
||
|
<!-- ========= START OF TOP NAVBAR ======= -->
|
||
|
<A NAME="navbar_top"><!-- --></A>
|
||
|
<A HREF="#skip-navbar_top" title="Skip navigation links"></A>
|
||
|
<TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0" SUMMARY="">
|
||
|
<TR>
|
||
|
<TD COLSPAN=2 BGCOLOR="#EEEEFF" CLASS="NavBarCell1">
|
||
|
<A NAME="navbar_top_firstrow"><!-- --></A>
|
||
|
<TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3" SUMMARY="">
|
||
|
<TR ALIGN="center" VALIGN="top">
|
||
|
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../overview-summary.html"><FONT CLASS="NavBarFont1"><B>Overview</B></FONT></A> </TD>
|
||
|
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-summary.html"><FONT CLASS="NavBarFont1"><B>Package</B></FONT></A> </TD>
|
||
|
<TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> <FONT CLASS="NavBarFont1Rev"><B>Class</B></FONT> </TD>
|
||
|
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="class-use/MathUtils.html"><FONT CLASS="NavBarFont1"><B>Use</B></FONT></A> </TD>
|
||
|
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A> </TD>
|
||
|
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A> </TD>
|
||
|
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../index-all.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A> </TD>
|
||
|
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A> </TD>
|
||
|
</TR>
|
||
|
</TABLE>
|
||
|
</TD>
|
||
|
<TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM>
|
||
|
Rice Pastry API</EM>
|
||
|
</TD>
|
||
|
</TR>
|
||
|
|
||
|
<TR>
|
||
|
<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
|
||
|
<A HREF="../../../rice/p2p/util/ImmutableSortedMap.html" title="class in rice.p2p.util"><B>PREV CLASS</B></A>
|
||
|
<A HREF="../../../rice/p2p/util/MCAdapter.html" title="class in rice.p2p.util"><B>NEXT CLASS</B></A></FONT></TD>
|
||
|
<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
|
||
|
<A HREF="../../../index.html?rice/p2p/util/MathUtils.html" target="_top"><B>FRAMES</B></A>
|
||
|
<A HREF="MathUtils.html" target="_top"><B>NO FRAMES</B></A>
|
||
|
<SCRIPT type="text/javascript">
|
||
|
<!--
|
||
|
if(window==top) {
|
||
|
document.writeln('<A HREF="../../../allclasses-noframe.html"><B>All Classes</B></A>');
|
||
|
}
|
||
|
//-->
|
||
|
</SCRIPT>
|
||
|
<NOSCRIPT>
|
||
|
<A HREF="../../../allclasses-noframe.html"><B>All Classes</B></A>
|
||
|
</NOSCRIPT>
|
||
|
|
||
|
|
||
|
</FONT></TD>
|
||
|
</TR>
|
||
|
<TR>
|
||
|
<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
|
||
|
SUMMARY: NESTED | <A HREF="#field_summary">FIELD</A> | CONSTR | <A HREF="#method_summary">METHOD</A></FONT></TD>
|
||
|
<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
|
||
|
DETAIL: <A HREF="#field_detail">FIELD</A> | CONSTR | <A HREF="#method_detail">METHOD</A></FONT></TD>
|
||
|
</TR>
|
||
|
</TABLE>
|
||
|
<A NAME="skip-navbar_top"></A>
|
||
|
<!-- ========= END OF TOP NAVBAR ========= -->
|
||
|
|
||
|
<HR>
|
||
|
<!-- ======== START OF CLASS DATA ======== -->
|
||
|
<H2>
|
||
|
<FONT SIZE="-1">
|
||
|
rice.p2p.util</FONT>
|
||
|
<BR>
|
||
|
Class MathUtils</H2>
|
||
|
<PRE>
|
||
|
java.lang.Object
|
||
|
<IMG SRC="../../../resources/inherit.gif" ALT="extended by "><B>rice.p2p.util.MathUtils</B>
|
||
|
</PRE>
|
||
|
<HR>
|
||
|
<DL>
|
||
|
<DT><PRE>public class <B>MathUtils</B><DT>extends java.lang.Object</DL>
|
||
|
</PRE>
|
||
|
|
||
|
<P>
|
||
|
This class contains a large number of static methods for performing
|
||
|
math operations.
|
||
|
<P>
|
||
|
|
||
|
<P>
|
||
|
<DL>
|
||
|
<DT><B>Version:</B></DT>
|
||
|
<DD>$Id: MathUtils.java 4549 2008-10-16 18:21:19Z jeffh $</DD>
|
||
|
<DT><B>Author:</B></DT>
|
||
|
<DD>amislove</DD>
|
||
|
</DL>
|
||
|
<HR>
|
||
|
|
||
|
<P>
|
||
|
<!-- =========== FIELD SUMMARY =========== -->
|
||
|
|
||
|
<A NAME="field_summary"><!-- --></A>
|
||
|
<TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
|
||
|
<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
|
||
|
<TH ALIGN="left" COLSPAN="2"><FONT SIZE="+2">
|
||
|
<B>Field Summary</B></FONT></TH>
|
||
|
</TR>
|
||
|
<TR BGCOLOR="white" CLASS="TableRowColor">
|
||
|
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
|
||
|
<CODE>static char[]</CODE></FONT></TD>
|
||
|
<TD><CODE><B><A HREF="../../../rice/p2p/util/MathUtils.html#HEX_ARRAY">HEX_ARRAY</A></B></CODE>
|
||
|
|
||
|
<BR>
|
||
|
The array used for conversion to hexadecimal</TD>
|
||
|
</TR>
|
||
|
</TABLE>
|
||
|
|
||
|
<!-- ========== METHOD SUMMARY =========== -->
|
||
|
|
||
|
<A NAME="method_summary"><!-- --></A>
|
||
|
<TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
|
||
|
<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
|
||
|
<TH ALIGN="left" COLSPAN="2"><FONT SIZE="+2">
|
||
|
<B>Method Summary</B></FONT></TH>
|
||
|
</TR>
|
||
|
<TR BGCOLOR="white" CLASS="TableRowColor">
|
||
|
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
|
||
|
<CODE>static int</CODE></FONT></TD>
|
||
|
<TD><CODE><B><A HREF="../../../rice/p2p/util/MathUtils.html#byteArrayToInt(byte[])">byteArrayToInt</A></B>(byte[] input)</CODE>
|
||
|
|
||
|
<BR>
|
||
|
Utility method for converting a byte[] into a int</TD>
|
||
|
</TR>
|
||
|
<TR BGCOLOR="white" CLASS="TableRowColor">
|
||
|
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
|
||
|
<CODE>static int</CODE></FONT></TD>
|
||
|
<TD><CODE><B><A HREF="../../../rice/p2p/util/MathUtils.html#byteArrayToInt(byte[], int)">byteArrayToInt</A></B>(byte[] input,
|
||
|
int offset)</CODE>
|
||
|
|
||
|
<BR>
|
||
|
</TD>
|
||
|
</TR>
|
||
|
<TR BGCOLOR="white" CLASS="TableRowColor">
|
||
|
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
|
||
|
<CODE>static long</CODE></FONT></TD>
|
||
|
<TD><CODE><B><A HREF="../../../rice/p2p/util/MathUtils.html#byteArrayToLong(byte[])">byteArrayToLong</A></B>(byte[] input)</CODE>
|
||
|
|
||
|
<BR>
|
||
|
Utility method for converting a byte[] into a long</TD>
|
||
|
</TR>
|
||
|
<TR BGCOLOR="white" CLASS="TableRowColor">
|
||
|
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
|
||
|
<CODE>static long</CODE></FONT></TD>
|
||
|
<TD><CODE><B><A HREF="../../../rice/p2p/util/MathUtils.html#byteArrayToLong(byte[], int)">byteArrayToLong</A></B>(byte[] input,
|
||
|
int offset)</CODE>
|
||
|
|
||
|
<BR>
|
||
|
</TD>
|
||
|
</TR>
|
||
|
<TR BGCOLOR="white" CLASS="TableRowColor">
|
||
|
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
|
||
|
<CODE>static short</CODE></FONT></TD>
|
||
|
<TD><CODE><B><A HREF="../../../rice/p2p/util/MathUtils.html#byteArrayToShort(byte[])">byteArrayToShort</A></B>(byte[] input)</CODE>
|
||
|
|
||
|
<BR>
|
||
|
</TD>
|
||
|
</TR>
|
||
|
<TR BGCOLOR="white" CLASS="TableRowColor">
|
||
|
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
|
||
|
<CODE>static short</CODE></FONT></TD>
|
||
|
<TD><CODE><B><A HREF="../../../rice/p2p/util/MathUtils.html#byteArrayToShort(byte[], int)">byteArrayToShort</A></B>(byte[] input,
|
||
|
int offset)</CODE>
|
||
|
|
||
|
<BR>
|
||
|
</TD>
|
||
|
</TR>
|
||
|
<TR BGCOLOR="white" CLASS="TableRowColor">
|
||
|
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
|
||
|
<CODE>static byte[]</CODE></FONT></TD>
|
||
|
<TD><CODE><B><A HREF="../../../rice/p2p/util/MathUtils.html#fromBase64(java.lang.String)">fromBase64</A></B>(java.lang.String text)</CODE>
|
||
|
|
||
|
<BR>
|
||
|
Utility method which converts a base64 string to a byte[]</TD>
|
||
|
</TR>
|
||
|
<TR BGCOLOR="white" CLASS="TableRowColor">
|
||
|
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
|
||
|
<CODE>static byte[]</CODE></FONT></TD>
|
||
|
<TD><CODE><B><A HREF="../../../rice/p2p/util/MathUtils.html#fromHex(java.lang.String)">fromHex</A></B>(java.lang.String text)</CODE>
|
||
|
|
||
|
<BR>
|
||
|
Utility method which converts a hex string to a byte[]</TD>
|
||
|
</TR>
|
||
|
<TR BGCOLOR="white" CLASS="TableRowColor">
|
||
|
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
|
||
|
<CODE>protected static byte</CODE></FONT></TD>
|
||
|
<TD><CODE><B><A HREF="../../../rice/p2p/util/MathUtils.html#getByte(char)">getByte</A></B>(char c)</CODE>
|
||
|
|
||
|
<BR>
|
||
|
Utility method for converting a char to a byte</TD>
|
||
|
</TR>
|
||
|
<TR BGCOLOR="white" CLASS="TableRowColor">
|
||
|
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
|
||
|
<CODE>static byte[]</CODE></FONT></TD>
|
||
|
<TD><CODE><B><A HREF="../../../rice/p2p/util/MathUtils.html#intToByteArray(int)">intToByteArray</A></B>(int input)</CODE>
|
||
|
|
||
|
<BR>
|
||
|
Utility method for converting a int into a byte[]</TD>
|
||
|
</TR>
|
||
|
<TR BGCOLOR="white" CLASS="TableRowColor">
|
||
|
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
|
||
|
<CODE>static void</CODE></FONT></TD>
|
||
|
<TD><CODE><B><A HREF="../../../rice/p2p/util/MathUtils.html#intToByteArray(int, byte[], int)">intToByteArray</A></B>(int input,
|
||
|
byte[] output,
|
||
|
int offset)</CODE>
|
||
|
|
||
|
<BR>
|
||
|
Utility method for converting a int into a byte[]</TD>
|
||
|
</TR>
|
||
|
<TR BGCOLOR="white" CLASS="TableRowColor">
|
||
|
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
|
||
|
<CODE>static byte</CODE></FONT></TD>
|
||
|
<TD><CODE><B><A HREF="../../../rice/p2p/util/MathUtils.html#intToUByte(int)">intToUByte</A></B>(int i)</CODE>
|
||
|
|
||
|
<BR>
|
||
|
</TD>
|
||
|
</TR>
|
||
|
<TR BGCOLOR="white" CLASS="TableRowColor">
|
||
|
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
|
||
|
<CODE>static byte[]</CODE></FONT></TD>
|
||
|
<TD><CODE><B><A HREF="../../../rice/p2p/util/MathUtils.html#longToByteArray(long)">longToByteArray</A></B>(long input)</CODE>
|
||
|
|
||
|
<BR>
|
||
|
Utility method for converting a long into a byte[]</TD>
|
||
|
</TR>
|
||
|
<TR BGCOLOR="white" CLASS="TableRowColor">
|
||
|
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
|
||
|
<CODE>static void</CODE></FONT></TD>
|
||
|
<TD><CODE><B><A HREF="../../../rice/p2p/util/MathUtils.html#longToByteArray(long, byte[], int)">longToByteArray</A></B>(long input,
|
||
|
byte[] output,
|
||
|
int offset)</CODE>
|
||
|
|
||
|
<BR>
|
||
|
Utility method for converting a long into a byte[]</TD>
|
||
|
</TR>
|
||
|
<TR BGCOLOR="white" CLASS="TableRowColor">
|
||
|
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
|
||
|
<CODE>static int</CODE></FONT></TD>
|
||
|
<TD><CODE><B><A HREF="../../../rice/p2p/util/MathUtils.html#mod(int, int)">mod</A></B>(int a,
|
||
|
int b)</CODE>
|
||
|
|
||
|
<BR>
|
||
|
Utility which does *proper* modding, where the result is guaranteed to be
|
||
|
positive.</TD>
|
||
|
</TR>
|
||
|
<TR BGCOLOR="white" CLASS="TableRowColor">
|
||
|
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
|
||
|
<CODE>static byte[]</CODE></FONT></TD>
|
||
|
<TD><CODE><B><A HREF="../../../rice/p2p/util/MathUtils.html#randomBytes(int, rice.environment.random.RandomSource)">randomBytes</A></B>(int len,
|
||
|
<A HREF="../../../rice/environment/random/RandomSource.html" title="interface in rice.environment.random">RandomSource</A> random)</CODE>
|
||
|
|
||
|
<BR>
|
||
|
Method which returns a specified number of random bytes</TD>
|
||
|
</TR>
|
||
|
<TR BGCOLOR="white" CLASS="TableRowColor">
|
||
|
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
|
||
|
<CODE>static int</CODE></FONT></TD>
|
||
|
<TD><CODE><B><A HREF="../../../rice/p2p/util/MathUtils.html#randomInt(rice.environment.random.RandomSource)">randomInt</A></B>(<A HREF="../../../rice/environment/random/RandomSource.html" title="interface in rice.environment.random">RandomSource</A> random)</CODE>
|
||
|
|
||
|
<BR>
|
||
|
Method which returns a random int</TD>
|
||
|
</TR>
|
||
|
<TR BGCOLOR="white" CLASS="TableRowColor">
|
||
|
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
|
||
|
<CODE>static int</CODE></FONT></TD>
|
||
|
<TD><CODE><B><A HREF="../../../rice/p2p/util/MathUtils.html#simpleHash(byte[])">simpleHash</A></B>(byte[] b)</CODE>
|
||
|
|
||
|
<BR>
|
||
|
A simple and fast hash function for hashing an arbitrary length
|
||
|
byte array into an int.</TD>
|
||
|
</TR>
|
||
|
<TR BGCOLOR="white" CLASS="TableRowColor">
|
||
|
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
|
||
|
<CODE>static java.lang.String</CODE></FONT></TD>
|
||
|
<TD><CODE><B><A HREF="../../../rice/p2p/util/MathUtils.html#toBase64(byte[])">toBase64</A></B>(byte[] text)</CODE>
|
||
|
|
||
|
<BR>
|
||
|
Utility method which converts a byte[] to a base64 string of characters, in lower case</TD>
|
||
|
</TR>
|
||
|
<TR BGCOLOR="white" CLASS="TableRowColor">
|
||
|
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
|
||
|
<CODE>static java.lang.String</CODE></FONT></TD>
|
||
|
<TD><CODE><B><A HREF="../../../rice/p2p/util/MathUtils.html#toHex(byte[])">toHex</A></B>(byte[] text)</CODE>
|
||
|
|
||
|
<BR>
|
||
|
Utility method which converts a byte[] to a hexadecimal string of characters, in lower case</TD>
|
||
|
</TR>
|
||
|
<TR BGCOLOR="white" CLASS="TableRowColor">
|
||
|
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
|
||
|
<CODE>static int</CODE></FONT></TD>
|
||
|
<TD><CODE><B><A HREF="../../../rice/p2p/util/MathUtils.html#uByteToInt(byte)">uByteToInt</A></B>(byte b)</CODE>
|
||
|
|
||
|
<BR>
|
||
|
</TD>
|
||
|
</TR>
|
||
|
<TR BGCOLOR="white" CLASS="TableRowColor">
|
||
|
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
|
||
|
<CODE>static int</CODE></FONT></TD>
|
||
|
<TD><CODE><B><A HREF="../../../rice/p2p/util/MathUtils.html#uShortToInt(short)">uShortToInt</A></B>(short b)</CODE>
|
||
|
|
||
|
<BR>
|
||
|
</TD>
|
||
|
</TR>
|
||
|
<TR BGCOLOR="white" CLASS="TableRowColor">
|
||
|
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
|
||
|
<CODE>static byte[]</CODE></FONT></TD>
|
||
|
<TD><CODE><B><A HREF="../../../rice/p2p/util/MathUtils.html#xor(byte[], byte[])">xor</A></B>(byte[] a,
|
||
|
byte[] b)</CODE>
|
||
|
|
||
|
<BR>
|
||
|
Utility method which xors two given byte arrays, of equal length, and returns the results</TD>
|
||
|
</TR>
|
||
|
</TABLE>
|
||
|
<A NAME="methods_inherited_from_class_java.lang.Object"><!-- --></A>
|
||
|
<TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
|
||
|
<TR BGCOLOR="#EEEEFF" CLASS="TableSubHeadingColor">
|
||
|
<TH ALIGN="left"><B>Methods inherited from class java.lang.Object</B></TH>
|
||
|
</TR>
|
||
|
<TR BGCOLOR="white" CLASS="TableRowColor">
|
||
|
<TD><CODE>clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait</CODE></TD>
|
||
|
</TR>
|
||
|
</TABLE>
|
||
|
|
||
|
<P>
|
||
|
|
||
|
<!-- ============ FIELD DETAIL =========== -->
|
||
|
|
||
|
<A NAME="field_detail"><!-- --></A>
|
||
|
<TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
|
||
|
<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
|
||
|
<TH ALIGN="left" COLSPAN="1"><FONT SIZE="+2">
|
||
|
<B>Field Detail</B></FONT></TH>
|
||
|
</TR>
|
||
|
</TABLE>
|
||
|
|
||
|
<A NAME="HEX_ARRAY"><!-- --></A><H3>
|
||
|
HEX_ARRAY</H3>
|
||
|
<PRE>
|
||
|
public static final char[] <B>HEX_ARRAY</B></PRE>
|
||
|
<DL>
|
||
|
<DD>The array used for conversion to hexadecimal
|
||
|
<P>
|
||
|
<DL>
|
||
|
</DL>
|
||
|
</DL>
|
||
|
|
||
|
<!-- ============ METHOD DETAIL ========== -->
|
||
|
|
||
|
<A NAME="method_detail"><!-- --></A>
|
||
|
<TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
|
||
|
<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
|
||
|
<TH ALIGN="left" COLSPAN="1"><FONT SIZE="+2">
|
||
|
<B>Method Detail</B></FONT></TH>
|
||
|
</TR>
|
||
|
</TABLE>
|
||
|
|
||
|
<A NAME="mod(int, int)"><!-- --></A><H3>
|
||
|
mod</H3>
|
||
|
<PRE>
|
||
|
public static int <B>mod</B>(int a,
|
||
|
int b)</PRE>
|
||
|
<DL>
|
||
|
<DD>Utility which does *proper* modding, where the result is guaranteed to be
|
||
|
positive.
|
||
|
<P>
|
||
|
<DD><DL>
|
||
|
<DT><B>Parameters:</B><DD><CODE>a</CODE> - The modee<DD><CODE>b</CODE> - The value to mod by
|
||
|
<DT><B>Returns:</B><DD>The result</DL>
|
||
|
</DD>
|
||
|
</DL>
|
||
|
<HR>
|
||
|
|
||
|
<A NAME="xor(byte[], byte[])"><!-- --></A><H3>
|
||
|
xor</H3>
|
||
|
<PRE>
|
||
|
public static byte[] <B>xor</B>(byte[] a,
|
||
|
byte[] b)</PRE>
|
||
|
<DL>
|
||
|
<DD>Utility method which xors two given byte arrays, of equal length, and returns the results
|
||
|
<P>
|
||
|
<DD><DL>
|
||
|
<DT><B>Parameters:</B><DD><CODE>a</CODE> - The first array<DD><CODE>b</CODE> - The second array
|
||
|
<DT><B>Returns:</B><DD>A new byte array, xored</DL>
|
||
|
</DD>
|
||
|
</DL>
|
||
|
<HR>
|
||
|
|
||
|
<A NAME="randomBytes(int, rice.environment.random.RandomSource)"><!-- --></A><H3>
|
||
|
randomBytes</H3>
|
||
|
<PRE>
|
||
|
public static byte[] <B>randomBytes</B>(int len,
|
||
|
<A HREF="../../../rice/environment/random/RandomSource.html" title="interface in rice.environment.random">RandomSource</A> random)</PRE>
|
||
|
<DL>
|
||
|
<DD>Method which returns a specified number of random bytes
|
||
|
<P>
|
||
|
<DD><DL>
|
||
|
<DT><B>Parameters:</B><DD><CODE>len</CODE> - The number of random bytes to generate</DL>
|
||
|
</DD>
|
||
|
</DL>
|
||
|
<HR>
|
||
|
|
||
|
<A NAME="randomInt(rice.environment.random.RandomSource)"><!-- --></A><H3>
|
||
|
randomInt</H3>
|
||
|
<PRE>
|
||
|
public static int <B>randomInt</B>(<A HREF="../../../rice/environment/random/RandomSource.html" title="interface in rice.environment.random">RandomSource</A> random)</PRE>
|
||
|
<DL>
|
||
|
<DD>Method which returns a random int
|
||
|
<P>
|
||
|
<DD><DL>
|
||
|
<DT><B>Parameters:</B><DD><CODE>len</CODE> - The number of random bytes to generate</DL>
|
||
|
</DD>
|
||
|
</DL>
|
||
|
<HR>
|
||
|
|
||
|
<A NAME="toHex(byte[])"><!-- --></A><H3>
|
||
|
toHex</H3>
|
||
|
<PRE>
|
||
|
public static java.lang.String <B>toHex</B>(byte[] text)</PRE>
|
||
|
<DL>
|
||
|
<DD>Utility method which converts a byte[] to a hexadecimal string of characters, in lower case
|
||
|
<P>
|
||
|
<DD><DL>
|
||
|
<DT><B>Parameters:</B><DD><CODE>text</CODE> - The array to convert
|
||
|
<DT><B>Returns:</B><DD>A string representation</DL>
|
||
|
</DD>
|
||
|
</DL>
|
||
|
<HR>
|
||
|
|
||
|
<A NAME="fromHex(java.lang.String)"><!-- --></A><H3>
|
||
|
fromHex</H3>
|
||
|
<PRE>
|
||
|
public static byte[] <B>fromHex</B>(java.lang.String text)</PRE>
|
||
|
<DL>
|
||
|
<DD>Utility method which converts a hex string to a byte[]
|
||
|
<P>
|
||
|
<DD><DL>
|
||
|
<DT><B>Parameters:</B><DD><CODE>text</CODE> - The text to convert
|
||
|
<DT><B>Returns:</B><DD>The bytes</DL>
|
||
|
</DD>
|
||
|
</DL>
|
||
|
<HR>
|
||
|
|
||
|
<A NAME="toBase64(byte[])"><!-- --></A><H3>
|
||
|
toBase64</H3>
|
||
|
<PRE>
|
||
|
public static java.lang.String <B>toBase64</B>(byte[] text)</PRE>
|
||
|
<DL>
|
||
|
<DD>Utility method which converts a byte[] to a base64 string of characters, in lower case
|
||
|
<P>
|
||
|
<DD><DL>
|
||
|
<DT><B>Parameters:</B><DD><CODE>text</CODE> - The array to convert
|
||
|
<DT><B>Returns:</B><DD>A string representation</DL>
|
||
|
</DD>
|
||
|
</DL>
|
||
|
<HR>
|
||
|
|
||
|
<A NAME="fromBase64(java.lang.String)"><!-- --></A><H3>
|
||
|
fromBase64</H3>
|
||
|
<PRE>
|
||
|
public static byte[] <B>fromBase64</B>(java.lang.String text)</PRE>
|
||
|
<DL>
|
||
|
<DD>Utility method which converts a base64 string to a byte[]
|
||
|
<P>
|
||
|
<DD><DL>
|
||
|
<DT><B>Parameters:</B><DD><CODE>text</CODE> - The text to convert
|
||
|
<DT><B>Returns:</B><DD>The bytes</DL>
|
||
|
</DD>
|
||
|
</DL>
|
||
|
<HR>
|
||
|
|
||
|
<A NAME="simpleHash(byte[])"><!-- --></A><H3>
|
||
|
simpleHash</H3>
|
||
|
<PRE>
|
||
|
public static int <B>simpleHash</B>(byte[] b)</PRE>
|
||
|
<DL>
|
||
|
<DD>A simple and fast hash function for hashing an arbitrary length
|
||
|
byte array into an int. Not for crypto. Not to be trusted.
|
||
|
|
||
|
From Wikipedia: http://en.wikipedia.org/wiki/Hash_table
|
||
|
<P>
|
||
|
<DD><DL>
|
||
|
<DT><B>Parameters:</B><DD><CODE>b</CODE> -
|
||
|
<DT><B>Returns:</B><DD>A hash of b</DL>
|
||
|
</DD>
|
||
|
</DL>
|
||
|
<HR>
|
||
|
|
||
|
<A NAME="getByte(char)"><!-- --></A><H3>
|
||
|
getByte</H3>
|
||
|
<PRE>
|
||
|
protected static byte <B>getByte</B>(char c)</PRE>
|
||
|
<DL>
|
||
|
<DD>Utility method for converting a char to a byte
|
||
|
<P>
|
||
|
<DD><DL>
|
||
|
<DT><B>Parameters:</B><DD><CODE>c</CODE> - The char
|
||
|
<DT><B>Returns:</B><DD>The byte</DL>
|
||
|
</DD>
|
||
|
</DL>
|
||
|
<HR>
|
||
|
|
||
|
<A NAME="intToByteArray(int)"><!-- --></A><H3>
|
||
|
intToByteArray</H3>
|
||
|
<PRE>
|
||
|
public static byte[] <B>intToByteArray</B>(int input)</PRE>
|
||
|
<DL>
|
||
|
<DD>Utility method for converting a int into a byte[]
|
||
|
<P>
|
||
|
<DD><DL>
|
||
|
<DT><B>Parameters:</B><DD><CODE>input</CODE> - The log to convert
|
||
|
<DT><B>Returns:</B><DD>a byte[] representation</DL>
|
||
|
</DD>
|
||
|
</DL>
|
||
|
<HR>
|
||
|
|
||
|
<A NAME="intToByteArray(int, byte[], int)"><!-- --></A><H3>
|
||
|
intToByteArray</H3>
|
||
|
<PRE>
|
||
|
public static void <B>intToByteArray</B>(int input,
|
||
|
byte[] output,
|
||
|
int offset)</PRE>
|
||
|
<DL>
|
||
|
<DD>Utility method for converting a int into a byte[]
|
||
|
<P>
|
||
|
<DD><DL>
|
||
|
<DT><B>Parameters:</B><DD><CODE>input</CODE> - The log to convert</DL>
|
||
|
</DD>
|
||
|
</DL>
|
||
|
<HR>
|
||
|
|
||
|
<A NAME="byteArrayToInt(byte[])"><!-- --></A><H3>
|
||
|
byteArrayToInt</H3>
|
||
|
<PRE>
|
||
|
public static int <B>byteArrayToInt</B>(byte[] input)</PRE>
|
||
|
<DL>
|
||
|
<DD>Utility method for converting a byte[] into a int
|
||
|
<P>
|
||
|
<DD><DL>
|
||
|
<DT><B>Parameters:</B><DD><CODE>input</CODE> - The byte[] to convert
|
||
|
<DT><B>Returns:</B><DD>a int representation</DL>
|
||
|
</DD>
|
||
|
</DL>
|
||
|
<HR>
|
||
|
|
||
|
<A NAME="byteArrayToInt(byte[], int)"><!-- --></A><H3>
|
||
|
byteArrayToInt</H3>
|
||
|
<PRE>
|
||
|
public static int <B>byteArrayToInt</B>(byte[] input,
|
||
|
int offset)</PRE>
|
||
|
<DL>
|
||
|
<DD><DL>
|
||
|
</DL>
|
||
|
</DD>
|
||
|
</DL>
|
||
|
<HR>
|
||
|
|
||
|
<A NAME="byteArrayToShort(byte[])"><!-- --></A><H3>
|
||
|
byteArrayToShort</H3>
|
||
|
<PRE>
|
||
|
public static short <B>byteArrayToShort</B>(byte[] input)</PRE>
|
||
|
<DL>
|
||
|
<DD><DL>
|
||
|
</DL>
|
||
|
</DD>
|
||
|
</DL>
|
||
|
<HR>
|
||
|
|
||
|
<A NAME="byteArrayToShort(byte[], int)"><!-- --></A><H3>
|
||
|
byteArrayToShort</H3>
|
||
|
<PRE>
|
||
|
public static short <B>byteArrayToShort</B>(byte[] input,
|
||
|
int offset)</PRE>
|
||
|
<DL>
|
||
|
<DD><DL>
|
||
|
</DL>
|
||
|
</DD>
|
||
|
</DL>
|
||
|
<HR>
|
||
|
|
||
|
<A NAME="longToByteArray(long)"><!-- --></A><H3>
|
||
|
longToByteArray</H3>
|
||
|
<PRE>
|
||
|
public static byte[] <B>longToByteArray</B>(long input)</PRE>
|
||
|
<DL>
|
||
|
<DD>Utility method for converting a long into a byte[]
|
||
|
<P>
|
||
|
<DD><DL>
|
||
|
<DT><B>Parameters:</B><DD><CODE>input</CODE> - The log to convert
|
||
|
<DT><B>Returns:</B><DD>a byte[] representation</DL>
|
||
|
</DD>
|
||
|
</DL>
|
||
|
<HR>
|
||
|
|
||
|
<A NAME="longToByteArray(long, byte[], int)"><!-- --></A><H3>
|
||
|
longToByteArray</H3>
|
||
|
<PRE>
|
||
|
public static void <B>longToByteArray</B>(long input,
|
||
|
byte[] output,
|
||
|
int offset)</PRE>
|
||
|
<DL>
|
||
|
<DD>Utility method for converting a long into a byte[]
|
||
|
<P>
|
||
|
<DD><DL>
|
||
|
<DT><B>Parameters:</B><DD><CODE>input</CODE> - The log to convert</DL>
|
||
|
</DD>
|
||
|
</DL>
|
||
|
<HR>
|
||
|
|
||
|
<A NAME="byteArrayToLong(byte[])"><!-- --></A><H3>
|
||
|
byteArrayToLong</H3>
|
||
|
<PRE>
|
||
|
public static long <B>byteArrayToLong</B>(byte[] input)</PRE>
|
||
|
<DL>
|
||
|
<DD>Utility method for converting a byte[] into a long
|
||
|
<P>
|
||
|
<DD><DL>
|
||
|
<DT><B>Parameters:</B><DD><CODE>input</CODE> - The byte[] to convert
|
||
|
<DT><B>Returns:</B><DD>a long representation</DL>
|
||
|
</DD>
|
||
|
</DL>
|
||
|
<HR>
|
||
|
|
||
|
<A NAME="byteArrayToLong(byte[], int)"><!-- --></A><H3>
|
||
|
byteArrayToLong</H3>
|
||
|
<PRE>
|
||
|
public static long <B>byteArrayToLong</B>(byte[] input,
|
||
|
int offset)</PRE>
|
||
|
<DL>
|
||
|
<DD><DL>
|
||
|
</DL>
|
||
|
</DD>
|
||
|
</DL>
|
||
|
<HR>
|
||
|
|
||
|
<A NAME="uByteToInt(byte)"><!-- --></A><H3>
|
||
|
uByteToInt</H3>
|
||
|
<PRE>
|
||
|
public static int <B>uByteToInt</B>(byte b)</PRE>
|
||
|
<DL>
|
||
|
<DD><DL>
|
||
|
</DL>
|
||
|
</DD>
|
||
|
</DL>
|
||
|
<HR>
|
||
|
|
||
|
<A NAME="uShortToInt(short)"><!-- --></A><H3>
|
||
|
uShortToInt</H3>
|
||
|
<PRE>
|
||
|
public static int <B>uShortToInt</B>(short b)</PRE>
|
||
|
<DL>
|
||
|
<DD><DL>
|
||
|
</DL>
|
||
|
</DD>
|
||
|
</DL>
|
||
|
<HR>
|
||
|
|
||
|
<A NAME="intToUByte(int)"><!-- --></A><H3>
|
||
|
intToUByte</H3>
|
||
|
<PRE>
|
||
|
public static byte <B>intToUByte</B>(int i)</PRE>
|
||
|
<DL>
|
||
|
<DD><DL>
|
||
|
</DL>
|
||
|
</DD>
|
||
|
</DL>
|
||
|
<!-- ========= END OF CLASS DATA ========= -->
|
||
|
<HR>
|
||
|
|
||
|
|
||
|
<!-- ======= START OF BOTTOM NAVBAR ====== -->
|
||
|
<A NAME="navbar_bottom"><!-- --></A>
|
||
|
<A HREF="#skip-navbar_bottom" title="Skip navigation links"></A>
|
||
|
<TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0" SUMMARY="">
|
||
|
<TR>
|
||
|
<TD COLSPAN=2 BGCOLOR="#EEEEFF" CLASS="NavBarCell1">
|
||
|
<A NAME="navbar_bottom_firstrow"><!-- --></A>
|
||
|
<TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3" SUMMARY="">
|
||
|
<TR ALIGN="center" VALIGN="top">
|
||
|
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../overview-summary.html"><FONT CLASS="NavBarFont1"><B>Overview</B></FONT></A> </TD>
|
||
|
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-summary.html"><FONT CLASS="NavBarFont1"><B>Package</B></FONT></A> </TD>
|
||
|
<TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> <FONT CLASS="NavBarFont1Rev"><B>Class</B></FONT> </TD>
|
||
|
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="class-use/MathUtils.html"><FONT CLASS="NavBarFont1"><B>Use</B></FONT></A> </TD>
|
||
|
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A> </TD>
|
||
|
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A> </TD>
|
||
|
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../index-all.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A> </TD>
|
||
|
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A> </TD>
|
||
|
</TR>
|
||
|
</TABLE>
|
||
|
</TD>
|
||
|
<TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM>
|
||
|
Rice Pastry API</EM>
|
||
|
</TD>
|
||
|
</TR>
|
||
|
|
||
|
<TR>
|
||
|
<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
|
||
|
<A HREF="../../../rice/p2p/util/ImmutableSortedMap.html" title="class in rice.p2p.util"><B>PREV CLASS</B></A>
|
||
|
<A HREF="../../../rice/p2p/util/MCAdapter.html" title="class in rice.p2p.util"><B>NEXT CLASS</B></A></FONT></TD>
|
||
|
<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
|
||
|
<A HREF="../../../index.html?rice/p2p/util/MathUtils.html" target="_top"><B>FRAMES</B></A>
|
||
|
<A HREF="MathUtils.html" target="_top"><B>NO FRAMES</B></A>
|
||
|
<SCRIPT type="text/javascript">
|
||
|
<!--
|
||
|
if(window==top) {
|
||
|
document.writeln('<A HREF="../../../allclasses-noframe.html"><B>All Classes</B></A>');
|
||
|
}
|
||
|
//-->
|
||
|
</SCRIPT>
|
||
|
<NOSCRIPT>
|
||
|
<A HREF="../../../allclasses-noframe.html"><B>All Classes</B></A>
|
||
|
</NOSCRIPT>
|
||
|
|
||
|
|
||
|
</FONT></TD>
|
||
|
</TR>
|
||
|
<TR>
|
||
|
<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
|
||
|
SUMMARY: NESTED | <A HREF="#field_summary">FIELD</A> | CONSTR | <A HREF="#method_summary">METHOD</A></FONT></TD>
|
||
|
<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
|
||
|
DETAIL: <A HREF="#field_detail">FIELD</A> | CONSTR | <A HREF="#method_detail">METHOD</A></FONT></TD>
|
||
|
</TR>
|
||
|
</TABLE>
|
||
|
<A NAME="skip-navbar_bottom"></A>
|
||
|
<!-- ======== END OF BOTTOM NAVBAR ======= -->
|
||
|
|
||
|
<HR>
|
||
|
<i>Copyright © 2001-2005 - Rice Pastry.</i>
|
||
|
</BODY>
|
||
|
</HTML>
|