Example usage for java.util HashSet isEmpty

List of usage examples for java.util HashSet isEmpty

Introduction

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

Prototype

public boolean isEmpty() 

Source Link

Document

Returns true if this set contains no elements.

Usage

From source file:com.addthis.hydra.job.spawn.JobAlertUtil.java

/**
 * Count the total number of hits along a certain path in a tree object
 * @param jobId The job to query/*from   ww  w. j  a v a 2  s. c  om*/
 * @param checkPath The path to check, e.g.
 * @return The number of hits along the specified path
 */
public static long getQueryCount(String jobId, String checkPath) {

    HashSet<String> result = JSONFetcher.staticLoadSet(getQueryURL(jobId, checkPath, defaultOps, defaultOps),
            alertQueryTimeout, alertQueryRetries, null);
    if (result == null || result.isEmpty()) {
        log.warn("Found no data for job={} checkPath={}; returning zero", jobId, checkPath);
        return 0;
    } else if (result.size() > 1) {
        log.warn("Found multiple results for job={} checkPath={}; using first row", jobId, checkPath);
    }
    String raw = result.iterator().next();
    return Long.parseLong(QUERY_TRIM_PATTERN.matcher(raw).replaceAll("")); // Trim [] characters and parse as long

}

From source file:edu.uci.ics.hyracks.algebricks.core.algebra.util.OperatorPropertiesUtil.java

public static boolean hasFreeVariables(ILogicalOperator op) throws AlgebricksException {
    HashSet<LogicalVariable> free = new HashSet<LogicalVariable>();
    getFreeVariablesInOp(op, free);//from  ww  w . j a  va  2  s . c  o  m
    return !free.isEmpty();
}

From source file:org.apache.hyracks.algebricks.core.algebra.util.OperatorPropertiesUtil.java

public static boolean hasFreeVariablesInSelfOrDesc(AbstractLogicalOperator op) throws AlgebricksException {
    HashSet<LogicalVariable> free = new HashSet<>();
    getFreeVariablesInSelfOrDesc(op, free);
    return !free.isEmpty();
}

From source file:edu.uci.ics.hyracks.algebricks.core.algebra.util.OperatorPropertiesUtil.java

public static boolean hasFreeVariablesInSelfOrDesc(AbstractLogicalOperator op) throws AlgebricksException {
    HashSet<LogicalVariable> free = new HashSet<LogicalVariable>();
    getFreeVariablesInSelfOrDesc(op, free);
    return !free.isEmpty();
}

From source file:org.apache.sysml.hops.codegen.opt.PlanAnalyzer.java

private static Collection<HashSet<Long>> getConnectedSubGraphs(CPlanMemoTable memo, ArrayList<Hop> roots) {
    //build inverted index for 'referenced by' relationship 
    HashMap<Long, HashSet<Long>> refBy = new HashMap<>();
    for (Entry<Long, List<MemoTableEntry>> e : memo.getPlans().entrySet())
        for (MemoTableEntry me : e.getValue())
            for (int i = 0; i < 3; i++)
                if (me.isPlanRef(i)) {
                    if (!refBy.containsKey(me.input(i)))
                        refBy.put(me.input(i), new HashSet<Long>());
                    refBy.get(me.input(i)).add(e.getKey());
                }/*w ww . j a v  a  2  s  .  c  o  m*/

    //create a single partition per root node, if reachable over refBy of 
    //other root node the resulting partition is empty and can be discarded
    ArrayList<HashSet<Long>> parts = new ArrayList<>();
    HashSet<Long> visited = new HashSet<>();
    for (Entry<Long, List<MemoTableEntry>> e : memo.getPlans().entrySet())
        if (!refBy.containsKey(e.getKey())) { //root node
            HashSet<Long> part = rGetConnectedSubGraphs(e.getKey(), memo, refBy, visited, new HashSet<Long>());
            if (!part.isEmpty())
                parts.add(part);
        }

    if (LOG.isTraceEnabled())
        LOG.trace("Connected sub graphs: " + parts.size());

    return parts;
}

