Java HashSet Create select(HashSet S)

Here you can find the source of select(HashSet S)

Description

select

License

Open Source License

Declaration

public static int select(HashSet<Integer> S) 

Method Source Code


//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;
    }
}

Related

  1. newHashSet(E... elements)
  2. newHashSet(E... elements)
  3. newHashSetOnNull(Set set)
  4. print_bigrams(HashSet bigrams)
  5. printlnStringHashSet(HashSet hashSet)
  6. stringArrayToHashset(String[] strings)
  7. toHashSet(Object[] array)
  8. toHashSet(Set inp)