Example usage for java.util HashSet addAll

List of usage examples for java.util HashSet addAll

Introduction

In this page you can find the example usage for java.util HashSet addAll.

Prototype

boolean addAll(Collection<? extends E> c);

Source Link

Document

Adds all of the elements in the specified collection to this set if they're not already present (optional operation).

Usage

From source file:edu.uci.ics.jung.graph.impl.SimpleSparseVertex.java

/**
 * Returns a set of all neighbors attached to this vertex.
 * Requires time proportional to the number of neighbors.
 * //from  www . ja v  a 2s. co m
 * @see AbstractSparseVertex#getNeighbors_internal()
 */
protected Collection getNeighbors_internal() {
    HashSet neighbors = new HashSet();
    neighbors.addAll(getPredsToInEdges().keySet());
    neighbors.addAll(getSuccsToOutEdges().keySet());
    neighbors.addAll(getNeighborsToEdges().keySet());
    return neighbors;
}

From source file:Business.InvertedIndex.java

public List searchForWholePhrase(List<DocInfo> docList, String[] queryTerms) {

    HashMap<DocInfo, Integer> documentPhraseScore = new HashMap<>();

    for (DocInfo doc : docList) {
        documentPhraseScore.put(doc, 0);
        int count = 0;
        for (String word1 : queryTerms) {
            String word2 = word1.replaceAll("[^\\w]", "");
            es.setCurrent(word2);/*from   w w w .  j ava2s .c om*/
            es.stem();
            String queryTerm = es.getCurrent();
            HashSet<Integer> positions = new HashSet<>();

            if (doc.getTermsInADocument().containsKey(queryTerm)) {
                if (positions.isEmpty()) {
                    positions.addAll(doc.getTermsInADocument().get(queryTerm).getPositions());
                } else {
                    ArrayList<Integer> newPositions = doc.getTermsInADocument().get(queryTerm).getPositions();
                    ArrayList<Integer> tempList = new ArrayList<>();
                    boolean b = false;
                    for (int po : newPositions) {

                        if (positions.contains(po - 1)) {
                            tempList.add(po);
                            int currentScore = documentPhraseScore.get(doc);
                            int newScore = currentScore + count;
                            documentPhraseScore.put(doc, newScore);
                            b = true;
                        }
                    }
                    if (b) {
                        positions.clear();
                        positions.addAll(tempList);
                    }
                }
            }
            if (count == 0) {
                count++;
            } else {
                count = count * 10;
            }
        }

    }

    Set<DocInfo> set = documentPhraseScore.keySet();
    List<DocInfo> sortedDocs = new ArrayList<>(set);

    Collections.sort(sortedDocs, (DocInfo s1, DocInfo s2) -> Double.compare(documentPhraseScore.get(s2),
            documentPhraseScore.get(s1)));
    return sortedDocs;
}

From source file:licenseUtil.LicensingList.java

public HashSet<String> getNonFixedHeaders() {
    HashSet<String> result = new HashSet<>();
    for (LicensingObject licensingObject : this) {
        result.addAll(licensingObject.getNonFixedHeaders());
    }/*w w w . j av a  2  s. co m*/
    return result;
}

From source file:de.tudarmstadt.ukp.lmf.transform.germanet.LexicalEntryGenerator.java

/**
 * This method consumes a list of RelatedForms and removes
 * all duplicates from the consumed list
 * @param relatedForms {@link List} of RelatedForm objects from which duplicates should be removed
 * @see {@link RelatedForm}/* www  .  j  a  v a  2  s  . c om*/
 * @since UBY 0.1.0
 */
private void removeDuplicateRelatedForms(List<RelatedForm> relatedForms) {
    if (relatedForms.isEmpty())
        return;

    HashSet<RelatedForm> temp = new HashSet<RelatedForm>();
    temp.addAll(relatedForms);
    relatedForms.clear();
    relatedForms.addAll(temp);
}

From source file:eu.esdihumboldt.hale.io.wfs.ui.AbstractWFSSource.java

/**
 * @see ImportSource#createControls(Composite)
 *///from w w w . java 2s .  c  o  m
@Override
public void createControls(Composite parent) {
    parent.setLayout(new GridLayout(4, false));

    // caption
    new Label(parent, SWT.NONE); // placeholder

    Label caption = new Label(parent, SWT.NONE);
    caption.setText(getCaption());
    caption.setLayoutData(new GridData(SWT.BEGINNING, SWT.BEGINNING, true, false, 3, 1));

    // source file
    // target URL field
    sourceURL = new URLSourceURIFieldEditor("sourceURL", "URL:", parent) {

        // the following methods are overridden so the capabilities button
        // may appear on the same line

        @Override
        public int getNumberOfControls() {
            return super.getNumberOfControls() + 1;
        }

        @Override
        protected void doFillIntoGrid(Composite parent, int numColumns) {
            super.doFillIntoGrid(parent, numColumns - 1);
        }

    };
    sourceURL.setPage(getPage());

    // set custom URI filter
    sourceURL.setURIFilter(createHistoryURIFilter());

    // set content types for URI field
    Collection<IOProviderDescriptor> factories = getConfiguration().getFactories();
    HashSet<IContentType> supportedTypes = new HashSet<IContentType>();
    for (IOProviderDescriptor factory : factories) {
        supportedTypes.addAll(factory.getSupportedTypes());
    }

    sourceURL.setContentTypes(supportedTypes);

    sourceURL.setPropertyChangeListener(new IPropertyChangeListener() {

        @Override
        public void propertyChange(PropertyChangeEvent event) {
            if (event.getProperty().equals(FieldEditor.IS_VALID)) {
                getPage().setMessage(null);
                updateState(true);
            } else if (event.getProperty().equals(FieldEditor.VALUE)) {
                getPage().setMessage(null);
                updateState(true);
            }
        }
    });

    // button to determine from capabilities
    Button capButton = new Button(parent, SWT.PUSH);
    capButton.setText("...");
    capButton.setToolTipText("Determine based on WFS Capabilities");
    capButton.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            determineSource(sourceURL);
        }
    });

    // provider selection

    // label
    Label providerLabel = new Label(parent, SWT.NONE);
    providerLabel.setText("Import as");

    // create provider combo
    ComboViewer providers = createProviders(parent);
    providers.getControl().setLayoutData(new GridData(SWT.FILL, SWT.BEGINNING, true, false, 3, 1));

    // initial state update
    updateState(true);
}

