* Java 1.1 compatible. *
* * @see * ArrayLib2 * * @version * 2003-04-07 * @since * 2001-04-06 * @author * David Wallace Croft*/ public class Util{ /********************************************************************* * Removes duplicate elements from the array. *********************************************************************/ public static Object [ ] removeDuplicates ( Object [ ] array ) ////////////////////////////////////////////////////////////////////// { Hashtable hashtable = new Hashtable ( ); for ( int i = 0; i < array.length; i++ ) { hashtable.put ( array [ i ], array [ i ] ); } Object [ ] newArray = ( Object [ ] ) Array.newInstance ( array.getClass ( ).getComponentType ( ), hashtable.size ( ) ); int index = 0; Enumeration enumeration = hashtable.elements ( ); while ( enumeration.hasMoreElements ( ) ) { newArray [ index++ ] = enumeration.nextElement ( ); } return newArray; } }