HashSet that can take Arrays/Collections (Lists, other sets, etc) as args.

Discussion in 'Resources' started by VoidWhisperer, Aug 26, 2012.

Thread Status:
Not open for further replies.
  1. Offline

    VoidWhisperer

    Code:
    public class VSet<T> extends HashSet<T> {
        private static final long serialVersionUID = 735658361929997765L;
        public VSet()
        {
            super();
            //Allows for no-arg initialization
        }
        public VSet(Collection<T> a)
        {
            super(a);
        }
        public VSet(T[] a)
        {
            super();
            for(T q : a)
            {
                add(q);
            }
        }
    }
    I got very bored after someone asked me how to intialize a HashSet with an array. I'm pretty sure this has no point, but I figured i'd share it anyways.
     
  2. Offline

    Giant

    Seems to me this is a bit useless, as it already is able to store these anyhow?
     
Thread Status:
Not open for further replies.

Share This Page