Example usage for java.util Set size

List of usage examples for java.util Set size

Introduction

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

Prototype

int size();

Source Link

Document

Returns the number of elements in this set (its cardinality).

Usage

From source file:com.uwsoft.editor.utils.runtime.EntityUtils.java

public static Vector2 getLeftBottomPoint(Set<Entity> entities) {
    if (entities.size() == 0)
        return null;

    Vector2 leftBottomPoint = getPosition(entities.stream().findFirst().get());

    for (Entity entity : entities) {
        TransformComponent transformComponent = ComponentRetriever.get(entity, TransformComponent.class);
        if (leftBottomPoint.x > transformComponent.x) {
            leftBottomPoint.x = transformComponent.x;
        }/*from   w w w.  j a v  a2  s  .  com*/
        if (leftBottomPoint.y > transformComponent.y) {
            leftBottomPoint.y = transformComponent.y;
        }
    }

    return leftBottomPoint;
}

From source file:fr.inria.lille.repair.nopol.NoPolLauncher.java

private static void displayResult(NoPol nopol, List<Patch> patches, long executionTime) {
    System.out.println("----INFORMATION----");
    List<CtType<?>> allClasses = nopol.getSpooner().spoonFactory().Class().getAll();
    int nbMethod = 0;
    for (int i = 0; i < allClasses.size(); i++) {
        CtType<?> ctSimpleType = allClasses.get(i);
        if (ctSimpleType instanceof CtClass) {
            Set methods = ((CtClass) ctSimpleType).getMethods();
            nbMethod += methods.size();
        }//from   ww w. j ava2s.  c o m
    }
    System.out.println("Nb classes : " + allClasses.size());
    System.out.println("Nb methods : " + nbMethod);
    BitSet coverage = NoPol.currentStatement.getCoverage();
    int countStatementSuccess = 0;
    int countStatementFailed = 0;
    int nextTest = coverage.nextSetBit(0);
    while (nextTest != -1) {
        TestResult testResult = nopol.getgZoltar().getGzoltar().getTestResults().get(nextTest);
        if (testResult.wasSuccessful()) {
            countStatementSuccess += testResult.getCoveredComponents().size();
        } else {
            countStatementFailed += testResult.getCoveredComponents().size();
        }
        nextTest = coverage.nextSetBit(nextTest + 1);
    }
    System.out
            .println("Nb statements: " + nopol.getgZoltar().getGzoltar().getSpectra().getNumberOfComponents());
    System.out.println(
            "Nb statement executed by the passing tests of the patched line: " + countStatementSuccess);
    System.out
            .println("Nb statement executed by the failing tests of the patched line: " + countStatementFailed);
    System.out.println("Nb unit tests : " + nopol.getgZoltar().getGzoltar().getTestResults().size());
    System.out.println("Nb Statements Analyzed : " + SynthesizerFactory.getNbStatementsAnalysed());
    System.out.println(
            "Nb Statements with Angelic Value Found : " + DefaultSynthesizer.getNbStatementsWithAngelicValue());
    if (Config.INSTANCE.getSynthesis() == Config.NopolSynthesis.SMT) {
        System.out.println("Nb inputs in SMT : " + DefaultSynthesizer.getDataSize());
        System.out.println("Nb SMT level: " + ConstraintBasedSynthesis.level);
        if (ConstraintBasedSynthesis.operators != null) {
            System.out.println("Nb SMT components: [" + ConstraintBasedSynthesis.operators.size() + "] "
                    + ConstraintBasedSynthesis.operators);
            Iterator<Operator<?>> iterator = ConstraintBasedSynthesis.operators.iterator();
            Map<Class, Integer> mapType = new HashMap<>();
            while (iterator.hasNext()) {
                Operator<?> next = iterator.next();
                if (!mapType.containsKey(next.type())) {
                    mapType.put(next.type(), 1);
                } else {
                    mapType.put(next.type(), mapType.get(next.type()) + 1);
                }
            }
            for (Iterator<Class> patchIterator = mapType.keySet().iterator(); patchIterator.hasNext();) {
                Class next = patchIterator.next();
                System.out.println("                  " + next + ": " + mapType.get(next));
            }
        }

        System.out.println("Nb variables in SMT : " + DefaultSynthesizer.getNbVariables());
    }
    System.out.println("Nb run failing test  : " + nbFailingTestExecution);
    System.out.println("Nb run passing test : " + nbPassedTestExecution);
    System.out.println("NoPol Execution time : " + executionTime + "ms");

    if (patches != null && !patches.isEmpty()) {
        System.out.println("----PATCH FOUND----");
        for (Patch patch : patches) {
            System.out.println(patch);
        }
    }
}

