All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class harpoon.Util.Util

java.lang.Object
   |
   +----harpoon.Util.Util

public abstract class Util
extends Object
Miscellaneous static utility functions.

Version:
$Id: Util.java,v 1.12 1998/11/10 03:34:37 cananian Exp $
Author:
C. Scott Ananian <cananian@alumni.princeton.edu>

Constructor Index

 o Util()

Method Index

 o assert(boolean)
Hacked assertion facility
 o assert(boolean, String)
 o copy(Object[])
Copy an array type to prevent modification.
 o escape(String)
Escape the contents of a String so they are safe to print.
 o ffs(int)
Find first set (least significant bit).
 o ffs(long)
Find first set (least significant bit).
 o fls(int)
Find last set (most significant bit).
 o fls(long)
Find last set (most significant bit).
 o grow(Object[], Object, int)
Insert element o before src[n].
 o log2c(int)
Returns ceil(log2(n))
 o repeatString(String, int)
Repeat a given string a certain number of times.
 o shrink(Object[], int)
Remove element 'n' from array 'src'.

Constructors

 o Util
 public Util()

Methods

 o copy
 public static final Object[] copy(Object src[])
Copy an array type to prevent modification. Does not bother to copy array types of length 0, because they're already immutable.

 o shrink
 public static final Object[] shrink(Object src[],
                                     int n)
Remove element 'n' from array 'src'.

 o grow
 public static final Object[] grow(Object src[],
                                   Object o,
                                   int n)
Insert element o before src[n].

After return, src[n]==o.

 o escape
 public static final String escape(String str)
Escape the contents of a String so they are safe to print.

 o assert
 public static final void assert(boolean val)
Hacked assertion facility

 o assert
 public static final void assert(boolean val,
                                 String msg)
 o repeatString
 public static final String repeatString(String s,
                                         int n)
Repeat a given string a certain number of times.

Returns:
a string consisting of s repeated n times.
 o ffs
 public static final int ffs(int v)
Find first set (least significant bit).

Returns:
the first bit set in the argument. ffs(0)==0 and ffs(1)==1.
 o ffs
 public static final int ffs(long v)
Find first set (least significant bit).

Returns:
the first bit set in the argument. ffs(0)==0 and ffs(1)==1.
 o fls
 public static final int fls(int v)
Find last set (most significant bit).

Returns:
the last bit set in the argument. fls(0)==0 and fls(1)==1.
 o fls
 public static final int fls(long v)
Find last set (most significant bit).

Returns:
the last bit set in the argument. fls(0)==0 and fls(1)==1.
 o log2c
 public static final int log2c(int v)
Returns ceil(log2(n))


All Packages  Class Hierarchy  This Package  Previous  Next  Index