Java HashSet Create toHashSet(Object[] array)

Here you can find the source of toHashSet(Object[] array)

Description

to Hash Set

License

Open Source License

Declaration

public static HashSet toHashSet(Object[] array) 

Method Source Code

//package com.java2s;
/*//ww  w. ja v a2  s  . co m
 * This file is part of the Jose Project
 * see http://jose-chess.sourceforge.net/
 * (c) 2002-2006 Peter Sch?fer
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 */

import java.util.*;

public class Main {
    public static HashSet toHashSet(Object[] array) {
        HashSet result = new HashSet();
        for (int i = array.length - 1; i >= 0; i--)
            result.add(array[i]);
        return result;
    }

    public static void add(Collection coll, Object[] array) {
        for (int i = 0; i < array.length; i++)
            coll.add(array[i]);
    }

    public static void add(Map map, Object[] array) {
        for (int i = 0; i < array.length; i += 2)
            map.put(array[i], array[i + 1]);
    }
}

Related

  1. newHashSetOnNull(Set set)
  2. print_bigrams(HashSet bigrams)
  3. printlnStringHashSet(HashSet hashSet)
  4. select(HashSet S)
  5. stringArrayToHashset(String[] strings)
  6. toHashSet(Set inp)