com.limegroup.gnutella.util
Class Utilities

java.lang.Object
  extended bycom.limegroup.gnutella.util.Utilities

public class Utilities
extends java.lang.Object

Provides utility methods like checking set intersection etc.


Constructor Summary
Utilities()
           
 
Method Summary
static void fill(byte[] array, int start, int stop, byte value)
          An optimized replacement for Arrays.fill that takes advantage of System.arraycopy.
static void fill(int[] array, int start, int stop, int value)
          An optimized replacement for Arrays.fill that takes advantage of System.arraycopy.
static boolean hasIntersection(java.util.Set set1, java.util.Set set2)
          Determines if two sets have non-void intersection
static byte log2(int num)
          Returns the based 2 logarithm of num.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Utilities

public Utilities()
Method Detail

hasIntersection

public static boolean hasIntersection(java.util.Set set1,
                                      java.util.Set set2)
Determines if two sets have non-void intersection

Parameters:
set1 - First set
set2 - Second set
Returns:
true, if two sets have non-void intersection, false otherwise

fill

public static void fill(int[] array,
                        int start,
                        int stop,
                        int value)
An optimized replacement for Arrays.fill that takes advantage of System.arraycopy. On my Windows machine, this is over nearly twice as fast for arrays greater than 1000 elements. The savings decrease somewhat over 32000 elements.

Parameters:
array - the array to fill
start - the starting offset, inclusive
stop - the stop offset+1. MUST be greater than start; this differs from Arrays.fill.
value - the value to write into the array

fill

public static void fill(byte[] array,
                        int start,
                        int stop,
                        byte value)
An optimized replacement for Arrays.fill that takes advantage of System.arraycopy. On someone's Windows machine, this is over nearly twice as fast for arrays greater than 1000 elements. The savings decrease somewhat over 32000 elements.

Parameters:
array - the array to fill
start - the starting offset, inclusive
stop - the stop offset+1. MUST be greater than start; this differs from Arrays.fill.
value - the value to write into the array

log2

public static byte log2(int num)
Returns the based 2 logarithm of num.

Parameters:
num - MUST be a power of 2