Here you can find the source of select(HashSet
public static int select(HashSet<Integer> S)
//package com.java2s; //License from project: Open Source License import java.util.*; public class Main { public static int select(HashSet<Integer> S) { Random R = new Random(); int r = R.nextInt(S.size()); int i = 0; for (int e : S) { i++;/*ww w. ja v a 2s. c o m*/ if (i == r) { return e; } } return 0; } }