Set addAll - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Set addAll method.

This code example shows how to use the following methods:addAll
  public void remove(T elem) {
    ids.remove(elem);
  } 
 
  public void merge(ChoosableSet<T> toMerge) {
    ids.addAll(toMerge.ids);
  } 
 
  public boolean isEmpty() { 
    return ids.isEmpty();
  } 
 
  @Override 
  public Iterator<T> iterator() {
    return ids.iterator();
  } 
 
  public synchronized T choose() { 
    if (!ids.isEmpty()) {
      if (iter == null || !iter.hasNext()) {
7
CodeRank
This code example shows how to use the following methods:add, addAll, contains, containsAll
import java.util.Arrays; 
import java.util.Collections; 
import java.util.Set; 
import java.util.TreeSet; 
 
public class Sets { 
    public static void main(String[] args){
        Set<Integer> a = new TreeSet<>();
        //TreeSet sorts on natural ordering (or an optional comparator) 
        //other options: HashSet (hashcode) 
        //               LinkedHashSet (insertion order) 
        //               EnumSet (optimized for enum values) 
        //others at: http://download.oracle.com/javase/7/docs/api/java/util/Set.html 
        Set<Integer> b = new TreeSet<>();
        Set<Integer> c = new TreeSet<>();
        Set<Integer> d = new TreeSet<>();
 
        a.addAll(Arrays.asList(1, 2, 3, 4, 5));
        b.addAll(Arrays.asList(2, 3, 4, 5, 6, 8));
        c.addAll(Arrays.asList(2, 3, 4));

7
CodeRank
This code example shows how to use the following methods:addAll
    } 
 
    @Override 
    public Object fromString(String input) {
 
        Set<String> tagValues = new HashSet<String>();
 
        if(input != null && !input.isEmpty()){
            String[] splitInput = input.split(SPLIT);
            tagValues.addAll(Arrays.asList(splitInput));
        } 
 
        return new MergeableTags(tagValues);
    } 
} 
7
CodeRank
This code example shows how to use the following methods:addAll, size, toArray
		} 
	} 
 
	private Method[] getMethods(Class<?> type, Object targetObject) {
		if (targetObject instanceof Class) {
			Set<Method> methods = new HashSet<Method>();
			methods.addAll(Arrays.asList(getMethods(type)));
			methods.addAll(Arrays.asList(getMethods(targetObject.getClass())));
			return methods.toArray(new Method[methods.size()]);
		} 
		return getMethods(type);
	} 
 
	/** 
	 * Return the set of methods for this type. The default implementation returns the 
	 * result of {@link Class#getMethods()} for the given {@code type}, but subclasses 
	 * may override in order to alter the results, e.g. specifying static methods 
	 * declared elsewhere. 
	 * @param type the class for which to return the methods 
	 * @since 3.1.1 
8
CodeRank
This code example shows how to use the following methods:add, addAll
    public boolean hasSchemaTypes() { 
        return schemaTypes != null;
    } 
 
    public Collection<String> getDefinedNamespaces() throws Exception {
        Set<String> namespaces = new HashSet<String>();
 
        SchemaTypeSystem schemaTypes = getSchemaTypeSystem();
        if (schemaTypes != null) {
            namespaces.addAll(SchemaUtils.extractNamespaces(getSchemaTypeSystem(), true));
        } 
 
        namespaces.add(getTargetNamespace());
 
        return namespaces;
    } 
 
    public String getTargetNamespace() {
        return WsdlUtils.getTargetNamespace(definition);
    } 
7
CodeRank
This code example shows how to use the following methods:addAll, isEmpty
        } 
        if (filter1.excluded.isEmpty() && filter2.excluded.isEmpty()) {
            excluded = Collections.emptySet();
        } else { 
            excluded = new HashSet<String>(filter1.excluded);
            excluded.addAll(filter2.excluded);
        } 
        shortcut = findShortcut();
    } 
 
    protected Boolean findShortcut() {
        if (required.isEmpty() && excluded.isEmpty()) {
            // no condition, always matches 
            return Boolean.TRUE;
        } 
        Collection<String> intersection = new HashSet<String>(required);
        intersection.retainAll(excluded);
        if (!intersection.isEmpty()) {
            // non-empty intersection, filter can never match 
            return Boolean.FALSE;

7
CodeRank
This code example shows how to use the following methods:addAll
    } 
 
    @Override 
    public Set<Class<?>> getClasses() {
        Set<Class<?>> classes = super.getClasses();
        classes.addAll(tmApplication.getClasses());
 
        return classes;
    } 
 
    @Override 
    public Set<Object> getSingletons() {
        Set<Object> singletons = super.getSingletons();
        singletons.addAll(tmApplication.getSingletons());
 
        return singletons;
    } 
} 
7
CodeRank
This code example shows how to use the following methods:addAll, toArray
        final TransactionImporter transactionImporter = SubordinationManager.getTransactionImporter();
        return transactionImporter.importTransaction(xidTransactionID.getXid(), txTimeout);
    } 
 
    public Xid[] getXidsToRecoverForParentNode(final String parentNodeName, int recoveryFlags) throws XAException {
        final Set<Xid> xidsToRecover = new HashSet<Xid>();
        final TransactionImporter transactionImporter = SubordinationManager.getTransactionImporter();
        if (transactionImporter instanceof TransactionImporterImple) {
            final Set<Xid> inFlightXids = ((TransactionImporterImple) transactionImporter).getInflightXids(parentNodeName);
            if (inFlightXids != null) {
                xidsToRecover.addAll(inFlightXids);
            } 
        } 
        final XATerminator xaTerminator = SubordinationManager.getXATerminator();
        if (xaTerminator instanceof XATerminatorImple) {
            final Xid[] inDoubtTransactions = ((XATerminatorImple) xaTerminator).doRecover(null, parentNodeName);
            if (inDoubtTransactions != null) {
                xidsToRecover.addAll(Arrays.asList(inDoubtTransactions));
            } 
        } else { 

8
CodeRank
This code example shows how to use the following methods:addAll
        return keySet().contains( s );
    } 
 
    @SuppressWarnings("unchecked") 
    public Set<String> keySet(){
        Set<String> keys = new HashSet();
        keys.addAll(VALID_FIELDS);
        keys.addAll(_extradata.keySet());
        return keys;
    } 
 
    public boolean isPartialObject(){ 
        return false; 
    } 
 
    public void markAsPartialObject(){ 
        throw new RuntimeException( "can't load partial GridFSFile file" );
    } 
     
    // ---------------------- 
7
CodeRank
This code example shows how to use the following methods:addAll
  public void remove(T elem) {
    ids.remove(elem);
  } 
 
  public void merge(ChoosableSet<T> toMerge) {
    ids.addAll(toMerge.ids);
  } 
 
  public boolean isEmpty() { 
    return ids.isEmpty();
  } 
 
  @Override 
  public Iterator<T> iterator() {
    return ids.iterator();
  } 
 
  public synchronized T choose() { 
    if (!ids.isEmpty()) {
      if (iter == null || !iter.hasNext()) {
6
CodeRank
addAll Method Overview
Adds all of the elements in the specified collection to this set if they're not already present (optional operation).
See Code Examples for other Java 8 Set Methods: