it.unimi.dsi.mg4j.util
Class Fast

java.lang.Object
  extended by it.unimi.dsi.mg4j.util.Fast

public final class Fast
extends Object

All-purpose optimised static-method container class.

This class contains static optimised utility methods that are used by all MG4J classes.

Since:
0.1
Author:
Sebastiano Vigna

Field Summary
static int[] BYTELSB
          Deprecated. Moved to dsiutils.
static int[] BYTEMSB
          Deprecated. Moved to dsiutils.
 
Method Summary
static long availableMemory()
          Deprecated. Moved to dsiutils.
static void compactMemory()
          Deprecated. Moved to dsiutils.
static void ensureLog4JIsConfigured()
          Deprecated. Moved to dsiutils.
static void ensureLog4JIsConfigured(Level level)
          Deprecated. Moved to dsiutils.
static String format(double d)
          Deprecated. Moved to dsiutils.
static String format(long l)
          Deprecated. Moved to dsiutils.
static String formatBinarySize(long l)
          Deprecated. Moved to dsiutils.
static String formatSize(long l)
          Deprecated. Moved to dsiutils.
static Logger getLogger(Class<?> klass)
          Deprecated. Moved to dsiutils.
static int int2nat(int x)
          Deprecated. Moved to dsiutils.
static long int2nat(long x)
          Deprecated. Moved to dsiutils.
static int leastSignificantBit(int x)
          Deprecated. Moved to dsiutils.
static int leastSignificantBit(long x)
          Deprecated. Moved to dsiutils.
static boolean log4JIsConfigured()
          Deprecated. Moved to dsiutils.
static boolean memoryIsLow()
          Deprecated. Moved to dsiutils.
static int mostSignificantBit(int x)
          Deprecated. Moved to dsiutils.
static int mostSignificantBit(long x)
          Deprecated. Moved to dsiutils.
static int nat2int(int x)
          Deprecated. Moved to dsiutils.
static long nat2int(long x)
          Deprecated. Moved to dsiutils.
static int percAvailableMemory()
          Deprecated. Moved to dsiutils.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

BYTELSB

@Deprecated
public static final int[] BYTELSB
Deprecated. Moved to dsiutils.
Precomputed least significant bits for bytes (-1 for 0 ).


BYTEMSB

@Deprecated
public static final int[] BYTEMSB
Deprecated. Moved to dsiutils.
Precomputed most significant bits for bytes (-1 for 0 ).

Method Detail

mostSignificantBit

@Deprecated
public static int mostSignificantBit(int x)
Deprecated. Moved to dsiutils.

Computes the most significant bit of an integer.

Parameters:
x - an integer.
Returns:
the most significant bit of the argument (-1 for 0).

mostSignificantBit

@Deprecated
public static int mostSignificantBit(long x)
Deprecated. Moved to dsiutils.

Computes the most significant bit of a long integer.

Parameters:
x - a long integer.
Returns:
the most significant bit of the argument (-1 for 0).

leastSignificantBit

@Deprecated
public static int leastSignificantBit(int x)
Deprecated. Moved to dsiutils.

Computes the least significant bit of an integer.

Parameters:
x - an integer.
Returns:
the least significant bit of the argument (-1 for 0).

leastSignificantBit

@Deprecated
public static int leastSignificantBit(long x)
Deprecated. Moved to dsiutils.

Computes the least significant bit of a long integer.

Parameters:
x - a long integer.
Returns:
the least significant bit of the argument (-1 for 0).

int2nat

@Deprecated
public static int int2nat(int x)
Deprecated. Moved to dsiutils.

Maps integers bijectively into natural numbers.

This method will map a negative integer x to -2x-1 and a nonnegative integer x to 2x. It can be used to save integers in the range [Integer.MIN_VALUE/2..Integer.MAX_VALUE/2] (i.e., [-230..230-1]) using the standard coding methods (which all work on natural numbers). Note that no range checks are performed.

The inverse of the above map is computed by nat2int(int).

Parameters:
x - an integer.
Returns:
the argument mapped into a natural number.
See Also:
nat2int(int)

nat2int

@Deprecated
public static int nat2int(int x)
Deprecated. Moved to dsiutils.

Maps natural numbers bijectively into integers.

This method computes the inverse of int2nat(int).

