Example usage for java.util Set contains

List of usage examples for java.util Set contains

Introduction

In this page you can find the example usage for java.util Set contains.

Prototype

boolean contains(Object o);

Source Link

Document

Returns true if this set contains the specified element.

Usage

From source file:Main.java

public static <T> Set<T> intersect(Set<T> sourceSet, Set<T> targetSet) {
    Set<T> set = new HashSet<T>();
    int sourceSetSize = sourceSet.size();
    int targetSetSize = targetSet.size();
    Set<T> minSet = null;//  ww  w . j  av  a  2s  .c  o  m
    Set<T> maxSet = null;
    if (sourceSetSize <= targetSetSize) {
        minSet = sourceSet;
        maxSet = targetSet;
    } else {
        minSet = targetSet;
        maxSet = sourceSet;

    }

    for (T t : minSet) {
        if (maxSet.contains(t)) {
            set.add(t);
        }
    }
    return set;
}

From source file:com.l2jfree.gameserver.document.DocumentEngine.java

public static List<L2Item> loadArmors(Map<Integer, Item> armorData) {
    final List<L2Item> list = loadData(armorData, listFiles("data/stats/armor"));

    Set<Integer> xmlItem = new HashSet<Integer>();

    for (L2Item item : list)
        xmlItem.add(item.getItemId());/*  ww w.  ja v a2  s . co  m*/

    for (Item item : armorData.values())
        if (!xmlItem.contains(item.id))
            _log.warn("SkillsEngine: Missing XML side for L2Armor - id: " + item.id);

    return list;
}

From source file:com.l2jfree.gameserver.document.DocumentEngine.java

public static List<L2Item> loadWeapons(Map<Integer, Item> weaponData) {
    final List<L2Item> list = loadData(weaponData, listFiles("data/stats/weapon"));

    Set<Integer> xmlItem = new HashSet<Integer>();

    for (L2Item item : list)
        xmlItem.add(item.getItemId());//from ww  w.ja v  a 2  s  .c  o m

    for (Item item : weaponData.values())
        if (!xmlItem.contains(item.id))
            _log.warn("SkillsEngine: Missing XML side for L2Weapon - id: " + item.id);

    return list;
}

From source file:TwitterClustering.java

public static <T> Set<T> intersection(Set<T> setA, Set<T> setB) {
    Set<T> tmp = new TreeSet<T>();
    for (T x : setA) {
        if (setB.contains(x)) {
            tmp.add(x);//from   w  w  w.j a va2s .c  om
        }
    }
    return tmp;
}

From source file:io.github.moosbusch.lumpi.util.FormUtil.java

public static boolean isExcludedProperty(Class<?> type, String propertyName,
        Map<String, Set<Class<?>>> excludedProperties) {
    Map<String, Set<Class<?>>> excludedProps = excludedProperties;

    if (excludedProps != null) {
        if (excludedProps.containsKey(propertyName)) {
            Set<Class<?>> ignoredPropertyTypes = excludedProps.get(propertyName);
            Set<Class<?>> superTypes = LumpiUtil.getSuperTypes(type, true, true, true);

            if (!ignoredPropertyTypes.contains(type)) {
                if (superTypes.stream().anyMatch((superType) -> (!ignoredPropertyTypes.contains(superType)))) {
                    return true;
                }//from w  ww  .  j  a v a2  s .  co m
            }
        }
    }

    return false;
}

From source file:de.bund.bfr.jung.JungUtils.java

public static <V, E> Transformer<V, Stroke> newNodeStrokeTransformer(RenderContext<V, E> renderContext,
        Set<V> metaNodes) {
    return node -> (metaNodes != null && metaNodes.contains(node))
            || renderContext.getPickedVertexState().isPicked(node) ? new BasicStroke(4.0f)
                    : new BasicStroke(1.0f);
}

From source file:com.l2jfree.gameserver.document.DocumentEngine.java

public static List<L2Item> loadItems(Map<Integer, Item> itemData) {
    final List<L2Item> list = loadData(itemData, listFiles("data/stats/etcitem"));

    Set<Integer> xmlItem = new HashSet<Integer>();

    for (L2Item item : list)
        xmlItem.add(item.getItemId());/* w w w  .ja  va 2  s . c  o  m*/

    for (Item item : itemData.values()) {
        if (!xmlItem.contains(item.id)) {
            try {
                list.add(new L2EtcItem((L2EtcItemType) item.type, item.set));
            } catch (RuntimeException e) {
                _log.warn("Error while parsing item id " + item.id, e);
            }
        }
    }

    return list;
}

From source file:com.tesora.dve.tools.DVEAnalyzerCLITest.java

private static void bumpStatementKindCount(final String key, final int freq,
        final Set<String> expectedStmtTypes, final Map<String, Integer> counter) {
    if (expectedStmtTypes.contains(key)) {
        Integer count = counter.get(key);
        final Integer stmtFreq = Integer.valueOf(freq);
        if (count == null) {
            count = stmtFreq;/*from   www . j av a 2s. c o m*/
        } else {
            count += stmtFreq;
        }
        counter.put(key, count);
    }
}

From source file:com.huawei.streaming.cql.executor.ExecutorUtils.java

/**
 * ??//from w ww  .  j  a  va  2 s .co m
 * 
 * To?From??
 * @param transitions 
 * @return 
 */
public static List<OperatorTransition> getLastTransitons(List<OperatorTransition> transitions) {
    List<OperatorTransition> res = new ArrayList<OperatorTransition>();

    Set<String> froms = getFromTransitons(transitions);
    Set<String> tos = getToTransitons(transitions);
    for (String s : tos) {
        if (!froms.contains(s)) {
            res.addAll(getTransitonsByToId(s, transitions));
        }
    }
    return res;
}

From source file:ezbake.deployer.impl.Files.java

@SuppressWarnings("ResultOfMethodCallIgnored")
public static void setPosixFilePermissions(File file, Set<PosixFilePermission> filePermissions) {
    if (filePermissions.contains(PosixFilePermission.OWNER_EXECUTE))
        file.setExecutable(true, filePermissions.contains(PosixFilePermission.GROUP_EXECUTE)
                || filePermissions.contains(PosixFilePermission.OTHERS_EXECUTE));
    if (filePermissions.contains(PosixFilePermission.OWNER_READ))
        file.setReadable(true, filePermissions.contains(PosixFilePermission.GROUP_READ)
                || filePermissions.contains(PosixFilePermission.OTHERS_READ));
    if (filePermissions.contains(PosixFilePermission.OWNER_WRITE))
        file.setWritable(true, filePermissions.contains(PosixFilePermission.GROUP_WRITE)
                || filePermissions.contains(PosixFilePermission.OTHERS_WRITE));
}