From source file:com.o2d.pkayjava.editor.utils.runtime.EntityUtils.java

public static Vector2 getLeftBottomPoint(Set<Entity> entities) {
    if (entities.size() == 0)
        return null;

    Vector2 leftBottomPoint = getPosition(entities.stream().findFirst().get());

    for (Entity entity : entities) {
        TransformComponent transformComponent = ComponentRetriever.get(entity, TransformComponent.class);
        if (leftBottomPoint.x > transformComponent.getX()) {
            leftBottomPoint.x = transformComponent.getX();
        }/*from www .  ja v a2 s  .  c o  m*/
        if (leftBottomPoint.y > transformComponent.getY()) {
            leftBottomPoint.y = transformComponent.getY();
        }
    }

    return leftBottomPoint;
}

From source file:com.uwsoft.editor.utils.runtime.EntityUtils.java

public static Vector2 getRightTopPoint(Set<Entity> entities) {
    if (entities.size() == 0)
        return null;

    Vector2 rightTopPoint = getPosition(entities.stream().findFirst().get());

    for (Entity entity : entities) {
        TransformComponent transformComponent = ComponentRetriever.get(entity, TransformComponent.class);
        DimensionsComponent dimensionsComponent = ComponentRetriever.get(entity, DimensionsComponent.class);

        if (rightTopPoint.x < transformComponent.x + dimensionsComponent.width) {
            rightTopPoint.x = transformComponent.x + dimensionsComponent.width;
        }//from w ww .  j  a v  a  2 s .  c o  m
        if (rightTopPoint.y < transformComponent.y + dimensionsComponent.height) {
            rightTopPoint.y = transformComponent.y + dimensionsComponent.height;
        }
    }

    return rightTopPoint;
}

From source file:de.unentscheidbar.csv2.CaseInsensitiveBenchmark.java

static Collection<String> getLotsOfColumnNames() {

    Random rnd = new Random(0);
    Set<String> names = Collections.newSetFromMap(new CaseInsensitiveMap<String, Boolean>());
    while (names.size() < 100) {
        names.add(randomString(rnd, 1 + rnd.nextInt(30)));
    }//  w w w  . j  a  v a  2  s . co m
    List<String> uniqueNames = new ArrayList<>(names);
    /* For predictable iteration order: */
    Collections.sort(uniqueNames);
    Collections.shuffle(uniqueNames, rnd);
    return Collections.unmodifiableList(uniqueNames);
}

From source file:edu.american.student.stonewall.util.Deployer.java

public static void deploy(List<String> packages, File deployDirectory) throws DeployException {
    Class<? extends Index> indexPage = null;
    List<Class<? extends Page>> otherPages = new ArrayList<Class<? extends Page>>();
    for (String pkg : packages) {
        Reflections reflections = new Reflections(pkg);
        Set<Class<? extends Index>> indexClasses = reflections.getSubTypesOf(Index.class);
        if (indexClasses.size() > 1) {
            throw new DeployException("More than 1 class found that extends Index");
        }/*from w ww . jav a2s.  c om*/
        if (indexClasses.size() == 1) {
            if (indexPage != null) {
                throw new DeployException("More than 1 class found that extends Index");
            } else {
                indexPage = indexClasses.iterator().next();
            }
        }
        Set<Class<? extends Page>> pageClasses = reflections.getSubTypesOf(Page.class);
        for (Class<? extends Page> page : pageClasses) {
            otherPages.add(page);
        }
    }
    try {
        deployMe(indexPage, otherPages, deployDirectory);
    } catch (Exception e) {
        throw new DeployException("Unable to deploy ", e);
    }
}