Parameters:
x - a natural number.
Returns:
the argument mapped into an integer.
See Also:
int2nat(int)

int2nat

@Deprecated
public static long int2nat(long x)
Deprecated. Moved to dsiutils.

Maps longs bijectively into long natural numbers.

This method will map a negative long x to -2x-1 and a nonnegative long x to 2x. It can be used to save longs in the range [Long.MIN_VALUE/2..Long.MAX_VALUE/2] (i.e., [-262..262-1]) using the standard coding methods (which all work on natural numbers). Note that no range checks are performed.

The inverse of the above map is computed by nat2int(long).

Parameters:
x - a long.
Returns:
the argument mapped into a long natural number.
See Also:
int2nat(int)

nat2int

@Deprecated
public static long nat2int(long x)
Deprecated. Moved to dsiutils.

Maps long natural numbers bijectively into longs.

This method computes the inverse of int2nat(long).

Parameters:
x - a long natural number.
Returns:
the argument mapped into a long.
See Also:
nat2int(int)

format

@Deprecated
public static String format(double d)
Deprecated. Moved to dsiutils.

Formats a number.

This method formats a double separating thousands and printing just two fractional digits.

Parameters:
d - a number.
Returns:
a string containing a pretty print of the number.

format

@Deprecated
public static String format(long l)
Deprecated. Moved to dsiutils.

Formats a number.

This method formats a long separating thousands.

Parameters:
l - a number.
Returns:
a string containing a pretty print of the number.

formatSize

@Deprecated
public static String formatSize(long l)
Deprecated. Moved to dsiutils.

Formats a size.

This method formats a long using suitable unit multipliers (e.g., K, M, G, and T) and printing just two fractional digits.

Parameters:
l - a number, representing a size (e.g., memory).
Returns:
a string containing a pretty print of the number using unit multipliers.

formatBinarySize

@Deprecated
public static String formatBinarySize(long l)
Deprecated. Moved to dsiutils.

Formats a binary size.

This method formats a long using suitable unit binary multipliers (e.g., Ki, Mi, Gi, and Ti) and printing no fractional digits. The argument must be a power of 2.

Parameters:
l - a number, representing a binary size (e.g., memory); must be a power of 2.
Returns:
a string containing a pretty print of the number using binary unit multipliers.

log4JIsConfigured

@Deprecated
public static boolean log4JIsConfigured()
Deprecated. Moved to dsiutils.

Checks whether Log4J is properly configuring by searching for appenders in all loggers.

Returns:
whether Log4J is configured (or, at least, an educated guess).

ensureLog4JIsConfigured

@Deprecated
public static void ensureLog4JIsConfigured()
Deprecated. Moved to dsiutils.

Ensures that Log4J is configured, by invoking, if necessary, BasicConfigurator.configure(), and setting the root logger level to Level.INFO.


ensureLog4JIsConfigured

@Deprecated
public static void ensureLog4JIsConfigured(Level level)
Deprecated. Moved to dsiutils.

Ensures that Log4J is configured, by invoking, if necessary, BasicConfigurator.configure(), and setting the root logger level to level.

Parameters:
level - the required logging level.

getLogger

@Deprecated
public static Logger getLogger(Class<?> klass)
Deprecated. Moved to dsiutils.

Calls Log4J's Logger.getLogger(java.lang.Class) method and then ensureLog4JIsConfigured().

Parameters:
klass - a class that will be passed to Logger.getLogger(java.lang.Class).
Returns:
the logger returned by Logger.getLogger(java.lang.Class).

memoryIsLow

@Deprecated
public static boolean memoryIsLow()
Deprecated. Moved to dsiutils.

Returns true if less then 5% of the available memory is free.

Returns:
true if less then 5% of the available memory is free.

availableMemory

@Deprecated
public static long availableMemory()
Deprecated. Moved to dsiutils.

Returns the amount of available memory (free memory plus never allocated memory).

Returns:
the amount of available memory, in bytes.

percAvailableMemory

@Deprecated
public static int percAvailableMemory()
Deprecated. Moved to dsiutils.

Returns the percentage of available memory (free memory plus never allocated memory).

Returns:
the percentage of available memory.

compactMemory

@Deprecated
public static void compactMemory()
Deprecated. Moved to dsiutils.

Tries to compact memory as much as possible by forcing garbage collection.