// Collection of code snippets by Arne Vajhøj 
// (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) 
import java.io.UnsupportedEncodingException;
import java.util.HashSet;
import java.util.Random;
import java.util.Set;

public class IniCap {
    private static Random rng = new Random();
    private static void testDefault() throws UnsupportedEncodingException {
        long t1 = System.currentTimeMillis();
        Set<String> c = new HashSet<String>();
        for(int i = 0; i < 5000; i++) {
            byte [] b = new byte[20];
            rng.nextBytes(b);
            c.add(new String(b, "ISO-8859-1"));
        }
        long t2 = System.currentTimeMillis();
        System.out.println(t2 - t1);
    }
    private static void test10000() throws UnsupportedEncodingException {
        long t1 = System.currentTimeMillis();
        Set<String> c = new HashSet<String>(10000);
        for(int i = 0; i < 5000; i++) {
            byte [] b = new byte[20];
            rng.nextBytes(b);
            c.add(new String(b, "ISO-8859-1"));
        }
        long t2 = System.currentTimeMillis();
        System.out.println(t2 - t1);
    }
    public static void main(String[] args) throws Exception {
        testDefault();
        test10000();
    }
}