From source file:coq.DebugUnivInconst.java

/**
 * //from w  w  w .ja v a2  s.  c  o  m
 * @param s1
 * @param s2
 * @return 
 */
static boolean nonDisjoint(HashSet<String> highlight, Set<String> scc) {
    if (highlight.isEmpty())
        return true;

    HashSet<String> highCopy = new HashSet<String>(highlight);
    highCopy.retainAll(scc);
    return (highCopy.size() > 0);
}

From source file:pt.webdetails.cda.test.util.CdaTestHelper.java

@SafeVarargs
public static <T> boolean columnContains(TableModel table, int colIdx, T... values) {
    HashSet<T> set = new HashSet<T>();
    set.addAll(Arrays.asList(values));
    for (int i = 0; i < table.getRowCount(); i++) {
        set.remove(table.getValueAt(i, colIdx));
        if (set.isEmpty()) {
            return true;
        }/*from   www .j  a  v  a2 s .c  o m*/
    }
    return false;
}

From source file:com.addthis.hydra.job.alert.JobAlertUtil.java

/**
 * Count the total number of hits along a certain path in a tree object
 * @param jobId The job to query/*from   w w  w  .  j a v  a  2 s. c om*/
 * @param checkPath The path to check, e.g.
 * @return The number of hits along the specified path
 */
public static long getQueryCount(String jobId, String checkPath) {
    String queryURL = getQueryURL(jobId, checkPath, defaultOps, defaultOps);

    HashSet<String> result = new JSONFetcher.SetLoader(queryURL)
            .setContention(alertQueryTimeout, alertQueryRetries, alertQueryBackoff).load();
    if (result == null || result.isEmpty()) {
        log.warn("Found no data for job={} checkPath={}; returning zero", jobId, checkPath);
        return 0;
    } else if (result.size() > 1) {
        log.warn("Found multiple results for job={} checkPath={}; using first row", jobId, checkPath);
    }
    String raw = result.iterator().next();
    return Long.parseLong(QUERY_TRIM_PATTERN.matcher(raw).replaceAll("")); // Trim [] characters and parse as long

}

From source file:org.talend.dataquality.statistics.datetime.SystemDateTimePatternManager.java

private static Set<String> dateTimePatternReplace(List<Map<Pattern, String>> patternGroupList, String value) {
    if (StringUtils.isEmpty(value)) {
        return Collections.singleton(StringUtils.EMPTY);
    }/* w  w w.ja v  a  2  s .  c o m*/
    HashSet<String> resultSet = new HashSet<>();
    for (Map<Pattern, String> patternMap : patternGroupList) {
        for (Pattern parser : patternMap.keySet()) {
            if (parser.matcher(value).find()) {
                resultSet.add(patternMap.get(parser));
            }
        }
        if (!resultSet.isEmpty()) {
            return resultSet;
        }
    }
    return resultSet;
}

From source file:com.marlonjones.voidlauncher.InstallShortcutReceiver.java

public static void removeFromInstallQueue(Context context, HashSet<String> packageNames,
        UserHandleCompat user) {//from w w  w.ja v a  2 s.co m
    if (packageNames.isEmpty()) {
        return;
    }
    SharedPreferences sp = Utilities.getPrefs(context);
    synchronized (sLock) {
        Set<String> strings = sp.getStringSet(APPS_PENDING_INSTALL, null);
        if (DBG) {
            Log.d(TAG, "APPS_PENDING_INSTALL: " + strings + ", removing packages: " + packageNames);
        }
        if (strings != null) {
            Set<String> newStrings = new HashSet<String>(strings);
            Iterator<String> newStringsIter = newStrings.iterator();
            while (newStringsIter.hasNext()) {
                String encoded = newStringsIter.next();
                PendingInstallShortcutInfo info = decode(encoded, context);
                if (info == null
                        || (packageNames.contains(info.getTargetPackage()) && user.equals(info.user))) {
                    newStringsIter.remove();
                }
            }
            sp.edit().putStringSet(APPS_PENDING_INSTALL, newStrings).apply();
        }
    }
}