Example usage for org.apache.commons.collections.set CompositeSet addComposited

List of usage examples for org.apache.commons.collections.set CompositeSet addComposited

Introduction

In this page you can find the example usage for org.apache.commons.collections.set CompositeSet addComposited.

Prototype

public synchronized void addComposited(Collection[] comps) 

Source Link

Document

Add an array of sets to this composite

Usage

From source file:SetExampleV2.java

public static void main(String args[]) {
    // create two sets
    Set set1 = new HashSet();
    set1.add("Red");
    set1.add("Green");

    Set set2 = new HashSet();
    set2.add("Yellow");
    set2.add("Red");

    // create a composite set out of these two
    CompositeSet composite = new CompositeSet();

    // set the class that handles additions, conflicts etc
    // composite.setMutator(new CompositeMutator());

    // initialize the composite with the sets
    // Cannot be used if set1 and set2 intersect is not null and
    // a strategy to deal with it has not been set
    composite.addComposited(new Set[] { set1, set2 });

    // do some addition/deletions
    // composite.add("Pink");
    // composite.remove("Green");

    // whats left in the composite?
    Iterator itr = composite.iterator();

    while (itr.hasNext()) {
        System.err.println(itr.next());
    }/* w w  w. j  a va  2s.c o  m*/
}

From source file:com.amalto.core.storage.dispatch.CompositeStorage.java

@Override
public Set<String> getFullTextSuggestion(String keyword, FullTextSuggestion mode, int suggestionSize) {
    CompositeSet results = new CompositeSet();
    for (Storage storage : storages) {
        results.addComposited(storage.getFullTextSuggestion(keyword, mode, suggestionSize));
    }//from   w w w.  ja  v a  2 s  .  c  o m
    return results;
}