From source file:org.red5.server.net.rtmp.BaseRTMPHandler.java

/**
 * Handler for pending call result. Dispatches results to all pending call handlers.
 * @param conn         Connection/*from   w ww  . j  av a2 s . c  om*/
 * @param invoke       Pending call result event context
 */
protected void handlePendingCallResult(RTMPConnection conn, Notify invoke) {
    final IServiceCall call = invoke.getCall();
    final IPendingServiceCall pendingCall = conn.getPendingCall(invoke.getInvokeId());
    if (pendingCall != null) {
        // The client sent a response to a previously made call.
        Object[] args = call.getArguments();
        if ((args != null) && (args.length > 0)) {
            // TODO: can a client return multiple results?
            pendingCall.setResult(args[0]);
        }

        Set<IPendingServiceCallback> callbacks = pendingCall.getCallbacks();
        if (!callbacks.isEmpty()) {
            HashSet<IPendingServiceCallback> tmp = new HashSet<IPendingServiceCallback>();
            tmp.addAll(callbacks);
            for (IPendingServiceCallback callback : tmp) {
                try {
                    callback.resultReceived(pendingCall);
                } catch (Exception e) {
                    log.error("Error while executing callback " + callback, e);
                }
            }
        }
    }
}

From source file:com.tremolosecurity.proxy.ProxyRequest.java

@Override
public Enumeration getParameterNames() {

    HashSet<String> paramListLocal = new HashSet<String>();
    paramListLocal.addAll(this.paramList);

    for (NVP p : this.queryString) {
        if (!paramListLocal.contains(p.getName())) {
            paramListLocal.add(p.getName());
        }// w  w  w . ja  v a  2 s . co m
    }

    return new IteratorEnumeration(paramListLocal.iterator());

}

From source file:com.esri.geoevent.test.performance.ui.ReportOptionsController.java

/**
 * Sets the report object to initialize the dialog
 *
 * @param report {@link Report}//ww w . j  a  va 2s .c o m
 */
public void setReport(Report report) {
    if (report != null) {
        this.report = report;

        // update report type
        if (report.getType() == null) {
            report.setType(reportType.getValue());
        }
        reportType.setValue(report.getType());

        // update the report file location
        if (StringUtils.isEmpty(report.getReportFile())) {
            report.setReportFile(selectedReportFileLocationLabel.getText());
        }
        updateSelectedReportFile(report.getReportFile());

        // update the report columns
        HashSet<String> columns = new HashSet<String>();
        if (report.getReportColumns() != null) {
            columns.addAll(report.getReportColumns());
        }
        if (report.getAdditionalReportColumns() != null) {
            columns.addAll(report.getAdditionalReportColumns());
        }
        updateSelectedReportColumns(new ArrayList<String>(columns));
    }
}

From source file:org.fusesource.meshkeeper.distribution.registry.zk.ZooKeeperRegistry.java

@SuppressWarnings("unchecked")
public Collection<String> list(String path, boolean recursive, String... filters) throws Exception {
    if (filters != null) {
        HashSet<String> filterSet = new HashSet<String>();
        filterSet.addAll(Arrays.asList(filters));
        return list(path, recursive, new LinkedList<String>(), filterSet);
    } else {//  w  w  w  . j av a2s . c o  m
        return list(path, recursive, new LinkedList<String>(), Collections.EMPTY_LIST);
    }

}

From source file:org.apache.accumulo.core.util.LocalityGroupUtil.java

public static Map<String, Set<ByteSequence>> getLocalityGroups(AccumuloConfiguration acuconf)
        throws LocalityGroupConfigurationError {
    Map<String, Set<ByteSequence>> result = new HashMap<String, Set<ByteSequence>>();
    String[] groups = acuconf.get(Property.TABLE_LOCALITY_GROUPS).split(",");
    for (String group : groups) {
        if (group.length() > 0)
            result.put(group, new HashSet<ByteSequence>());
    }//  w w  w. j a v  a2 s.  c  o m
    HashSet<ByteSequence> all = new HashSet<ByteSequence>();
    for (Entry<String, String> entry : acuconf) {
        String property = entry.getKey();
        String value = entry.getValue();
        String prefix = Property.TABLE_LOCALITY_GROUP_PREFIX.getKey();
        if (property.startsWith(prefix)) {
            // this property configures a locality group, find out which one:
            String group = property.substring(prefix.length());
            String[] parts = group.split("\\.");
            group = parts[0];
            if (result.containsKey(group)) {
                if (parts.length == 1) {
                    Set<ByteSequence> colFamsSet = decodeColumnFamilies(value);
                    if (!Collections.disjoint(all, colFamsSet)) {
                        colFamsSet.retainAll(all);
                        throw new LocalityGroupConfigurationError("Column families " + colFamsSet + " in group "
                                + group + " is already used by another locality group");
                    }

                    all.addAll(colFamsSet);
                    result.put(group, colFamsSet);
                }
            }
        }
    }
    // result.put("", all);
    return result;
}