Example usage for java.util.concurrent CopyOnWriteArraySet CopyOnWriteArraySet

List of usage examples for java.util.concurrent CopyOnWriteArraySet CopyOnWriteArraySet

Introduction

In this page you can find the example usage for java.util.concurrent CopyOnWriteArraySet CopyOnWriteArraySet.

Prototype

public CopyOnWriteArraySet() 

Source Link

Document

Creates an empty set.

Usage

From source file:Main.java

public static <E> CopyOnWriteArraySet<E> getCopyOnWriteArraySet() {
    return new CopyOnWriteArraySet<E>();
}

From source file:Main.java

public static <E> CopyOnWriteArraySet<E> createCopyOnWriteArraySet() {
    return new CopyOnWriteArraySet<E>();
}

From source file:Main.java

public static <E> CopyOnWriteArraySet<E> getCopyOnWriteArraySet(Collection<? extends E> collection) {
    return new CopyOnWriteArraySet<E>();
}

From source file:Main.java

public static <E> CopyOnWriteArraySet<E> createCopyOnWriteArraySet(Collection<? extends E> collection) {
    return new CopyOnWriteArraySet<E>();
}

From source file:Main.java

/**
 * Given any of the known collection types, this method will return an instance of the collection.
 * @param collectionType    the type of the collection
 * @return the collection instance/*  w ww.j  av a  2 s  . c  om*/
 */
public static Collection<?> getCollection(Class<?> collectionType) {
    if (HashSet.class.equals(collectionType)) {
        return new HashSet<Object>();
    } else if (TreeSet.class.equals(collectionType)) {
        return new TreeSet<Object>();
    } else if (CopyOnWriteArraySet.class.equals(collectionType)) {
        return new CopyOnWriteArraySet<Object>();
    } else if (LinkedHashSet.class.equals(collectionType)) {
        return new LinkedHashSet<Object>();
    } else if (ArrayList.class.equals(collectionType)) {
        return new ArrayList<Object>();
    } else if (LinkedList.class.equals(collectionType)) {
        return new LinkedList<Object>();
    } else if (Vector.class.equals(collectionType)) {
        return new Vector<Object>();
    } else if (Stack.class.equals(collectionType)) {
        return new Stack<Object>();
    } else if (PriorityQueue.class.equals(collectionType)) {
        return new PriorityQueue<Object>();
    } else if (PriorityBlockingQueue.class.equals(collectionType)) {
        return new PriorityBlockingQueue<Object>();
    } else if (ArrayDeque.class.equals(collectionType)) {
        return new ArrayDeque<Object>();
    } else if (ConcurrentLinkedQueue.class.equals(collectionType)) {
        return new ConcurrentLinkedQueue<Object>();
    } else if (LinkedBlockingQueue.class.equals(collectionType)) {
        return new LinkedBlockingQueue<Object>();
    } else if (LinkedBlockingDeque.class.equals(collectionType)) {
        return new LinkedBlockingDeque<Object>();
    } else if (List.class.equals(collectionType)) {
        return new LinkedList<Object>();
    } else if (Set.class.equals(collectionType)) {
        return new HashSet<Object>();
    } else if (Queue.class.equals(collectionType)) {
        return new PriorityQueue<Object>();
    } else if (Deque.class.equals(collectionType)) {
        return new ArrayDeque<Object>();
    } else if (Collection.class.equals(collectionType)) {
        return new LinkedList<Object>();
    }
    throw new IllegalArgumentException("Unsupported collection type: " + collectionType);
}

From source file:Main.java

/**
 * Create a new concurrent set./*from ww w .j  a  v  a 2 s  .co  m*/
 *
 * @param <T> The type of value.
 *
 * @return The new concurrent set.
 */
public static <T> Set<T> newConcurrentSet() {
    return new CopyOnWriteArraySet<T>();
}

From source file:Main.java

/**
 * This method, as the name suggests, will take the union of all the input sets,
 * creating an output, thread-safe set./*from  w  w w. ja  va2s.c o  m*/
 * @param collections    input sets
 * @param <E>     type of set items
 * @return a set that is the union of all input sets
 */
public static <E> Set<E> union(Collection<E>... collections) {
    final CopyOnWriteArraySet<E> result = new CopyOnWriteArraySet<E>();
    for (Collection<E> collection : collections) {
        result.addAll(collection);
    }
    return result;
}

From source file:ubic.BAMSandAllen.JenaUtil.java

public static Set<OntClass> fitlerClasses(Set classes, ClassSelector filter) {
    Set<OntClass> result = new CopyOnWriteArraySet<OntClass>();
    for (Object o : classes) {
        OntClass ontClass = (OntClass) o;
        if (filter.test(ontClass)) {
            result.add(ontClass);/*from   w w  w  . jav a 2 s  . c  o m*/
        }
    }
    return result;
}

From source file:uta.ak.usttmp.common.textmining.FileExcludeStopWord.java

public FileExcludeStopWord() {

    //Load stopword file
    InputStreamReader isr = null;
    try {/*from w  ww . ja v a 2 s. c om*/
        stopWordsList = new CopyOnWriteArraySet<>();
        Resource res = new ClassPathResource("StopWordTable2.txt");
        //                File stopwords=res.getFile();
        //      File stopwords=new File("/Users/zhangcong/dev/corpus/StopWordTable2.txt");
        isr = new InputStreamReader(res.getInputStream());
        BufferedReader stops = null;
        try {
            String tempString = null;
            stops = new BufferedReader(isr);
            tempString = stops.readLine();
            while ((tempString = stops.readLine()) != null) {
                if (!tempString.isEmpty()) {
                    stopWordsList.add(tempString.toLowerCase().trim());
                }
            }

        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

    } catch (IOException ex) {
        Logger.getLogger(FileExcludeStopWord.class.getName()).log(Level.SEVERE, null, ex);
    } finally {
        try {
            isr.close();
        } catch (IOException ex) {
            Logger.getLogger(FileExcludeStopWord.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
}

From source file:com.amazonaws.http.DelegatingDnsResolverTest.java

@Before
public void resetClientConfiguration() {
    dnsResolutionCounter = new AtomicInteger(0);
    requestedHosts = new CopyOnWriteArraySet<String>();

    ClientConfiguration clientConfiguration = new ClientConfiguration();
    clientConfiguration.withMaxErrorRetry(0);
    clientConfiguration.withDnsResolver(new DnsResolver() {
        DnsResolver system = new SystemDefaultDnsResolver();

        @Override//w w  w.  j a  v a  2s  .  c  om
        public InetAddress[] resolve(String host) throws UnknownHostException {
            dnsResolutionCounter.incrementAndGet();
            requestedHosts.add(host);
            return system.resolve(host);
        }
    });

    testedClient = new AmazonHttpClient(clientConfiguration);
}