standup.utils
Class Utils

java.lang.Object
  extended by standup.utils.Utils

public class Utils
extends Object

A collection of various low-level utility functions, all accessible from a static context.

Author:
Ruli Manurung

Field Summary
private static Random dice
           
private static int fODD_PRIME_NUMBER
           
static int SEED
          An initial value for a hashCode, to which is added contributions from fields.
 
Constructor Summary
Utils()
           
 
Method Summary
static void copy(InputStream in, File dst)
           
static
<T> List<T>
copyList(List<T> orig)
           
private static int firstTerm(int aSeed)
           
static
<T> T
getRandom(Collection<T> stuff)
           
static String getTimeString(long timeStamp)
           
static int hash(int aSeed, boolean aBoolean)
          booleans.
static int hash(int aSeed, char aChar)
          chars.
static int hash(int aSeed, double aDouble)
          doubles.
static int hash(int aSeed, float aFloat)
          floats.
static int hash(int aSeed, int aInt)
          ints.
static int hash(int aSeed, long aLong)
          longs.
static int hash(int aSeed, Object aObject)
          aObject is a possibly-null object field, and possibly an array.
private static boolean isArray(Object aObject)
           
static
<T> T
removeRandom(Collection<T> stuff)
           
static double throwDice()
           
static int throwDice(int max)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

dice

private static Random dice

SEED

public static final int SEED
An initial value for a hashCode, to which is added contributions from fields. Using a non-zero value decreases collisons of hashCode values.

See Also:
Constant Field Values

fODD_PRIME_NUMBER

private static final int fODD_PRIME_NUMBER
See Also:
Constant Field Values
Constructor Detail

Utils

public Utils()
Method Detail

getTimeString

public static String getTimeString(long timeStamp)

copy

public static void copy(InputStream in,
                        File dst)
                 throws IOException
Throws:
IOException

throwDice

public static double throwDice()

throwDice

public static int throwDice(int max)

getRandom

public static <T> T getRandom(Collection<T> stuff)

removeRandom

public static <T> T removeRandom(Collection<T> stuff)

copyList

public static <T> List<T> copyList(List<T> orig)

hash

public static int hash(int aSeed,
                       boolean aBoolean)
booleans.


hash

public static int hash(int aSeed,
                       char aChar)
chars.


hash

public static int hash(int aSeed,
                       int aInt)
ints.


hash

public static int hash(int aSeed,
                       long aLong)
longs.


hash

public static int hash(int aSeed,
                       float aFloat)
floats.


hash

public static int hash(int aSeed,
                       double aDouble)
doubles.


hash

public static int hash(int aSeed,
                       Object aObject)
aObject is a possibly-null object field, and possibly an array. If aObject is an array, then each element may be a primitive or a possibly-null object.


firstTerm

private static int firstTerm(int aSeed)

isArray

private static boolean isArray(Object aObject)