From source file:com.o2d.pkayjava.editor.utils.runtime.EntityUtils.java

public static Vector2 getRightTopPoint(Set<Entity> entities) {
    if (entities.size() == 0)
        return null;

    Vector2 rightTopPoint = getPosition(entities.stream().findFirst().get());

    for (Entity entity : entities) {
        TransformComponent transformComponent = ComponentRetriever.get(entity, TransformComponent.class);
        DimensionsComponent dimensionsComponent = ComponentRetriever.get(entity, DimensionsComponent.class);

        if (rightTopPoint.x < transformComponent.getX() + dimensionsComponent.width) {
            rightTopPoint.x = transformComponent.getX() + dimensionsComponent.width;
        }/*from  www  .  j  ava 2  s  .c o  m*/
        if (rightTopPoint.y < transformComponent.getY() + dimensionsComponent.height) {
            rightTopPoint.y = transformComponent.getY() + dimensionsComponent.height;
        }
    }

    return rightTopPoint;
}

From source file:Main.java

static public String assemblyUrlByCommon(String url, Map<String, String> params) {
    if (params == null && params.size() == 0) {
        return url;
    } else {//from  w ww.j  a  va 2s . co  m
        StringBuilder sb = new StringBuilder(url);
        sb.append("?");

        Set<String> keys = params.keySet();
        int i = 0;
        for (String key : keys) {
            String value = params.get(key);
            sb.append(key).append("=").append(value);
            if (i != keys.size() - 1) {
                sb.append("&");
            }
            i++;
        }
        return sb.toString();
    }
}

From source file:com.reactive.hzdfs.utils.EntityFinder.java

/**
 * Find implementation classes for the given interface.
 * @param <T>//from   w ww  . j a  v  a2  s. co m
 * @param basePkg
 * @param baseInterface
 * @return
 * @throws ClassNotFoundException
 */
@SuppressWarnings("unchecked")
public static <T> List<Class<T>> findImplementationClasses(String basePkg, final Class<T> baseInterface)
        throws ClassNotFoundException {
    ClassPathScanningCandidateComponentProvider provider = new ClassPathScanningCandidateComponentProvider(
            false);
    provider.addIncludeFilter(new TypeFilter() {

        @Override
        public boolean match(MetadataReader metadataReader, MetadataReaderFactory metadataReaderFactory)
                throws IOException {
            ClassMetadata aMeta = metadataReader.getClassMetadata();
            String[] intf = aMeta.getInterfaceNames();
            Arrays.sort(intf);
            return Arrays.binarySearch(intf, baseInterface.getName()) >= 0;
        }
    });

    Set<Class<?>> collection = findComponents(provider, basePkg);
    List<Class<T>> list = new ArrayList<>(collection.size());
    for (Class<?> c : collection) {
        list.add((Class<T>) c);
    }
    return list;

}

From source file:ddf.security.common.util.PropertiesLoader.java

@SuppressWarnings("unchecked")
public static <K, V> Map<K, V> toMap(Properties properties) {
    if (properties != null) {
        Set<K> keySet = (Set<K>) properties.keySet();
        Map<K, V> map = new HashMap<K, V>(keySet.size() * 2);
        for (K obj : keySet) {
            map.put(obj, (V) properties.get(obj));
        }/*from ww w .  ja v a 2 s  .c  o m*/
        return map;
    }
    return new HashMap<K, V>();
}